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

# Get DCA Orders

> Retrieve all DCA orders for a specific trader address

## Overview

Fetches all DCA orders created by a trader, with filtering options for order status and pagination support. Each order includes execution history, remaining cycles, and current status.

## Request

<ParamField query="traderAddress" type="string" required>
  Trader's wallet address (hex format)
</ParamField>

<ParamField query="status" type="string">
  Filter by order status (`INDEXING`, `ACTIVE`, or `CLOSED`)
</ParamField>

<ParamField query="page" type="number" default={0}>
  Page number for pagination
</ParamField>

<ParamField query="size" type="number" default={20}>
  Number of orders per page (max: 50)
</ParamField>

<ParamField query="sort" type="string" default="createdAt,desc">
  Sort order. Format: `field,direction`

  * Fields: `createdAt`, `status`, `remainingCycles`
  * Direction: `asc` or `desc`
</ParamField>

## Response

<ResponseField name="content" type="array" required>
  Array of DCA order objects

  <Expandable title="Order Object">
    <ResponseField name="id" type="string" required>
      The order identifier (UUID format)
    </ResponseField>

    <ResponseField name="blockNumber" type="number" required>
      The block number when the order was created
    </ResponseField>

    <ResponseField name="timestamp" type="string" required>
      The timestamp when the order was created (ISO 8601 format)
    </ResponseField>

    <ResponseField name="traderAddress" type="string" required>
      The trader address (hex format)
    </ResponseField>

    <ResponseField name="orderAddress" type="string" required>
      The order address (hex format)
    </ResponseField>

    <ResponseField name="creationTransactionHash" type="string" required>
      The transaction hash of the order creation
    </ResponseField>

    <ResponseField name="orderClassHash" type="string" required>
      The order class hash
    </ResponseField>

    <ResponseField name="sellTokenAddress" type="string" required>
      The sell token address (hex format)
    </ResponseField>

    <ResponseField name="sellAmount" type="string" required>
      The total amount you want to invest (hex format)
    </ResponseField>

    <ResponseField name="sellAmountPerCycle" type="string" required>
      The amount that will be sold at each iteration (hex format)
    </ResponseField>

    <ResponseField name="buyTokenAddress" type="string" required>
      The buy token address (hex format)
    </ResponseField>

    <ResponseField name="startDate" type="string" required>
      The start date of the order (ISO 8601 format)
    </ResponseField>

    <ResponseField name="endDate" type="string" required>
      The end date of the order (ISO 8601 format)
    </ResponseField>

    <ResponseField name="closeDate" type="string">
      The close date of the order (ISO 8601 format)
    </ResponseField>

    <ResponseField name="frequency" type="string" required>
      The duration between each iteration. Follows ISO 8601 standard
    </ResponseField>

    <ResponseField name="iterations" type="integer" required>
      The number of iterations
    </ResponseField>

    <ResponseField name="status" type="string" required>
      The order status (`INDEXING`, `ACTIVE`, or `CLOSED`)
    </ResponseField>

    <ResponseField name="pricingStrategy" type="object">
      The pricing strategy

      <Expandable title="properties">
        <ResponseField name="tokenToMinAmount" type="string">
          The buy token's min price you're agree to execute a trade
        </ResponseField>

        <ResponseField name="tokenToMaxAmount" type="string">
          The buy token's max price you're agree to execute a trade
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="amountSold" type="string" required>
      The amount already sold
    </ResponseField>

    <ResponseField name="amountBought" type="string" required>
      The amount already bought
    </ResponseField>

    <ResponseField name="averageAmountBought" type="string" required>
      The average amount bought
    </ResponseField>

    <ResponseField name="executedTradesCount" type="integer" required>
      The number of executed trades
    </ResponseField>

    <ResponseField name="cancelledTradesCount" type="integer" required>
      The number of cancelled trades
    </ResponseField>

    <ResponseField name="pendingTradesCount" type="integer" required>
      The number of pending trades
    </ResponseField>

    <ResponseField name="trades" type="array" required>
      The trades

      <Expandable title="Trade Object">
        <ResponseField name="sellAmount" type="string" required>
          The amount sold
        </ResponseField>

        <ResponseField name="sellAmountInUsd" type="number">
          The amount sold in USD
        </ResponseField>

        <ResponseField name="buyAmount" type="string">
          The amount bought
        </ResponseField>

        <ResponseField name="buyAmountInUsd" type="number">
          The amount bought in USD
        </ResponseField>

        <ResponseField name="expectedTradeDate" type="string" required>
          The expected trade date (ISO 8601 format)
        </ResponseField>

        <ResponseField name="status" type="string" required>
          The trade status (`PENDING`, `SUCCEEDED`, or `CANCELLED`)
        </ResponseField>

        <ResponseField name="actualTradeDate" type="string">
          The actual trade date (ISO 8601 format)
        </ResponseField>

        <ResponseField name="txHash" type="string">
          The transaction hash of the trade
        </ResponseField>

        <ResponseField name="errorReason" type="string">
          The error reason. Defined only if the trade failed
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="size" type="integer" required>
  Page size
