Swap API
Public API reference for swap quotes, order creation, and order tracking.
Swap API
This document describes the public Swap API for website and external integrations.
All endpoints in this document are published under the following namespace:
/external/swap/*Base URL
https://back.2aml.com/external/swapAuthentication
The Swap API does not require JWT authentication.
Recommended headers:
Content-Type: application/json
Accept: application/jsonOptional attribution header:
x-fingerprint: fp_browser_or_device_identifierIf x-fingerprint is sent in both the request header and the request body, the body value takes precedence.
General Conventions
- All request amounts must be sent as strings.
- Quote responses return numeric amounts.
- Order responses return stored order amounts as strings.
- All timestamps are returned as ISO 8601 strings.
orderIdis the canonical identifier for tracking an order.
Integration Flow
Recommended integration sequence:
- Call
GET /currencies. - Call
GET /pairs. - Call
GET /min-amountorGET /range. - Call
GET /estimated-amount. - Optionally call
GET /network-fee. - Call
GET /validate/address. - Call
POST /orders. - Poll
GET /orders/:orderIduntil a terminal status is reached.
Optional utility endpoint:
GET /markets/estimatefor display-only market conversion.
Request Modes
Direct Requests
Use type=direct when the source amount is known in advance.
- Send
fromAmount. - Do not rely on
toAmountas the input field.
Reverse Requests
Use type=reverse when the destination amount is known in advance.
- Send
toAmount. - Reverse requests are supported only in
fixed-rateflow.
Fixed-Rate Quotes
If a fixed-rate quote returns rateId, preserve it exactly and send it unchanged to POST /orders.
Integration rules:
- treat
rateIdas an opaque value - do not parse it
- do not trim it
- do not assume a fixed format or length
Refund Address
Some fixed-rate requests can require refundAddress.
Integration rule:
- if your integration supports fixed-rate execution, support
refundAddressin both quote and create flows
Order Status
| Status | Terminal | Description |
|---|---|---|
awaiting_deposit | No | The order is created and payment instructions are available. |
confirming | No | A deposit has been detected and is awaiting confirmation. |
processing | No | The swap is being processed. |
sending | No | The payout transfer is in progress. |
completed | Yes | The order completed successfully. |
failed | Yes | The order failed. |
refunded | Yes | The order was refunded. |
pending_support | Yes | The order cannot continue automatically through this API. |
Order display rules:
- show payment instructions only while
payment !== null - stop polling after a terminal status is returned
- always branch on
status, not on free-text message content
Endpoint Summary
| Method | Path | Purpose |
|---|---|---|
GET | /currencies | List supported swap currencies and networks |
GET | /pairs | List supported currency routes |
GET | /min-amount | Return the minimum supported amount for a route |
GET | /range | Return the minimum and maximum supported amount for a route |
GET | /estimated-amount | Return a quote estimate |
GET | /network-fee | Return estimated network fees |
GET | /markets/estimate | Return a display-oriented market conversion estimate |
GET | /validate/address | Validate the destination payout address |
POST | /orders | Create a swap order |
GET | /orders/:orderId | Get order status by orderId |
1. List Currencies
Returns the supported currency and network combinations for swap.
Endpoint
GET /currenciesQuery Parameters
| Field | Type | Required | Description |
|---|---|---|---|
active | string | No | If true, returns only active assets. |
flow | `'standard' | 'fixed-rate'` | No |
buy | string | No | Optional availability filter. |
sell | string | No | Optional availability filter. |
Example Request
curl --request GET \
--url 'https://back.2aml.com/external/swap/currencies?active=true'Example Response
[
{
"currency": "btc",
"network": "btc",
"name": "Bitcoin",
"supportsFixedRate": true,
"destinationExtraIdSupported": false,
"destinationExtraIdRequired": false,
"isStable": false,
"isFiat": false,
"tokenContract": null
}
]Response Fields
| Field | Type | Description |
|---|---|---|
currency | string | Asset ticker. |
network | string | Network identifier to use in later requests. |
name | string | Display name. |
supportsFixedRate | boolean | Whether fixed-rate mode is available. |
destinationExtraIdSupported | boolean | Whether a destination extra id can be submitted. |
destinationExtraIdRequired | boolean | Whether a destination extra id is required. |
isStable | boolean | Whether the asset is marked as stable. |
isFiat | boolean | Whether the asset is fiat. |
tokenContract | `string | null` |
2. List Pairs
Returns supported swap routes.
Endpoint
GET /pairsQuery Parameters
| Field | Type | Required | Description |
|---|---|---|---|
fromCurrency | string | No | Optional source currency filter. |
fromNetwork | string | No | Optional source network filter. |
toCurrency | string | No | Optional destination currency filter. |
toNetwork | string | No | Optional destination network filter. |
flow | `'standard' | 'fixed-rate'` | No |
Example Request
curl --request GET \
--url 'https://back.2aml.com/external/swap/pairs?fromCurrency=btc&toCurrency=eth'Example Response
[
{
"fromCurrency": "btc",
"fromNetwork": "btc",
"toCurrency": "eth",
"toNetwork": "eth",
"flow": {
"standard": true,
"fixedRate": true
}
}
]3. Get Min Amount
Returns the minimum supported source amount for a route.
Endpoint
GET /min-amountQuery Parameters
| Field | Type | Required | Description |
|---|---|---|---|
fromCurrency | string | Yes | Source asset ticker. |
fromNetwork | string | No | Source network. |
toCurrency | string | Yes | Destination asset ticker. |
toNetwork | string | No | Destination network. |
flow | `'standard' | 'fixed-rate'` | No |
Example Request
curl --request GET \
--url 'https://back.2aml.com/external/swap/min-amount?fromCurrency=btc&fromNetwork=btc&toCurrency=eth&toNetwork=eth'Example Response
{
"fromCurrency": "btc",
"fromNetwork": "btc",
"toCurrency": "eth",
"toNetwork": "eth",
"flow": "standard",
"minAmount": 0.0002787
}4. Get Range
Returns the minimum and maximum supported source amount for a route.
Endpoint
GET /rangeQuery Parameters
Same as GET /min-amount.
Example Request
curl --request GET \
--url 'https://back.2aml.com/external/swap/range?fromCurrency=btc&fromNetwork=btc&toCurrency=eth&toNetwork=eth&flow=standard'Example Response
{
"fromCurrency": "btc",
"fromNetwork": "btc",
"toCurrency": "eth",
"toNetwork": "eth",
"flow": "standard",
"minAmount": 0.0002625,
"maxAmount": null
}5. Get Estimated Amount
Returns a quote estimate for the selected route.
Endpoint
GET /estimated-amountQuery Parameters
| Field | Type | Required | Description |
|---|---|---|---|
fromCurrency | string | Yes | Source asset ticker. |
fromNetwork | string | No | Source network. |
toCurrency | string | Yes | Destination asset ticker. |
toNetwork | string | No | Destination network. |
fromAmount | string | For direct | Source amount. |
toAmount | string | For reverse | Destination amount. |
refundAddress | string | No | Optional refund address. |
flow | `'standard' | 'fixed-rate'` | No |
type | `'direct' | 'reverse'` | No |
useRateId | string | No | Set to true to request a reusable rateId for fixed-rate quotes. |
Direct Fixed-Rate Example
curl --request GET \
--url 'https://back.2aml.com/external/swap/estimated-amount?fromCurrency=btc&fromNetwork=btc&toCurrency=eth&toNetwork=eth&fromAmount=0.001&flow=fixed-rate&type=direct&useRateId=true'Reverse Fixed-Rate Example
curl --request GET \
--url 'https://back.2aml.com/external/swap/estimated-amount?fromCurrency=btc&fromNetwork=btc&toCurrency=eth&toNetwork=eth&toAmount=0.03&flow=fixed-rate&type=reverse&useRateId=true'Example Response
{
"fromCurrency": "btc",
"fromNetwork": "btc",
"toCurrency": "eth",
"toNetwork": "eth",
"flow": "fixed-rate",
"type": "direct",
"rateId": "dzmw56abdj0hvodg_4y26aqcy8yfiyyp",
"validUntil": "2026-05-03T12:45:00.000Z",
"transactionSpeedForecast": "10-60",
"warningMessage": null,
"fromAmount": 0.001,
"toAmount": 0.03312805,
"depositFee": 0,
"withdrawalFee": 0
}Response Fields
| Field | Type | Description |
|---|---|---|
fromCurrency | string | Source asset. |
fromNetwork | `string | null` |
toCurrency | string | Destination asset. |
toNetwork | `string | null` |
flow | string | Quote flow. |
type | string | Request mode. |
rateId | `string | null` |
validUntil | `string | null` |
transactionSpeedForecast | `string | null` |
warningMessage | `string | null` |
fromAmount | number | Source amount for the quote. |
toAmount | number | Destination amount for the quote. |
depositFee | number | Estimated deposit-side fee. |
withdrawalFee | number | Estimated withdrawal-side fee. |
6. Get Network Fee
Returns estimated fee data for the selected route.
Endpoint
GET /network-feeQuery Parameters
| Field | Type | Required | Description |
|---|---|---|---|
fromCurrency | string | Yes | Source asset ticker. |
fromNetwork | string | No | Source network. |
toCurrency | string | Yes | Destination asset ticker. |
toNetwork | string | No | Destination network. |
fromAmount | string | No | Source amount. |
toAmount | string | No | Destination amount. |
refundAddress | string | No | Optional refund address. |
flow | `'standard' | 'fixed-rate'` | No |
type | `'direct' | 'reverse'` | No |
convertedCurrency | string | No | Optional conversion currency for fee display. |
convertedNetwork | string | No | Optional conversion network. |
Example Request
curl --request GET \
--url 'https://back.2aml.com/external/swap/network-fee?fromCurrency=btc&fromNetwork=btc&toCurrency=eth&toNetwork=eth&fromAmount=0.001&flow=fixed-rate&type=direct&convertedCurrency=usd'Example Response
{
"estimatedFee": {
"deposit": {
"currency": "btc",
"network": "btc",
"amount": 0.00013
},
"withdrawal": {
"currency": "eth",
"network": "eth",
"amount": 0.0012
},
"totals": {
"from": {
"currency": "btc",
"network": "btc",
"amount": 0.00013
},
"to": {
"currency": "eth",
"network": "eth",
"amount": 0.0012
}
},
"converted": {
"currency": "usd",
"deposit": 4.21,
"withdrawal": 3.17,
"total": 7.38
}
}
}7. Get Market Estimate
Returns a display-oriented market conversion estimate. This endpoint is not an executable order quote.
Endpoint
GET /markets/estimateQuery Parameters
| Field | Type | Required | Description |
|---|---|---|---|
fromCurrency | string | Yes | Source asset ticker. |
fromNetwork | string | No | Source network. |
toCurrency | string | Yes | Destination asset ticker. |
toNetwork | string | No | Destination network. |
fromAmount | string | For direct | Source amount. |
toAmount | string | For reverse | Destination amount. |
type | `'direct' | 'reverse'` | No |
Example Request
curl --request GET \
--url 'https://back.2aml.com/external/swap/markets/estimate?fromCurrency=usdt&fromNetwork=trx&toCurrency=btc&toNetwork=btc&fromAmount=1000&type=direct'Example Response
{
"fromCurrency": "usdt",
"fromNetwork": "trx",
"toCurrency": "btc",
"toNetwork": "btc",
"fromAmount": 1000,
"toAmount": 0.09527438736782325,
"type": "direct"
}8. Validate Address
Validates the destination payout address.
Endpoint
GET /validate/addressQuery Parameters
| Field | Type | Required | Description |
|---|---|---|---|
currency | string | Yes | Destination asset ticker. |
network | string | No | Destination network hint. |
address | string | Yes | Destination address. |
Example Request
curl --request GET \
--url 'https://back.2aml.com/external/swap/validate/address?currency=eth&network=eth&address=0x57f31ad4b64095347F87eDB1675566DAfF5EC886'Example Response
{
"valid": true,
"reason": null,
"addressActive": null
}9. Create Order
Creates a swap order.
Endpoint
POST /ordersRequest Body
| Field | Type | Required | Description |
|---|---|---|---|
fromCurrency | string | Yes | Source asset ticker. |
fromNetwork | string | No | Source network. |
fromAmount | string | For direct | Source amount. |
toCurrency | string | Yes | Destination asset ticker. |
toNetwork | string | No | Destination network. |
toAmount | string | For reverse | Destination amount. |
destinationAddress | string | Yes | Destination payout address. |
destinationExtraId | string | No | Destination memo or tag when required. |
refundAddress | string | No | Optional refund address. |
refundExtraId | string | No | Optional refund memo or tag. |
rateId | string | No | Fixed-rate token obtained from the quote endpoint. |
fingerprint | string | No | Optional attribution fingerprint. |
referralCode | string | No | Optional referral code. |
acceptedTerms | boolean | Yes | Must be true. |
type | `'direct' | 'reverse'` | No |
flow | `'standard' | 'fixed-rate'` | No |
Example Request
curl --request POST \
--url 'https://back.2aml.com/external/swap/orders' \
--header 'Content-Type: application/json' \
--header 'x-fingerprint: fp_8bcafb2f41' \
--data '{
"fromCurrency": "btc",
"fromNetwork": "btc",
"fromAmount": "0.001",
"toCurrency": "eth",
"toNetwork": "eth",
"destinationAddress": "0x57f31ad4b64095347F87eDB1675566DAfF5EC886",
"acceptedTerms": true,
"flow": "fixed-rate",
"type": "direct",
"rateId": "dzmw56abdj0hvodg_4y26aqcy8yfiyyp"
}'Example Response
{
"orderId": "ORD-20260503-AB12CD34",
"status": "awaiting_deposit",
"message": "Send the exact deposit asset to the provided payment address.",
"deposit": {
"currency": "btc",
"network": "btc",
"amount": "0.001"
},
"receive": {
"currency": "eth",
"network": "eth",
"amount": "0.03312805"
},
"payment": {
"address": "3M7QKsJDKbVZAhFPpFSVtVQv6Nzon3Lwtv",
"extraId": null,
"reference": "PAY-ORD-20260503-AB12CD34",
"qrPayload": "bitcoin:3M7QKsJDKbVZAhFPpFSVtVQv6Nzon3Lwtv?amount=0.001",
"qrCodeDataUrl": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
},
"steps": {
"awaitingDeposit": "waiting",
"confirming": "waiting",
"processing": "waiting",
"sending": "waiting"
},
"updatedAt": "2026-05-03T12:30:00.000Z"
}Response Fields
| Field | Type | Description |
|---|---|---|
orderId | string | Canonical order identifier. |
status | string | Current order status. |
message | string | Customer-facing status message. |
deposit | object | Source asset, network, and amount for this order. |
receive | object | Destination asset, network, and amount for this order. |
payment | `object | null` |
steps | object | Progress summary. |
updatedAt | string | Last update timestamp. |
payment.reference is a customer-facing reference value. payment.address and the related QR data must be treated as active only while payment is present in the response.
10. Get Order
Returns the latest customer-facing order status by orderId.
Endpoint
GET /orders/:orderIdExample Request
curl --request GET \
--url 'https://back.2aml.com/external/swap/orders/ORD-20260503-AB12CD34'Example Response
{
"orderId": "ORD-20260503-AB12CD34",
"status": "confirming",
"message": "Deposit detected. Waiting for blockchain confirmation.",
"deposit": {
"currency": "btc",
"network": "btc",
"amount": "0.001"
},
"receive": {
"currency": "eth",
"network": "eth",
"amount": "0.03312805"
},
"payment": {
"address": "3M7QKsJDKbVZAhFPpFSVtVQv6Nzon3Lwtv",
"extraId": null,
"reference": "PAY-ORD-20260503-AB12CD34",
"qrPayload": "bitcoin:3M7QKsJDKbVZAhFPpFSVtVQv6Nzon3Lwtv?amount=0.001",
"qrCodeDataUrl": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
},
"steps": {
"awaitingDeposit": "done",
"confirming": "waiting",
"processing": "waiting",
"sending": "waiting"
},
"updatedAt": "2026-05-03T12:32:00.000Z"
}Polling Recommendation
awaiting_deposit: poll every 10 to 20 secondsconfirming: poll every 10 secondsprocessing: poll every 10 secondssending: poll every 10 seconds- terminal states: stop polling
Error Responses
All errors in this namespace use the following structure:
{
"statusCode": 400,
"timestamp": "2026-05-03T12:40:00.000Z",
"path": "/external/swap/orders",
"error": {
"message": "Order request is invalid."
}
}Validation Error Example
{
"statusCode": 400,
"timestamp": "2026-05-03T12:40:00.000Z",
"path": "/external/swap/orders",
"error": {
"message": [
"fromCurrency should not be empty",
"toCurrency should not be empty",
"acceptedTerms must be a boolean value"
]
}
}Not Found Example
{
"statusCode": 404,
"timestamp": "2026-05-03T12:40:00.000Z",
"path": "/external/swap/orders/ORD-DOES-NOT-EXIST",
"error": {
"message": "Order not found."
}
}Rate Limit Example
{
"statusCode": 429,
"timestamp": "2026-05-03T12:40:00.000Z",
"path": "/external/swap/orders",
"error": {
"message": "Too many requests. Please try again shortly."
}
}Temporary Service Error Example
{
"statusCode": 503,
"timestamp": "2026-05-03T12:40:00.000Z",
"path": "/external/swap/estimated-amount",
"error": {
"message": "Swap service is temporarily unavailable."
}
}Reference Schemas
type SwapCurrency = {
currency: string;
network: string;
name: string;
supportsFixedRate: boolean;
destinationExtraIdSupported: boolean;
destinationExtraIdRequired: boolean;
isStable: boolean;
isFiat: boolean;
tokenContract: string | null;
};
type SwapPair = {
fromCurrency: string;
fromNetwork: string;
toCurrency: string;
toNetwork: string;
flow: {
standard: boolean;
fixedRate: boolean;
};
};
type SwapEstimate = {
fromCurrency: string;
fromNetwork: string | null;
toCurrency: string;
toNetwork: string | null;
flow: string;
type: string;
rateId: string | null;
validUntil: string | null;
transactionSpeedForecast: string | null;
warningMessage: string | null;
fromAmount: number;
toAmount: number;
depositFee: number;
withdrawalFee: number;
};
type SwapOrder = {
orderId: string;
status:
| 'awaiting_deposit'
| 'confirming'
| 'processing'
| 'sending'
| 'completed'
| 'failed'
| 'refunded'
| 'pending_support';
message: string;
deposit: {
currency: string | null;
network: string | null;
amount: string | null;
};
receive: {
currency: string | null;
network: string | null;
amount: string | null;
};
payment: {
address: string;
extraId: string | null;
reference: string;
qrPayload: string | null;
qrCodeDataUrl: string | null;
} | null;
steps: {
awaitingDeposit: 'waiting' | 'done';
confirming: 'waiting' | 'done';
processing: 'waiting' | 'done';
sending: 'waiting' | 'done';
};
updatedAt: string;
};
