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

# Order History

> Get historical orders with filtering and pagination

## Overview

Retrieve order history for the authenticated user. This endpoint returns orders regardless of status, with optional filtering and pagination. For active orders, use the [List Active Orders](/pro/api-reference/list-orders) endpoint.

## Authentication

<ParamField header="X-Api-Key" type="string" required>
  Your API key with Read or Trade scope

  ```
  X-Api-Key: daya_sk_YOUR_API_KEY
  ```
</ParamField>

## Query Parameters

<ParamField query="status" type="string">
  Filter by order status

  **Allowed values:** `filled`, `cancelled`, `rejected`, `partially_filled`
</ParamField>

<ParamField query="symbol" type="string">
  Filter by trading pair symbol

  **Example:** `USDT-NGN`
</ParamField>

<ParamField query="side" type="string">
  Filter by order side

  **Allowed values:** `buy`, `sell`
</ParamField>

<ParamField query="type" type="string">
  Filter by order type

  **Allowed values:** `market`, `limit`
</ParamField>

<ParamField query="start_time" type="string">
  Filter orders created after this time (RFC3339 format)

  **Example:** `2024-01-01T00:00:00Z`
</ParamField>

<ParamField query="end_time" type="string">
  Filter orders created before this time (RFC3339 format)

  **Example:** `2024-12-31T23:59:59Z`
</ParamField>

<ParamField query="limit" type="integer">
  Maximum number of orders to return

  **Default:** `50`

  **Range:** `1` to `100`
</ParamField>

<ParamField query="offset" type="integer">
  Number of orders to skip for pagination

  **Default:** `0`
</ParamField>

## Request Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url 'https://api.pro.daya.co/public/v1/orders/history?symbol=USDT-NGN&status=filled&limit=20' \
    --header 'X-Api-Key: daya_sk_YOUR_API_KEY'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://api.pro.daya.co/public/v1/orders/history?symbol=USDT-NGN&status=filled&limit=20',
    {
      headers: { 'X-Api-Key': 'daya_sk_YOUR_API_KEY' }
    }
  );

  const data = await response.json();
  console.log('Order history:', data.data.orders);
  ```

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

  headers = {'X-Api-Key': 'daya_sk_YOUR_API_KEY'}

  response = requests.get(
      'https://api.pro.daya.co/public/v1/orders/history',
      headers=headers,
      params={
          'symbol': 'USDT-NGN',
          'status': 'filled',
          'limit': 20
      }
  )

  result = response.json()
  print(f"Order history: {result['data']['orders']}")
  ```

  ```go Go theme={null}
  package main

  import (
      "encoding/json"
      "fmt"
      "net/http"
  )

  func main() {
      req, _ := http.NewRequest("GET", "https://api.pro.daya.co/public/v1/orders/history?symbol=USDT-NGN&status=filled&limit=20", nil)
      req.Header.Set("X-Api-Key", "daya_sk_YOUR_API_KEY")

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      var result map[string]interface{}
      json.NewDecoder(resp.Body).Decode(&result)
      fmt.Println("Order history:", result["data"])
  }
  ```
</CodeGroup>

## Response

<ResponseField name="success" type="boolean" required>
  Indicates if the request was successful
</ResponseField>

<ResponseField name="message" type="string" required>
  Human-readable response message
</ResponseField>