</ResponseField>

<ResponseField name="number" type="integer" required>
  Current page number (zero-based)
</ResponseField>

<ResponseField name="totalElements" type="integer" required>
  Total number of orders
</ResponseField>

<ResponseField name="totalPages" type="integer" required>
  Total pages available
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://starknet.api.avnu.fi/dca/v3/orders?traderAddress=0x0123...&status=ACTIVE"
  ```

  ```typescript TypeScript theme={null}
  // Fetch active DCA orders
  const params = new URLSearchParams({
    traderAddress: account.address,
    status: 'ACTIVE',
    page: '0',
    size: '10'
  });

  const response = await fetch(`https://starknet.api.avnu.fi/dca/v3/orders?${params}` );

  const data = await response.json();
  console.log(`Found ${data.totalElements} active orders`);
  console.log(`Page ${data.number + 1} of ${data.totalPages}`);

  data.content.forEach(order => {
    console.log(`Order ${order.orderAddress}: ${order.sellTokenAddress} -> ${order.buyTokenAddress}`);
  });
  ```

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

  params = {
      'traderAddress': account_address,
      'status': 'ACTIVE',
      'page': 0,
      'size': 10
  }

  response = requests.get(
      'https://starknet.api.avnu.fi/dca/v3/orders',
      params=params
  )

  data = response.json()
  orders = data['content']

  print(f"Found {data['totalElements']} active orders")
  print(f"Page {data['number'] + 1} of {data['totalPages']}")

  for order in orders:
      print(f"Order {order['orderAddress'][:10]}...")
      print(f"  Status: {order['status']}")
      print(f"  Sell: {order['sellTokenAddress']}")
      print(f"  Buy: {order['buyTokenAddress']}")
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "content": [
      {
        "id": "ae1a649c-a9fb-4130-835b-cb14e144e8c1",
        "blockNumber": 860820,
        "timestamp": "2024-10-31T16:01:15Z",
        "traderAddress": "0x25b..",
        "orderAddress": "0x50ab..",
        "creationTransactionHash": "0x6b65..",
        "orderClassHash": "0x2d5af3e59f6b180bb2190957b527dd4db61a2c1095d4fd1e75e3a89732c796b",
        "sellTokenAddress": "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",
        "sellAmount": "0xde0b6b3a7640000",
        "sellAmountPerCycle": "0x94079cd1a42aaa",
        "buyTokenAddress": "0x3fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac",
        "startDate": "2024-10-31T16:01:15Z",
        "endDate": "2024-11-01T16:01:15Z",
        "closeDate": "2024-11-01T15:02:27.923Z",
        "frequency": "PT1H",
        "iterations": 24,
        "status": "CLOSED",
        "pricingStrategy": {},
        "amountSold": "0xde0b6b3a763fff0",
        "amountBought": "0x214",
        "averageAmountBought": "0x16",
        "executedTradesCount": 24,
        "cancelledTradesCount": 0,
        "pendingTradesCount": 0,
        "trades": [
          {
            "sellAmount": "0x94079cd1a42aaa",
            "sellAmountInUsd": 0.015667,
            "buyAmount": "0x17",
            "buyAmountInUsd": 0.016246,
            "expectedTradeDate": "2024-10-31T16:01:15Z",
            "status": "SUCCEEDED",
            "actualTradeDate": "2024-10-31T16:01:56.860Z",
            "txHash": "0x25a006ecd.."
          },
          {
            "sellAmount": "0x94079cd1a42aaa",
            "sellAmountInUsd": 0.015561,
            "buyAmount": "0x16",
            "buyAmountInUsd": 0.015482,
            "expectedTradeDate": "2024-10-31T17:01:15Z",
            "status": "SUCCEEDED",
            "actualTradeDate": "2024-10-31T17:01:57.834Z",
            "txHash": "0x7972e18b2c.."
          }
        ]
      }
    ],
    "size": 25,
    "number": 0,
    "totalElements": 1,
    "totalPages": 1
  }
  ```
</ResponseExample>

## Order Status

* **INDEXING**: Order is being indexed after creation (temporary state)
* **ACTIVE**: Order is currently active and executing
* **CLOSED**: Order has been completed or cancelled
