> For the complete documentation index, see [llms.txt](https://docs.panora.exchange/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.panora.exchange/developer/dca.md).

# DCA

## 1. Create a DCA Order

<mark style="color:green;">`POST`</mark> `https://api.panora.exchange/dca/v1/createOrder`

### Headers

* **Public API Key**:

  ```
  a4^KV_EaTf4MW#ZdvgGKX#HUD^3IFEAOV_kzpIE^3BQGA8pDnrkT7JcIy#HNlLGi
  ```

  ***Note:** This API key's limits should be sufficient for most use cases. Protocols within the Aptos ecosystem with specific requirements or customization may submit a ticket on Discord.*&#x20;

| Name      | Value        | Description                                                    |
| --------- | ------------ | -------------------------------------------------------------- |
| x-api-key | Your API Key | Use the public API key or enter the API key provided by Panora |

### Request Body

| Parameter                    | Required | Type                                                       | Description                                                             |
| ---------------------------- | -------- | ---------------------------------------------------------- | ----------------------------------------------------------------------- |
| `chainId`                    | yes      | `string`                                                   | ID for the chain for which the endpoint is being invoked.               |
| `toWalletAddress`            | yes      | `0x${string}`                                              | Address of the wallet to receive the purchased tokens.                  |
| `fromTokenAddress`           | yes      | `0x${string}`                                              | Address of the token you're selling.                                    |
| `toTokenAddress`             | yes      | `0x${string}`                                              | Address of the token you're buying.                                     |
| `fromTokenAmount.value`      | yes      | `string`                                                   | Amount of tokens to sell (either total or per order).                   |
| `fromTokenAmount.type`       | yes      | `"total"` \| `"perorder"`                                  | Whether the amount is total for the entire DCA or per individual order. |
| `interval.value`             | yes      | `string`                                                   | Value of the time interval between each order.                          |
| `interval.timePeriod`        | yes      | `"minute"` \| `"hour"` \| `"day"` \| `"week"` \| `"month"` | Unit of time for the interval.                                          |
| `numberOfOrders`             | yes      | `number`                                                   | Total number of orders to execute over time.                            |
| `minRateToTokenPerFromToken` | no       | `string`                                                   | Minimum acceptable exchange rate (toToken per fromToken).               |
| `maxRateToTokenPerFromToken` | no       | `string`                                                   | Maximum acceptable exchange rate (toToken per fromToken).               |
| `delay.value`                | no       | `string`                                                   | Value for delay before the first order starts.                          |
| `delay.timePeriod`           | no       | `"minute"` \| `"hour"` \| `"day"` \| `"week"` \| `"month"` | Unit of time for the delay.                                             |
| `slippagePercentage`         | no       | `string`                                                   | Slippage tolerance percentage allowed for each order.                   |

### Request Example

{% tabs %}
{% tab title="Javascript" %}

```javascript
// CALL THE BELOW FUNCTION WITH ASYNC
const end_point = 'https://api.panora.exchange/dca/v1/createOrder';

const requestBody = {
    chainId: 1,
    limit: 5,
    pageNumber: 1,
    status: "active",
    toWalletAddress: "0xe98d018a6958a6d1cde384aa69a746259df98488970c49fc5f46d10c5229ee56",
    txDetails: true
};

const headers = {
    "x-api-key": "Your API key",
    "Content-Type": "application/json"
};

const url = `${end_point}`;

const response = await (
    await fetch(url, {
        method: 'POST',
        headers: headers,
        body: JSON.stringify(requestBody)
    })
).json();

console.log(response);

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = 'https://api.panora.exchange/dca/v1/createOrder'

headers = {
    'x-api-key': 'Your API key',
    'Content-Type': 'application/json'
}

payload = {
    "chainId": 1,
    "limit": 5,
    "page_number": 1,
    "status": "active",
    "toWalletAddress": "0xe98d018a6958a6d1cde384aa69a746259df98488970c49fc5f46d10c5229ee56",
    "txDetails": True
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())

```

{% endtab %}

{% tab title="Go" %}

```go
package main

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

func main() {
	url := "https://api.panora.exchange/dca/v1/createOrder"

	payload := map[string]interface{}{
		"chainId":         1,
		"limit":           5,
		"page_number":     1,
		"status":          "active",
		"toWalletAddress": "0xe98d018a6958a6d1cde384aa69a746259df98488970c49fc5f46d10c5229ee56",
		"txDetails":       true,
	}

	jsonData, _ := json.Marshal(payload)

	req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
	req.Header.Set("x-api-key", "Your API key")
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, _ := client.Do(req)
	defer resp.Body.Close()

	var result map[string]interface{}
	json.NewDecoder(resp.Body).Decode(&result)
	fmt.Println(result)
}

```

{% endtab %}

{% tab title="Curl" %}

```
curl -X POST https://api.panora.exchange/dca/v1/createOrder \
  -H "x-api-key: Your API key" \
  -H "Content-Type: application/json" \
  -d '{
    "chainId": 1,
    "limit": 5,
    "page_number": 1,
    "status": "active",
    "toWalletAddress": "0xe98d018a6958a6d1cde384aa69a746259df98488970c49fc5f46d10c5229ee56",
    "txDetails": true
  }'

```

{% endtab %}
{% endtabs %}

## 2. Cancel a DCA Order

<mark style="color:green;">`POST`</mark> `https://api.panora.exchange/dca/v1/cancelOrder`

### Request Body

| Parameter         | Required | Type   | Description                                                            |
| ----------------- | -------- | ------ | ---------------------------------------------------------------------- |
| `chainId`         | no       | string | ID for the chain for which the endpoint is being invoked.              |
| `toWalletAddress` | no       | string | Address of the wallet associated with the transaction to be cancelled. |
| `panoraTxId`      | yes      | string | The Panora transaction ID of the order that needs to be cancelled.     |

### Request Example

{% tabs %}
{% tab title="Javascript" %}

```javascript
// CALL THE BELOW FUNCTION WITH ASYNC
const end_point = 'https://api.panora.exchange/dca/v1/cancelOrder';

const requestBody = {
    "chainId": "1",
    "toWalletAddress": "0xe98d018a6958a6d1cde384aa69a746259df98488970c49fc5f46d10c5229ee56",
    "panoraTxId": "0xc88d69a35bac183dd91e5a836e0fd0182127c557045db052fb6565dc5d98b962",
};

const headers = {
    "x-api-key": "Your API key",
    "Content-Type": "application/json"
};

const url = `${end_point}`;

const response = await (
    await fetch(url, {
        method: 'POST',
        headers: headers,
        body: JSON.stringify(requestBody)
    })
).json();

console.log(response);

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = 'https://api.panora.exchange/dca/v1/cancelOrder'
headers = {
    'x-api-key': 'Your API key',
    'Content-Type': 'application/json'
}
payload = {
    "chainId": "1",
    "toWalletAddress": "0xe98d018a6958a6d1cde384aa69a746259df98488970c49fc5f46d10c5229ee56",
    "panoraTxId": "0xc88d69a35bac183dd91e5a836e0fd0182127c557045db052fb6565dc5d98b962"
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())

```

{% endtab %}

{% tab title="Go" %}

```go
package main

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

func main() {
	url := "https://api.panora.exchange/dca/v1/cancelOrder"

	payload := map[string]string{
		"chainId":        "1",
		"toWalletAddress": "0xe98d018a6958a6d1cde384aa69a746259df98488970c49fc5f46d10c5229ee56",
		"panoraTxId":      "0xc88d69a35bac183dd91e5a836e0fd0182127c557045db052fb6565dc5d98b962",
	}

	jsonData, err := json.Marshal(payload)
	if err != nil {
		panic(err)
	}

	req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
	if err != nil {
		panic(err)
	}
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("x-api-key", "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(result)
}

```

{% endtab %}

{% tab title="Curl" %}

```
curl -X POST https://api.panora.exchange/dca/v1/cancelOrder \
  -H "Content-Type: application/json" \
  -H "x-api-key: Your API key" \
  -d '{
    "chainId": "1",
    "toWalletAddress": "0xe98d018a6958a6d1cde384aa69a746259df98488970c49fc5f46d10c5229ee56",
    "panoraTxId": "0xc88d69a35bac183dd91e5a836e0fd0182127c557045db052fb6565dc5d98b962"
}'

```

{% endtab %}
{% endtabs %}

## 3. Get DCA Orders

<mark style="color:green;">`POST`</mark> `https://api.panora.exchange/dca/v1/getOrders`

| Parameter         | Required | Type                        | Description                                               |
| ----------------- | -------- | --------------------------- | --------------------------------------------------------- |
| `chainId`         | Yes      | number                      | ID for the chain for which the endpoint is being invoked. |
| `toWalletAddress` | Yes      | string                      | Wallet address associated with the order.                 |
| `panoraTxId`      | No       | string                      | Specific transaction ID to filter results.                |
| `status`          | Yes      | `"active"` \| `"completed"` | Filter orders by their status.                            |
| `txDetails`       | No       | boolean                     | Whether to include transaction details in the response.   |
| `limit`           | Yes      | number                      | Maximum number of results per page.                       |
| `pageNumber`      | Yes      | number                      | Page number for pagination.                               |

{% tabs %}
{% tab title="Javascript" %}

```javascript
// CALL THE BELOW FUNCTION WITH ASYNC
const end_point = 'https://api.panora.exchange/dca/v1/getOrders';

const queryParams = {
    chainId: 1,
    limit: 5,
    pageNumber: 1,
    status: "active",
    toWalletAddress: "0xe98d018a6958a6d1cde384aa69a746259df98488970c49fc5f46d10c5229ee56",
    txDetails: true
};

const queryString = new URLSearchParams(queryParams).toString();
const url = `${end_point}?${queryString}`;

const headers = {
    "x-api-key": "Your API key"
};

const response = await (
    await fetch(url, {
        method: 'GET',
        headers: headers
    })
).json();

console.log(response);

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.panora.exchange/dca/v1/getOrders"
params = {
    "chainId": 1,
    "limit": 5,
    "page_number": 1,
    "status": "active",
    "toWalletAddress": "0xe98d018a6958a6d1cde384aa69a746259df98488970c49fc5f46d10c5229ee56",
    "txDetails": True
}

headers = {
    "x-api-key": "Your API key"
}

response = requests.get(url, headers=headers, params=params)
print(response.json())

```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
)