<ResponseField name="data" type="object" required>
  Paginated order data

  <Expandable title="data properties">
    <ResponseField name="orders" type="array">
      Array of order objects

      <Expandable title="order properties">
        <ResponseField name="id" type="string">
          Unique order identifier (UUID)
        </ResponseField>

        <ResponseField name="user_id" type="string">
          User identifier
        </ResponseField>

        <ResponseField name="symbol" type="string">
          Trading pair symbol
        </ResponseField>

        <ResponseField name="side" type="string">
          Order side: `buy` or `sell`
        </ResponseField>

        <ResponseField name="type" type="string">
          Order type: `limit` or `market`
        </ResponseField>

        <ResponseField name="status" type="string">
          Order status: `filled`, `cancelled`, `rejected`, `partially_filled`
        </ResponseField>

        <ResponseField name="price" type="string">
          Order price (for limit orders)
        </ResponseField>

        <ResponseField name="quantity" type="string">
          Original order quantity
        </ResponseField>

        <ResponseField name="filled_quantity" type="string">
          Quantity that has been filled
        </ResponseField>

        <ResponseField name="remaining_quantity" type="string">
          Remaining quantity (0 for filled orders)
        </ResponseField>

        <ResponseField name="executed_price" type="string">
          Average execution price
        </ResponseField>

        <ResponseField name="total_value" type="string">
          Total order value in quote currency
        </ResponseField>

        <ResponseField name="filled_value" type="string">
          Value of filled portion
        </ResponseField>

        <ResponseField name="base_currency" type="string">
          Base currency code (e.g. `USD`)
        </ResponseField>

        <ResponseField name="quote_currency" type="string">
          Quote currency code (e.g. `NGN`)
        </ResponseField>

        <ResponseField name="created_at" type="string">
          ISO 8601 creation timestamp
        </ResponseField>

        <ResponseField name="updated_at" type="string">
          ISO 8601 last update timestamp
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="total_count" type="integer">
      Total number of orders matching the filter
    </ResponseField>

    <ResponseField name="limit" type="integer">
      Number of orders returned
    </ResponseField>

    <ResponseField name="offset" type="integer">
      Offset used for pagination
    </ResponseField>

    <ResponseField name="has_more" type="boolean">
      Whether there are more results beyond the current page
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="timestamp" type="string">
  ISO 8601 timestamp of the response
</ResponseField>

### Success Response

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "success": true,
    "message": "Order history retrieved successfully",
    "data": {
      "orders": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "user_id": "user_abc123",
          "symbol": "USD-NGN",
          "side": "buy",
          "type": "limit",
          "status": "filled",
          "price": "1545.00",
          "quantity": "100.00000000",
          "filled_quantity": "100.00000000",
          "remaining_quantity": "0.00000000",
          "executed_price": "1545.00",
          "total_value": "154500.00",
          "filled_value": "154500.00",
          "base_currency": "USD",
          "quote_currency": "NGN",
          "created_at": "2024-01-15T10:35:00Z",
          "updated_at": "2024-01-15T10:35:05Z"
        },
        {
          "id": "550e8400-e29b-41d4-a716-446655440001",
          "user_id": "user_abc123",
          "symbol": "USD-NGN",
          "side": "sell",
          "type": "market",
          "status": "filled",
          "price": "",
          "quantity": "50.00000000",
          "filled_quantity": "50.00000000",
          "remaining_quantity": "0.00000000",
          "executed_price": "1546.50",
          "total_value": "77325.00",
          "filled_value": "77325.00",
          "base_currency": "USD",
          "quote_currency": "NGN",
          "created_at": "2024-01-14T15:20:00Z",
          "updated_at": "2024-01-14T15:20:01Z"
        }
      ],
      "total_count": 156,
      "limit": 20,
      "offset": 0,
      "has_more": true
    },
    "timestamp": "2024-01-15T10:35:00Z"
  }
  ```
</ResponseExample>

## Error Responses

<ResponseExample>
  ```json 401 Unauthorized theme={null}
  {
    "success": false,
    "message": "Unauthorized",
    "error": {
      "code": "API_KEY_INVALID",
      "message": "The provided API key is invalid"
    },
    "timestamp": "2024-01-15T10:35:00Z"
  }
  ```

  ```json 400 Bad Request - Invalid filter theme={null}
  {
    "success": false,
    "message": "Validation error",
    "error": {
      "code": "VALIDATION_ERROR",
      "message": "Invalid start_time format. Use RFC3339 format."
    },
    "timestamp": "2024-01-15T10:35:00Z"
  }
  ```
</ResponseExample>

## Pagination

Use `limit` and `offset` for pagination. The response includes `total_count` and `has_more` to help navigate pages.

## Rate Limits

* **100 requests per minute** per API key

## Next Steps

<CardGroup cols={2}>
  <Card title="List Active Orders" icon="list" href="/pro/api-reference/list-orders">
    View your active orders
  </Card>

  <Card title="List Trades" icon="arrow-right-arrow-left" href="/pro/api-reference/list-trades">
    View individual trade executions
  </Card>

  <Card title="Get Order" icon="magnifying-glass" href="/pro/api-reference/get-order">
    Get details of a specific order
  </Card>

  <Card title="Place Order" icon="plus" href="/pro/api-reference/place-order">
    Place a new order
  </Card>
</CardGroup>
