Trading API quickstart
This section provides a step by step guide for understanding your trading account and completing your first trade. Refer to the following sections (Hold APIs and A1 APIs) for more detail.
This section assumes you have already created and configured your API key. Refer to the following sections for a more detailed guide of our trading APIs at Anchorage Digital.
- List trading account . Start by listing the trading accounts associated with your organization. This will provide you with the trading account ID(s) you will need for future calls.
Response:
{
"data": [
{
"enabled": true,
"id": "1a7df984-c4b4-11ef-ad6b-4e27db456598",
"name": "Test Trading Account [TRUST]"
}
]
}- (a) (For pre-funded trading only) List trading account balances. Check the pre-funded balance using your API key and the trading account id obtained from the previous step. In the below example, the trading account has three assets pre-funded: USD, BTC, and SOL.
Response:
{
"data": [
{
"balance": {
"assetType": "USD",
"currentPrice": "1",
"currentUSDValue": "989793.79",
"quantity": "989793.79"
}
},
{
"balance": {
"assetType": "BTC",
"currentPrice": "94404.709262226",
"currentUSDValue": "755237.67",
"quantity": "8"
}
},
{
"balance": {
"assetType": "SOL",
"currentPrice": "183.26165178161",
"currentUSDValue": "916.31",
"quantity": "5"
}
}
]
}- (b) (For credit limit trading only) Get trading account credit limit and usage. Check the credit limit for the account and any unsettled trades. In the below example, my credit limit is $1,000,000 and I have two outstanding balances in AAVE and USD.
{
"data": {
"limits": [
{
"assetType": "USD",
"quantity": "1000000"
}
],
"usage": [
{
"assetType": "AAVE",
"quantity": "50"
},
{
"assetType": "USD",
"quantity": "100770.01"
}
]
}
}- List trading pairs. Next, request and review the available trading pairs for your organization. The header of the response is shown below.
{
"data": [
{
"description": "Buy AAVE with USD, or Sell AAVE for USD",
"pair": "AAVE-USD",
"referenceData": {
"baseAssetType": "AAVE",
"baseSizeIncrement": "0.00000001",
"lastUpdateTime": "2024-07-09T15:57:55.249Z",
"minimumOrderSize": "0.000000010000000000000002",
"priceIncrement": "0.0000001",
"quoteAssetType": "USD",
"quoteSizeIncrement": "0.01"
}
},
{
"description": "Buy AAVE with USDC, or Sell AAVE for USDC",
"pair": "AAVE-USDC",
"referenceData": {
"baseAssetType": "AAVE",
"baseSizeIncrement": "0.00001",
"lastUpdateTime": "2024-07-09T15:57:58.787Z",
"minimumOrderSize": "0.000009999999999999999",
"priceIncrement": "0.00000001",
"quoteAssetType": "USDC",
"quoteSizeIncrement": "0.01"
}
},
{
"description": "Buy ATOM with BTC, or Sell ATOM for BTC",
"pair": "ATOM-BTC"
},
{
"description": "Buy ATOM with USD, or Sell ATOM for USD",
"pair": "ATOM-USD",
"referenceData": {
"baseAssetType": "ATOM",
"baseSizeIncrement": "0.0001",
"lastUpdateTime": "2024-07-09T15:58:40.691Z",
"minimumOrderSize": "1",
"priceIncrement": "0.000001",
"quoteAssetType": "USD",
"quoteSizeIncrement": "0.001"
}
},
[continued] - Request a quote. Now that you have an understanding of your trading parameters, request a quote. You will need to include the following parameters:
- tradingPair. Select a pair from the prior call (ex. “BTC-USD”)
- quantity. Quote in the units of currency. (1)
- currency. Currency of quantity. (“BTC”)
- side. Side of the quote request. "BUY", "SELL", or "TWOWAY".
- idempotentId. Optional parameter which should be unique for each quote to avoid duplicating trades.
Note the below example does not include the authenticated header which must also be passed to request s quote.
API Request: POST /v2/trading/quote
{
"currency": "BTC",
"quantity": "1",
"side": "BUY",
"tradingPair": "BTC-USD",
"idempotentId": "01944c42-5ad3-4108-b376-f78cd6ff0394",
"accountId": "fd80d8fc-d20f-11ef-ab13-d2dbc7cc735e"
}
API Response (755ms):
{
"data": {
"offerAmount": {
"assetType": "USD",
"quantity": "99551.67"
},
"offerPrice": "99551.67",
"quoteID": "45055f47-1d5c-4444-921c-7208c3e4178e",
"quoteRequest": {
"currency": "BTC",
"quantity": "1",
"side": "BUY",
"tradingPair": "BTC-USD"
},
"quoteStatus": "OPEN",
"timestamp": "2025-01-15T19:29:01.870Z",
"validUntilTime": "2025-01-15T19:29:04.870Z"
}
}
✓ Successfully requested quote
<Response [201]>- Accept a quote. Once you have received a quote, you may accept the quote to execute the trade.
API Request: POST /v2/trading/quote/accept
{
"quoteID": "45055f47-1d5c-4444-921c-7208c3e4178e",
"side": "BUY",
"allowedSlippage": "0.001",
"accountId": "fd80d8fc-d20f-11ef-ab13-d2dbc7cc735e",
"idempotentId": "01944c42-5ad3-4108-b376-f78cd6ff0394"
}
API Response (617ms):
{
"data": {
"quoteID": "45055f47-1d5c-4444-921c-7208c3e4178e",
"side": "BUY",
"tradeID": "4ececdba-56c9-4cf2-ae11-9f439c351b43",
"tradeStatus": "PENDING"
}
}
✓ Successfully accepted quote
Updated 9 months ago
Did this page help you?