> ## Documentation Index
> Fetch the complete documentation index at: https://docs.strike.markets/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Quick setup guide for trading on Strike Protocol API

## Base URL

All API endpoints are served from:

```
https://api.strike.markets
```

## Quick Start

### 1. Get Your API Key

1. Visit [strike.markets](https://strike.markets) and connect your wallet
2. Click your wallet address → API Keys tab → Generate API Key
3. **Save the key immediately** - it won't be shown again

### 2. Test Connection

```bash theme={null}
curl -X GET "https://api.strike.markets/api-key/status" \
  -H "X-API-Key: stk_your_api_key_here"
```

### 3. Make Your First Trade

```bash theme={null}
curl -X POST "https://api.strike.markets/long" \
  -H "X-API-Key: stk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "margin": "100.0",
    "leverage": 10,
    "symbol": "BTC-USD"
  }'
```

## Trading Examples

<CodeGroup>
  ```python Python theme={null}
  import requests
  import os
  from dotenv import load_dotenv

  load_dotenv()

  API_KEY = os.getenv('STRIKE_API_KEY')
  BASE_URL = 'https://api.strike.markets'
  headers = {'X-API-Key': API_KEY, 'Content-Type': 'application/json'}

  def get_markets():
      """Get available markets and prices"""
      response = requests.get(f'{BASE_URL}/markets')
      if response.status_code == 200:
          return response.json()['data']
      return []

  def open_position(side, margin, leverage, symbol='BTC-USD'):
      """Open a long or short position"""
      endpoint = '/long' if side == 'long' else '/short'
      
      response = requests.post(
          f'{BASE_URL}{endpoint}',
          json={'margin': str(margin), 'leverage': leverage, 'symbol': symbol},
          headers=headers
      )
      
      if response.status_code == 200:
          position = response.json()
          print(f"✅ Position opened: ID {position['positionId']}")
          print(f"Entry: ${position['position']['entry_price']}")
          print(f"Liquidation: ${position['liquidation_price']}")
          return position
      else:
          print(f"❌ Failed: {response.json()}")
          return None

  def get_positions(wallet_address):
      """Get all positions for a wallet"""
      response = requests.get(
          f'{BASE_URL}/positions/{wallet_address}',
          headers=headers
      )
      
      if response.status_code == 200:
          return response.json()
      return None

  def close_position(position_id):
      """Close a position"""
      response = requests.post(
          f'{BASE_URL}/close',
          json={'positionId': position_id},
          headers=headers
      )
      
      if response.status_code == 200:
          result = response.json()
          print(f"✅ Position closed")
          return result
      return None

  # Example usage
  markets = get_markets()
  print(f"Available markets: {[m['symbol'] for m in markets]}")

  # Open a 100 USD long with 10x leverage
  position = open_position('long', 100, 10, 'BTC-USD')

  # Check positions
  wallet = "0x742d35cc6c6c7532b1140da4c8a2f6c8ecfc9b46"
  positions = get_positions(wallet)

  # Close position
  if position:
      close_position(position['positionId'])
  ```

  ```javascript JavaScript theme={null}
  const API_KEY = process.env.STRIKE_API_KEY;
  const BASE_URL = 'https://api.strike.markets';

  async function makeRequest(endpoint, method = 'GET', data = null) {
    const options = {
      method,
      headers: {
        'X-API-Key': API_KEY,
        'Content-Type': 'application/json',
      },
    };
    
    if (data) {
      options.body = JSON.stringify(data);
    }
    
    const response = await fetch(`${BASE_URL}${endpoint}`, options);
    if (!response.ok) {
      throw new Error(`HTTP ${response.status}: ${await response.text()}`);
    }
    return response.json();
  }

  // Get markets
  const markets = await makeRequest('/markets');
  console.log('Markets:', markets.data.map(m => m.symbol));

  // Open long position
  const position = await makeRequest('/long', 'POST', {
    margin: '100.0',
    leverage: 10,
    symbol: 'BTC-USD'
  });
  console.log('Position opened:', position.positionId);

  // Get positions
  const wallet = '0x742d35cc6c6c7532b1140da4c8a2f6c8ecfc9b46';
  const positions = await makeRequest(`/positions/${wallet}`);
  console.log('Active positions:', positions.active);

  // Close position
  await makeRequest('/close', 'POST', {
    positionId: position.positionId
  });
  ```
</CodeGroup>
