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

# Get Orderbook

> View the current orderbook for a GPU type and zone

## Query Parameters

<ParamField query="gpu_type" type="string" required>
  GPU type: `h100`, `h200`, `b200`, or `b300`
</ParamField>

<ParamField query="zone" type="string" required>
  Availability zone: `us-west-1`, `us-east-1`, or `eu-west-1`
</ParamField>

<ParamField query="depth" type="integer" default="10">
  Number of price levels to return (max: 50)
</ParamField>

## Response

<ResponseField name="market_depth" type="object">
  Current market depth with best bid/ask prices
</ResponseField>

<ResponseField name="bids" type="array">
  Array of buy orders (highest price first)
</ResponseField>

<ResponseField name="asks" type="array">
  Array of sell orders (lowest price first)
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl "https://api.galadriel.com/v1/orderbook?gpu_type=h100&zone=us-west-1&depth=10" \
    -H "Authorization: Bearer YOUR_API_TOKEN"
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      "https://api.galadriel.com/v1/orderbook",
      headers={"Authorization": "Bearer YOUR_API_TOKEN"},
      params={
          "gpu_type": "h100",
          "zone": "us-west-1",
          "depth": 10
      }
  )

  orderbook = response.json()
  print(f"Best Bid: ${orderbook['market_depth']['best_bid']}/hr")
  print(f"Best Ask: ${orderbook['market_depth']['best_ask']}/hr")
  print(f"Spread: ${orderbook['market_depth']['spread']}")
  ```

  ```javascript JavaScript theme={null}
  const params = new URLSearchParams({
    gpu_type: 'h100',
    zone: 'us-west-1',
    depth: '10'
  });

  const response = await fetch(
    `https://api.galadriel.com/v1/orderbook?${params}`,
    {
      headers: {
        'Authorization': 'Bearer YOUR_API_TOKEN'
      }
    }
  );

  const orderbook = await response.json();
  console.log(`Best Bid: $${orderbook.market_depth.best_bid}/hr`);
  console.log(`Best Ask: $${orderbook.market_depth.best_ask}/hr`);
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "gpu_type": "h100",
    "zone": "us-west-1",
    "timestamp": "2025-11-11T14:00:00Z",
    "market_depth": {
      "best_bid": 1.30,
      "best_ask": 1.40,
      "spread": 0.10,
      "mid_price": 1.35
    },
    "bids": [
      {
        "price": 1.30,
        "gpus": 24,
        "orders": 3
      },
      {
        "price": 1.25,
        "gpus": 16,
        "orders": 2
      },
      {
        "price": 1.20,
        "gpus": 32,
        "orders": 4
      }
    ],
    "asks": [
      {
        "price": 1.40,
        "gpus": 16,
        "orders": 2
      },
      {
        "price": 1.45,
        "gpus": 8,
        "orders": 1
      },
      {
        "price": 1.50,
        "gpus": 24,
        "orders": 3
      }
    ],
    "last_trade": {
      "price": 1.35,
      "gpus": 8,
      "timestamp": "2025-11-11T13:55:00Z"
    },
    "volume_24h": 1920
  }
  ```
</ResponseExample>

## Using Orderbook Data

The orderbook helps you make informed pricing decisions:

```python theme={null}
# Check if there's enough liquidity for your order
gpus_needed = 16
available = sum(level['gpus'] for level in orderbook['asks'])

if available >= gpus_needed:
    print("Sufficient liquidity for market order")
    best_price = orderbook['market_depth']['best_ask']
else:
    print("Insufficient liquidity, consider limit order")

# Calculate estimated cost for market order
cost = 0
remaining = gpus_needed
for level in orderbook['asks']:
    if remaining <= 0:
        break
    take = min(remaining, level['gpus'])
    cost += take * level['price'] * 24  # 24 hour lease
    remaining -= take

print(f"Estimated cost for market order: ${cost}")
```