func main() {
	baseURL := "https://api.panora.exchange/dca/v1/getOrders"

	params := url.Values{}
	params.Add("chainId", "1")
	params.Add("limit", "5")
	params.Add("page_number", "1")
	params.Add("status", "active")
	params.Add("toWalletAddress", "0xe98d018a6958a6d1cde384aa69a746259df98488970c49fc5f46d10c5229ee56")
	params.Add("txDetails", "true")

	reqURL := fmt.Sprintf("%s?%s", baseURL, params.Encode())

	req, err := http.NewRequest("GET", reqURL, nil)
	if err != nil {
		panic(err)
	}
	req.Header.Add("x-api-key", "Your API key")

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

	body, _ := ioutil.ReadAll(resp.Body)
	fmt.Println(string(body))
}

```

{% endtab %}

{% tab title="Curl" %}

```
curl -X GET "https://api.panora.exchange/dca/v1/getOrders?chainId=1&limit=5&page_number=1&status=active&toWalletAddress=0xe98d018a6958a6d1cde384aa69a746259df98488970c49fc5f46d10c5229ee56&txDetails=true" \
  -H "x-api-key: Your API key"

```

{% endtab %}
{% endtabs %}

### 📦 DCA`OrdersResponse` (Object)

| Parameter         | Type   | Description                                         |
| ----------------- | ------ | --------------------------------------------------- |
| `chainId`         | number | Chain ID of the DCA order.                          |
| `toWalletAddress` | string | Wallet address associated with the order.           |
| `pageNumber`      | number | Current page in the paginated response.             |
| `totalPages`      | number | Total number of pages available.                    |
| `orders`          | array  | List of DCA orders. Each item is an `Order` object. |

### 📦 orders\[] (Order Object)

| Parameter                     | Type              | Description                                                           |
| ----------------------------- | ----------------- | --------------------------------------------------------------------- |
| `panoraTxId`                  | string            | Unique ID of the Panora transaction.                                  |
| `fromToken`                   | Token             | Token being sold.                                                     |
| `toToken`                     | Token             | Token being bought.                                                   |
| `feeToken`                    | Token             | Token used to pay fees.                                               |
| `fromTokenAmountTotal`        | string            | Total amount of `fromToken` for the DCA.                              |
| `fromTokenAmountSpent`        | string            | Amount of `fromToken` already used.                                   |
| `fromTokenAmountBalance`      | string            | Remaining amount of `fromToken`.                                      |
| `fromTokenAmountWithdrawn`    | string            | Withdrawn amount of `fromToken`.                                      |
| `toTokenAmountWithdrawn`      | string            | Withdrawn amount of `toToken`.                                        |
| `numberOfOrdersTotal`         | number            | Total number of orders.                                               |
| `fromTokenAmountPerOrder`     | string            | Amount per order.                                                     |
| `numberOfOrdersRemaining`     | number            | Number of pending orders.                                             |
| `numberOfOrdersCompleted`     | number            | Number of completed orders.                                           |
| `interval`                    | object            | Object with `value` and `timePeriod` (`"minute"`, `"hour"`, `"day"`). |
| `createdAtTime`               | string            | ISO timestamp when order was created.                                 |
| `nextOrderTime`               | string            | ISO timestamp of the next scheduled order.                            |
| `estimatedCompletionTime`     | string (optional) | When the DCA is expected to complete.                                 |
| `avgPriceFromTokenPerToToken` | string            | Avg. price fromToken/toToken.                                         |
| `avgPriceToTokenPerFromToken` | string            | Avg. price toToken/fromToken.                                         |
| `minRateToTokenPerFromToken`  | string (optional) | Minimum rate (can be `"Infinity"`).                                   |
| `maxRateToTokenPerFromToken`  | string (optional) | Maximum rate (can be `"Infinity"`).                                   |
| `status`                      | string            | `"active"` \| `"filled"` \| `"cancelled"` \| `"refunded"`             |
| `platformId`                  | string            | Platform identifier.                                                  |
| `slippagePercentage`          | string            | Allowed slippage.                                                     |
| `delay`                       | object (optional) | Delay config: `value` + `timePeriod`.                                 |
| `txDetails`                   | array (optional)  | List of transaction details (see below).                              |

### orders\[] (Order Object)

| Parameter                  | Type              | Description                                                               |
| -------------------------- | ----------------- | ------------------------------------------------------------------------- |
| `txId`                     | string            | Unique transaction ID.                                                    |
| `txNumber`                 | number            | Sequential number of transaction.                                         |
| `type`                     | string            | One of `"created"`, `"filled"`, `"attempted"`, `"failed"`, `"cancelled"`. |
| `attemptNumber`            | number            | Attempt count for this order.                                             |
| `fromTokenAmount`          | string            | Amount used from source token.                                            |
| `fromTokenAmountUSD`       | string            | USD value of `fromTokenAmount`.                                           |
| `toTokenAmount`            | string            | Amount of output token received.                                          |
| `toTokenAmountUSD`         | string            | USD value of `toTokenAmount`.                                             |
| `feeTokenAmount`           | string            | Amount paid as fee.                                                       |
| `feeTokenAmountUSD`        | string            | USD value of fee paid.                                                    |
| `time`                     | string            | Time when tx was processed.                                               |
| `priceFromTokenPerToToken` | string (optional) | Execution price (from → to).                                              |
| `priceToTokenPerFromToken` | string (optional) | Execution price (to → from).                                              |
