> For the complete documentation index, see [llms.txt](https://docs.aftermath.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aftermath.finance/for-developers/api.md).

# API

Aftermath currently maintain two sets of API: **Aftermath REST API** and **Aftermath CCXT API**. Both are detailed here: <https://aftermath.finance/docs/>. CCXT also maintains documentation for the Aftermath CCXT integration here: <https://docs.ccxt.com/#/exchanges/aftermath>.

## Perpetuals REST API

The production API includes native Sui transaction builders under `/api/perpetuals/*`. Important endpoint groups include:

| Capability                      | Endpoints                                                                                                                                                                                                  |
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Account creation and collateral | `/api/perpetuals/transactions/create-account`, `/api/perpetuals/account/transactions/deposit-collateral`, `allocate-collateral`, `deallocate-collateral`, `transfer-collateral`, and `withdraw-collateral` |
| Order placement                 | `/api/perpetuals/account/transactions/place-market-order`, `place-limit-order`, `place-scale-order`, `place-stop-orders`, and `place-sl-tp-orders`                                                         |
| Atomic requoting                | `/api/perpetuals/account/transactions/cancel-and-place-orders`                                                                                                                                             |
| TWAP orders                     | `/api/perpetuals/account/transactions/create-twap-orders`, `edit-twap-orders`, `cancel-twap-orders`, and `/api/perpetuals/account/twap-order-datas`                                                        |
| Transaction previews            | `/api/perpetuals/account/previews/*` for orders, collateral, leverage, and cancellations                                                                                                                   |
| Account and position state      | `/api/perpetuals/accounts`, `/api/perpetuals/accounts/owned`, and `/api/perpetuals/accounts/positions`                                                                                                     |
| Account history                 | `/api/perpetuals/account/order-history`, `order-history-detailed`, `order-history-detailed-csv`, `collateral-history`, and `margin-history`                                                                |
| Market data                     | `/api/perpetuals/markets`, `markets/prices`, `markets/orderbooks`, `markets/24hr-stats`, and market candle, funding, and order history endpoints                                                           |
| Agent wallets and sponsorship   | Account and vault `grant-agent-wallet` / `revoke-agent-wallet` transaction builders, plus the `sponsor` field on supported transaction requests                                                            |
| Builder codes and rebates       | `/api/perpetuals/builder-codes/*` and `/api/perpetuals/rebates/*`                                                                                                                                          |
| Vault configuration             | `/api/perpetuals/vaults/config` for deployment-driven vault limits                                                                                                                                         |
| GasPool                         | `/api/gas-pool/*` for pool creation, deposits, grants, sponsorship, sharing, and withdrawals                                                                                                               |
| Live updates                    | `wss://aftermath.finance/api/perpetuals/ws/updates`                                                                                                                                                        |

Account transaction routes generally have vault equivalents under `/api/perpetuals/vault/transactions/*`, including atomic cancel-and-place and TWAP order management. Use the production [OpenAPI reference](https://aftermath.finance/docs/) for request and response schemas.

The REST API also covers pools, staking, DCA, spot limit orders, prices, rewards, referrals, router utilities, wallet data, zkLogin, and dynamic gas. See the [REST API guide](/for-developers/api/rest-api.md) and [complete endpoint inventory](/for-developers/api/rest-api/endpoint-inventory.md).
