Download OpenAPI specification:Download
Welcome to the Backpack Exchange API. This API is for programmatic trade execution. All of the endpoints require requests to be signed with an ED25519 keypair for authentication.
The API is hosted at https://api.backpack.exchange/
and the WS API is hosted at wss://ws.backpack.exchange/
.
Signed requests are required for any API calls that mutate state. Additionally, some read only requests can be performed by signing or via session authentication.
Signed requests require the following additional headers:
X-Timestamp
- Unix time in milliseconds that the request was sent.X-Window
- Time window in milliseconds that the request is valid for, default is 5000
and maximum is 60000
.X-API-Key
- Base64 encoded verifying key of the ED25519 keypair.X-Signature
- Base64 encoded signature generated according to the instructions below.To generate a signature perform the following:
The key/values of the request body or query parameters should be ordered alphabetically and then turned into query string format.
Append the header values for the timestamp and receive window to the above generated string in the format ×tamp=<timestamp>&window=<window>
. If no X-Window
header is passed the default value of 5000
still needs to be added to the signing string.
Each request also has an instruction type, valid instructions are:
accountQuery
balanceQuery
borrowLendExecute
borrowHistoryQueryAll
collateralQuery
depositAddressQuery
depositQueryAll
fillHistoryQueryAll
fundingHistoryQueryAll
interestHistoryQueryAll
orderCancel
orderCancelAll
orderExecute
orderHistoryQueryAll
orderQuery
orderQueryAll
pnlHistoryQueryAll
positionQuery
quoteSubmit
withdraw
withdrawalQueryAll
The correct instruction type should be prefixed to the signing string. The instruction types for each request are documented alongside the request.
For example, an API request to cancel an order with the following body:
{
"orderId": 28
"symbol": "BTC_USDT",
}
Would require the following to be signed:
instruction=orderCancel&orderId=28&symbol=BTC_USDT×tamp=1614550000000&window=5000
If the API endpoint requires query parameters instead of a request body, the same procedure should be used on the query parameters. If the API endpoint does not have a request body or query parameters, only the timestamp and receive window need to be signed.
This message should be signed using the private key of the ED25519 keypair that corresponds to the public key in the X-API-Key
header. The signature should then be base64 encoded and submitted in the X-Signature
header.
timestamp
field denoting the system time in unix-epoch microseconds to the depth endpoint.orderId
filter to order history endpoint.from
and to
timestamp to order fills endpoint.t
was added to the private order update stream. It is the trade_id
of the fill that generated the order update.X-Window
header of 60000
.wss://ws.backpack.exchange
. Please see the documentation. The previous API remains on the same endpoint and will be deprecated after a migration period. The new API changes the following:wss://ws.backpack.exchange
instead of wss://ws.backpack.exchange/stream
.params
field.signature
field.accountQuery
to subscribe
.microseconds
instead of milliseconds
.bookTicker
, depth
, and order
streams.depthEvent
to depth
.<symbol>@<type>
to <type>.<symbol>
or kline.<interval>.<symbol>
for K-lines.identifier
field on deposits with transaction_hash
and provider_id
.
This aims to provide clearer representation of the field, particularly for fiat deposits.pending
values from the WithdrawalStatus
and DepositStatus
spec enum.[- {
- "symbol": "BTC",
- "tokens": [
- {
- "blockchain": "Solana",
- "contractAddress": "string",
- "depositEnabled": true,
- "minimumDeposit": "string",
- "withdrawEnabled": true,
- "minimumWithdrawal": "string",
- "maximumWithdrawal": "string",
- "withdrawalFee": "string"
}
]
}
]
[- {
- "symbol": "string",
- "imfFunction": {
- "type": "sqrt",
- "base": "string",
- "factor": "string"
}, - "mmfFunction": {
- "type": "sqrt",
- "base": "string",
- "factor": "string"
}, - "haircutFunction": {
- "weight": "string",
- "kind": {
- "type": "identity"
}
}
}
]
[- {
- "state": "Open",
- "assetMarkPrice": "string",
- "borrowInterestRate": "string",
- "borrowedQuantity": "string",
- "fee": "string",
- "lendInterestRate": "string",
- "lentQuantity": "string",
- "maxUtilization": "string",
- "openBorrowLendLimit": "string",
- "optimalUtilization": "string",
- "symbol": "BTC",
- "timestamp": "2019-08-24T14:15:22Z",
- "throttleUtilizationThreshold": "string",
- "throttleUtilizationBound": "string",
- "throttleUpdateFraction": "string",
- "utilization": "string",
- "stepSize": "string"
}
]
interval required | string (BorrowLendMarketHistoryInterval) Enum: "1d" "1w" "1month" "1year" Filter for an interval. |
symbol | string Market symbol to query. If not set, all markets are returned. |
[- {
- "borrowInterestRate": "string",
- "borrowedQuantity": "string",
- "lendInterestRate": "string",
- "lentQuantity": "string",
- "timestamp": "2019-08-24T14:15:22Z",
- "utilization": "string"
}
]
[- {
- "symbol": "string",
- "baseSymbol": "BTC",
- "quoteSymbol": "BTC",
- "filters": {
- "price": {
- "minPrice": "string",
- "maxPrice": "string",
- "tickSize": "string",
- "maxMultiplier": "string",
- "minMultiplier": "string",
- "maxImpactMultiplier": "string",
- "minImpactMultiplier": "string",
- "meanMarkPriceBand": {
- "maxMultiplier": "string",
- "minMultiplier": "string"
}, - "meanPremiumBand": {
- "tolerancePct": "string"
}
}, - "quantity": {
- "minQuantity": "string",
- "maxQuantity": "string",
- "stepSize": "string"
}, - "leverage": {
- "minLeverage": 0,
- "maxLeverage": 0,
- "stepSize": 0
}
}, - "fundingInterval": 0
}
]
Retrieves a market supported by the exchange.
symbol required | string |
{- "symbol": "string",
- "baseSymbol": "BTC",
- "quoteSymbol": "BTC",
- "filters": {
- "price": {
- "minPrice": "string",
- "maxPrice": "string",
- "tickSize": "string",
- "maxMultiplier": "string",
- "minMultiplier": "string",
- "maxImpactMultiplier": "string",
- "minImpactMultiplier": "string",
- "meanMarkPriceBand": {
- "maxMultiplier": "string",
- "minMultiplier": "string"
}, - "meanPremiumBand": {
- "tolerancePct": "string"
}
}, - "quantity": {
- "minQuantity": "string",
- "maxQuantity": "string",
- "stepSize": "string"
}, - "leverage": {
- "minLeverage": 0,
- "maxLeverage": 0,
- "stepSize": 0
}
}, - "fundingInterval": 0
}
Retrieves summarised statistics for the last 24 hours for the given market symbol.
symbol required | string |
{- "symbol": "string",
- "firstPrice": "string",
- "lastPrice": "string",
- "priceChange": "string",
- "priceChangePercent": "string",
- "high": "string",
- "low": "string",
- "volume": "string",
- "quoteVolume": "string",
- "trades": "string"
}
Retrieves summarised statistics for the last 24 hours for all market symbols.
[- {
- "symbol": "string",
- "firstPrice": "string",
- "lastPrice": "string",
- "priceChange": "string",
- "priceChangePercent": "string",
- "high": "string",
- "low": "string",
- "volume": "string",
- "quoteVolume": "string",
- "trades": "string"
}
]
Retrieves the order book depth for a given market symbol.
symbol required | string |
{- "asks": [
- [
- "21.9",
- "500.123"
], - [
- "22.1",
- "2321.11"
]
], - "bids": [
- [
- "20.12",
- "255.123"
], - [
- "20.5",
- "499.555"
]
], - "lastUpdateId": "1684026955123",
- "timestamp": 1684026955123
}
Get K-Lines for the given market symbol, optionally providing a
startTime
and endTime
. If no startTime
is provided, the interval
duration will be used. If no endTime
is provided, the current time
will be used.
symbol required | string |
interval required | string (KlineInterval) Enum: "1m" "3m" "5m" "15m" "30m" "1h" "2h" "4h" "6h" "8h" "12h" "1d" "3d" "1w" "1month" |
startTime required | integer <int64> UTC timestamp in seconds. |
endTime | integer <int64> UTC timestamp in seconds. Set to the current time if not provided. |
[- {
- "start": "string",
- "end": "string",
- "open": "string",
- "high": "string",
- "low": "string",
- "close": "string",
- "volume": "string",
- "quoteVolume": "string",
- "trades": "string"
}
]
Retrieves mark price, index price and funding rate for the given market symbol.
symbol required | string |
{- "fundingRate": "string",
- "indexPrice": "string",
- "markPrice": "string",
- "nextFundingTimestamp": 0,
- "symbol": "string"
}
Funding interval rate history for futures.
symbol required | string Market symbol to query |
limit | integer <uint64> Maximum number to return. Default |
offset | integer <uint64> Offset for pagination. Default |
[- {
- "symbol": "string",
- "intervalEndTimestamp": "string",
- "fundingRate": "string"
}
]
Retrieve the most recent trades for a symbol. This is public data and is not specific to any account.
The maximum available recent trades is 1000
. If you need more than
1000
trades use the historical trades endpoint.
symbol required | string Market symbol to query fills for. |
limit | integer <uint16> Limit the number of fills returned. Default |
[- {
- "id": 0,
- "price": "string",
- "quantity": "string",
- "quoteQuantity": "string",
- "timestamp": 0,
- "isBuyerMaker": true
}
]
Retrieves all historical trades for the given symbol. This is public trade data and is not specific to any account.
symbol required | string |
limit | integer <int64> Limit the number of trades returned. Default |
offset | integer <int64> Offset. Default |
[- {
- "id": 0,
- "price": "string",
- "quantity": "string",
- "quoteQuantity": "string",
- "timestamp": 0,
- "isBuyerMaker": true
}
]
Instruction: accountQuery
X-API-KEY required | string API key |
X-SIGNATURE required | string Signature of the request |
X-TIMESTAMP required | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
{- "autoLend": true,
- "autoRepayBorrows": true,
- "borrowLimit": "string",
- "autoRealizePnl": true,
- "futuresMakerFee": "string",
- "futuresTakerFee": "string",
- "leverageLimit": "string",
- "limitOrders": 0,
- "liquidating": true,
- "positionLimit": "string",
- "autoBorrowSettlements": true,
- "spotMakerFee": "string",
- "spotTakerFee": "string",
- "triggerOrders": 0
}
Update account settings.
Instruction: accountUpdate
X-API-KEY required | string API key |
X-SIGNATURE required | string Signature of the request |
X-TIMESTAMP required | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
autoLend | boolean Determines if the account should automatically lend. |
autoRepayBorrows | boolean Determines if the account should automatically repay borrows with available balance. |
autoRealizePnl | boolean Determines if the account should have continuous PnL realization. |
leverageLimit | string <decimal> Determines the maximum leverage allowed for the main account or subaccount. |
autoBorrowSettlements | boolean If true, then tries to borrow during collateral reconciliation. Collateral reconciliation is a process in which the system reconciles the negative account debt or positive account equity. |
{- "autoLend": true,
- "autoRepayBorrows": true,
- "autoRealizePnl": true,
- "leverageLimit": "string",
- "autoBorrowSettlements": true
}
{- "code": "FORBIDDEN",
- "message": "string"
}
Retrieves all the open borrow lending positions for the account.
Instruction: borrowLendPositionQuery
X-API-KEY | string API key |
X-SIGNATURE | string Signature of the request |
X-TIMESTAMP | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
[- {
- "id": "string",
- "imf": "string",
- "imfFunction": {
- "type": "sqrt",
- "base": "string",
- "factor": "string"
}, - "netQuantity": "string",
- "markPrice": "string",
- "mmf": "string",
- "mmfFunction": {
- "type": "sqrt",
- "base": "string",
- "factor": "string"
}, - "netExposureQuantity": "string",
- "netExposureNotional": "string",
- "symbol": "BTC"
}
]
Instruction: borrowLendExecute
X-API-KEY required | string API key |
X-SIGNATURE required | string Signature of the request |
X-TIMESTAMP required | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
quantity required | string <decimal> The quantity of the asset to repay. |
side required | string Enum: "Borrow" "Lend" Side of the borrow lend. |
symbol required | string Enum: "BTC" "ETH" "SOL" "USDC" "USDT" "PYTH" "JTO" "BONK" "HNT" "MOBILE" "WIF" "JUP" "RENDER" "WEN" "W" "TNSR" "PRCL" "SHARK" "KMNO" "MEW" "BOME" "RAY" "HONEY" "SHFL" "BODEN" "IO" "DRIFT" "PEPE" "SHIB" "LINK" "UNI" "ONDO" "FTM" "MATIC" "STRK" "BLUR" "WLD" "GALA" "NYAN" "HLG" "MON" "ZKJ" "MANEKI" "HABIBI" "UNA" "ZRO" "ZEX" "AAVE" "LDO" "MOTHER" "CLOUD" "MAX" "POL" "TRUMPWIN" "HARRISWIN" "MOODENG" "DBR" "GOAT" "ACT" "DOGE" "BCH" "LTC" The asset to repay. |
{- "quantity": "string",
- "side": "Borrow",
- "symbol": "BTC"
}
{- "code": "FORBIDDEN",
- "message": "string"
}
Retrieves account balances and the state of the balances (locked or available).
Locked assets are those that are currently in an open order.
Instruction: balanceQuery
X-API-KEY | string API key |
X-SIGNATURE | string Signature of the request |
X-TIMESTAMP | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
{- "property1": {
- "available": "string",
- "locked": "string",
- "staked": "string"
}, - "property2": {
- "available": "string",
- "locked": "string",
- "staked": "string"
}
}
Retrieves collateral information for an account.
Instruction: collateralQuery
subaccountId | integer <uint16> |
X-API-KEY | string API key |
X-SIGNATURE | string Signature of the request |
X-TIMESTAMP | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
{- "assetsValue": "string",
- "borrowLiability": "string",
- "collateral": [
- {
- "symbol": "string",
- "assetMarkPrice": "string",
- "totalQuantity": "string",
- "balanceNotional": "string",
- "collateralWeight": "string",
- "collateralValue": "string",
- "openOrderQuantity": "string",
- "lendQuantity": "string",
- "availableQuantity": "string"
}
], - "imf": "string",
- "unsettledEquity": "string",
- "liabilitiesValue": "string",
- "marginFraction": "string",
- "mmf": "string",
- "netEquity": "string",
- "netEquityAvailable": "string",
- "netEquityLocked": "string",
- "netExposureFutures": "string",
- "pnlUnrealized": "string",
- "subaccountId": 0,
- "userId": 0
}
Retrieves deposit history.
Instruction: depositQueryAll
from | integer <int64> Filter to minimum time (milliseconds). |
to | integer <int64> Filter to maximum time (milliseconds). |
limit | integer <int64> Maximum number to return. Default |
offset | integer <int64> Offset. Default |
X-API-KEY | string API key |
X-SIGNATURE | string Signature of the request |
X-TIMESTAMP | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
[- {
- "id": 0,
- "toAddress": "string",
- "fromAddress": "string",
- "confirmationBlockNumber": 0,
- "source": "administrator",
- "status": "cancelled",
- "transactionHash": "string",
- "symbol": "BTC",
- "quantity": "string",
- "createdAt": "string"
}
]
Retrieves the user specific deposit address if the user were to deposit on the specified blockchain.
Instruction: depositAddressQuery
blockchain required | string (Blockchain) Enum: "Solana" "Ethereum" "Polygon" "Bitcoin" "Dogecoin" "BitcoinCash" "Litecoin" Blockchain symbol to get a deposit address for. |
X-API-KEY | string API key |
X-SIGNATURE | string Signature of the request |
X-TIMESTAMP | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
{- "address": "string"
}
Retrieves withdrawal history.
Instruction: withdrawalQueryAll
from | integer <int64> Filter to minimum time (milliseconds). |
to | integer <int64> Filter to maximum time (milliseconds). |
limit | integer <int64> Maximum number to return. Default |
offset | integer <int64> Offset. Default |
X-API-KEY | string API key |
X-SIGNATURE | string Signature of the request |
X-TIMESTAMP | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
[- {
- "id": 0,
- "blockchain": "Solana",
- "clientId": "string",
- "identifier": "string",
- "quantity": "string",
- "fee": "string",
- "symbol": "BTC",
- "status": "confirmed",
- "subaccountId": 0,
- "toAddress": "string",
- "transactionHash": "string",
- "createdAt": "string",
- "isInternal": true
}
]
Requests a withdrawal from the exchange.
The twoFactorToken
field is required if the withdrawal address is not
an address that is configured in the address book to not require
2FA. These addresses can be configured here.
Instruction: withdraw
X-API-KEY required | string API key |
X-TIMESTAMP required | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
X-SIGNATURE required | string Signature of the request |
address required | string Address to withdraw to. |
blockchain required | string Enum: "Solana" "Ethereum" "Polygon" "Bitcoin" "Dogecoin" "BitcoinCash" "Litecoin" Blockchain to withdraw on. |
clientId | string Custom client id. |
quantity required | string <decimal> Quantity to withdraw. |
symbol required | string Enum: "BTC" "ETH" "SOL" "USDC" "USDT" "PYTH" "JTO" "BONK" "HNT" "MOBILE" "WIF" "JUP" "RENDER" "WEN" "W" "TNSR" "PRCL" "SHARK" "KMNO" "MEW" "BOME" "RAY" "HONEY" "SHFL" "BODEN" "IO" "DRIFT" "PEPE" "SHIB" "LINK" "UNI" "ONDO" "FTM" "MATIC" "STRK" "BLUR" "WLD" "GALA" "NYAN" "HLG" "MON" "ZKJ" "MANEKI" "HABIBI" "UNA" "ZRO" "ZEX" "AAVE" "LDO" "MOTHER" "CLOUD" "MAX" "POL" "TRUMPWIN" "HARRISWIN" "MOODENG" "DBR" "GOAT" "ACT" "DOGE" "BCH" "LTC" Symbol of the asset to withdraw. |
twoFactorToken | string Issued two factor token. |
autoBorrow | boolean Auto borrow to withdraw if required. |
{- "address": "string",
- "blockchain": "Solana",
- "clientId": "string",
- "quantity": "string",
- "symbol": "BTC",
- "twoFactorToken": "string",
- "autoBorrow": true
}
{- "id": 0,
- "blockchain": "Solana",
- "clientId": "string",
- "identifier": "string",
- "quantity": "string",
- "fee": "string",
- "symbol": "BTC",
- "status": "confirmed",
- "subaccountId": 0,
- "toAddress": "string",
- "transactionHash": "string",
- "createdAt": "string",
- "isInternal": true
}
Retrieves account position summary.
Instruction: positionQuery
X-API-KEY | string API key |
X-SIGNATURE | string Signature of the request |
X-TIMESTAMP | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
[- {
- "breakEvenPrice": "string",
- "entryPrice": "string",
- "estLiquidationPrice": "string",
- "imf": "string",
- "imfFunction": {
- "type": "sqrt",
- "base": "string",
- "factor": "string"
}, - "markPrice": "string",
- "mmf": "string",
- "mmfFunction": {
- "type": "sqrt",
- "base": "string",
- "factor": "string"
}, - "netCost": "string",
- "netQuantity": "string",
- "netExposureQuantity": "string",
- "netExposureNotional": "string",
- "pnlRealized": "string",
- "pnlUnrealized": "string",
- "subaccountId": 0,
- "symbol": "string",
- "userId": 0
}
]
History of borrow and lend operations for the account.
Instruction: borrowHistoryQueryAll
type | string (BorrowLendEventType) Enum: "Borrow" "BorrowBackstopLiquidation" "BorrowRepay" "Lend" "LendBackstopLiquidation" "LendRedeem" Filter to history for either borrows or lends. |
source | string (BorrowLendSource) Enum: "AutoBorrowRepay" "AutoLend" "Interest" "Liquidation" "LiquidationAdl" "LiquidationBackstop" "Manual" "Reconciliation" "SpotMargin" Filter to return history for a particular source. |
positionId | string Filter to return history for a borrow lend position. |
symbol | string Filter to the given symbol. |
limit | integer <uint64> Maximum number to return. Default |
offset | integer <uint64> Offset for pagination. Default |
liquidations_only | boolean Filter to liquidation events only. |
X-API-KEY | string API key |
X-SIGNATURE | string Signature of the request |
X-TIMESTAMP | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
[- {
- "eventType": "Borrow",
- "positionId": "string",
- "quantity": "string",
- "source": "AutoBorrowRepay",
- "symbol": "string",
- "timestamp": "string",
- "spotMarginOrderId": "string"
}
]
History of the interest payments for borrows and lends for the account.
Instruction: interestHistoryQueryAll
symbol | string Market symbol to query. If not set, all markets are returned. |
positionId | string Filter to return history for a borrow lend position. |
limit | integer <uint64> Maximum number to return. Default |
offset | integer <uint64> Offset for pagination. Default |
source | string (InterestPaymentSource) Enum: "UnrealizedPnl" "BorrowLend" Filter to return interest payments of a particular source. Borrow interest payments through two mechanisms: borrow lend positions; interest paid on unrealized pnl. |
X-API-KEY | string API key |
X-SIGNATURE | string Signature of the request |
X-TIMESTAMP | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
[- {
- "paymentType": "EntryFee",
- "interestRate": "string",
- "interval": 0,
- "marketSymbol": "string",
- "positionId": "string",
- "quantity": "string",
- "symbol": "BTC",
- "timestamp": "string"
}
]
Retrieves historical fills, with optional filtering for a specific order or symbol.
Instruction: fillHistoryQueryAll
orderId | string Filter to the given order. |
from | integer <int64> Filter to minimum time (milliseconds). |
to | integer <int64> Filter to maximum time (milliseconds). |
symbol | string Filter to the given symbol. |
limit | integer <int64> Maximum number to return. Default |
offset | integer <int64> Offset. Default |
fillType | string (FillType) Enum: "User" "Liquidation" "CollateralConversion" "Adl" "AllLiquidation" Filter to return fills for different fill types |
X-API-KEY | string API key |
X-SIGNATURE | string Signature of the request |
X-TIMESTAMP | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
[- {
- "fee": "string",
- "feeSymbol": "string",
- "isMaker": true,
- "orderId": "string",
- "price": "string",
- "quantity": "string",
- "side": "Bid",
- "symbol": "string",
- "systemOrderType": "LiquidatePositionOnBook",
- "timestamp": "string",
- "tradeId": 0
}
]
Users funding payment history for futures.
Instruction: fundingHistoryQueryAll
subaccountId | integer <uint16> Filter for a subaccount. |
symbol | string Market symbol to query. If not set, all markets are returned. |
limit | integer <uint64> Maximum number to return. Default |
offset | integer <uint64> Offset for pagination. Default |
X-API-KEY | string API key |
X-SIGNATURE | string Signature of the request |
X-TIMESTAMP | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
[- {
- "userId": 0,
- "subaccountId": 0,
- "symbol": "string",
- "quantity": "string",
- "intervalEndTimestamp": "string",
- "fundingRate": "string"
}
]
Retrieves the order history for the user. This includes orders that have
been filled and are no longer on the book. It may include orders
that are on the book, but the /orders
endpoint contains more up to
date data.
Instruction: orderHistoryQueryAll
orderId | string Filter to the given order. |
symbol | string Filter to the given symbol. |
limit | integer <int64> Maximum number to return. Default |
offset | integer <int64> Offset. Default |
X-API-KEY | string API key |
X-SIGNATURE | string Signature of the request |
X-TIMESTAMP | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
[- {
- "id": "string",
- "orderType": "Market",
- "symbol": "string",
- "side": "Bid",
- "price": "string",
- "triggerPrice": "string",
- "quantity": "string",
- "quoteQuantity": "string",
- "executedQuantity": "string",
- "executedQuoteQuantity": "string",
- "timeInForce": "GTC",
- "selfTradePrevention": "RejectTaker",
- "postOnly": true,
- "status": "Cancelled"
}
]
History of profit and loss realization for an account.
Instruction: pnlHistoryQueryAll
subaccountId | integer <uint16> Filter for a subaccount. |
symbol | string Market symbol to query. If not set, all markets are returned. |
limit | integer <uint64> Maximum number to return. Default |
offset | integer <uint64> Offset for pagination. Default |
X-API-KEY | string API key |
X-SIGNATURE | string Signature of the request |
X-TIMESTAMP | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
[- {
- "pnlRealized": "string",
- "symbol": "string",
- "timestamp": "string"
}
]
History of settlement operations for the account.
Instruction: settlementHistoryQueryAll
limit | integer <uint64> Maximum number to return. Default |
offset | integer <uint64> Offset for pagination. Default |
source | string (SettlementSource) Enum: "TradingFees" "TradingFeesSystem" "FundingPayment" "CulledBorrowInterest" "CulledRealizePnl" "RealizePnl" "BackstopLiquidation" |
X-API-KEY | string API key |
X-SIGNATURE | string Signature of the request |
X-TIMESTAMP | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
[- {
- "quantity": "string",
- "source": "TradingFees",
- "timestamp": "string"
}
]
Retrieves an open order from the order book. This only returns the order if it is resting on the order book (i.e. has not been completely filled, expired, or cancelled).
One of orderId
or clientId
must be specified. If both are specified
then the request will be rejected.
Instruction: orderQuery
clientId | integer <uint32> Client ID of the order. |
orderId | string ID of the order. |
symbol required | string Market symbol for the order. |
X-API-KEY | string API key |
X-SIGNATURE | string Signature of the request |
X-TIMESTAMP | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
{- "orderType": "Market",
- "id": "string",
- "clientId": 0,
- "symbol": "string",
- "side": "Bid",
- "quantity": "string",
- "executedQuantity": "string",
- "quoteQuantity": "string",
- "executedQuoteQuantity": "string",
- "triggerPrice": "string",
- "timeInForce": "GTC",
- "selfTradePrevention": "RejectTaker",
- "status": "Cancelled",
- "createdAt": 0
}
Submits an order to the matching engine for execution.
Instruction: orderExecute
X-API-KEY required | string API key |
X-SIGNATURE required | string Signature of the request |
X-TIMESTAMP required | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
clientId | integer <uint32> Custom order id. |
orderType required | string Enum: "Market" "Limit" Order type, market or limit. |
postOnly | boolean Whether the order is post only or not |
price | string <decimal> The order price if this is a limit order |
quantity | string <decimal> The order quantity. Market orders must specify either a |
quoteQuantity | string <decimal> The maximum amount of the quote asset to spend (Ask) or receive (Bid)
for market orders. This is used for reverse market orders. The
order book will execute a |
selfTradePrevention | string Enum: "RejectTaker" "RejectMaker" "RejectBoth" "Allow" Action to take in the event the user crosses themselves in the order book. |
side required | string Enum: "Bid" "Ask" The order side. It will be matched against the resting orders on the other side of the order book. |
symbol required | string The market for the order. |
timeInForce | string Enum: "GTC" "IOC" "FOK" How long the order is good for. |
triggerPrice | string <decimal> Trigger price if this is a conditional order. |
reduceOnly | boolean Default: null If true then the order can only reduce the positon. Futures only. |
autoBorrow | boolean Default: null If true then the order can borrow. Spot margin only. |
{- "clientId": 0,
- "orderType": "Market",
- "postOnly": true,
- "price": "string",
- "quantity": "string",
- "quoteQuantity": "string",
- "selfTradePrevention": "RejectTaker",
- "side": "Bid",
- "symbol": "string",
- "timeInForce": "GTC",
- "triggerPrice": "string",
- "reduceOnly": null,
- "autoBorrow": null
}
{- "orderType": "Market",
- "id": "string",
- "clientId": 0,
- "symbol": "string",
- "side": "Bid",
- "quantity": "string",
- "executedQuantity": "string",
- "quoteQuantity": "string",
- "executedQuoteQuantity": "string",
- "triggerPrice": "string",
- "timeInForce": "GTC",
- "selfTradePrevention": "RejectTaker",
- "status": "Cancelled",
- "createdAt": 0
}
Cancels an open order from the order book.
One of orderId
or clientId
must be specified. If both are specified
then the request will be rejected.
Instruction: orderCancel
X-API-KEY required | string API key |
X-SIGNATURE required | string Signature of the request |
X-TIMESTAMP required | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
clientId | integer <uint32> Client ID of the order. |
orderId | string ID of the order. |
symbol required | string Market the order exists on. |
{- "clientId": 0,
- "orderId": "string",
- "symbol": "string"
}
{- "orderType": "Market",
- "id": "string",
- "clientId": 0,
- "symbol": "string",
- "side": "Bid",
- "quantity": "string",
- "executedQuantity": "string",
- "quoteQuantity": "string",
- "executedQuoteQuantity": "string",
- "triggerPrice": "string",
- "timeInForce": "GTC",
- "selfTradePrevention": "RejectTaker",
- "status": "Cancelled",
- "createdAt": 0
}
Retrieves all open orders. If a symbol is provided, only open orders for that market will be returned, otherwise all open orders are returned.
Instruction: orderQueryAll
symbol | string The symbol of the market for the orders. |
X-API-KEY | string API key |
X-SIGNATURE | string Signature of the request |
X-TIMESTAMP | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
[- {
- "orderType": "Market",
- "id": "string",
- "clientId": 0,
- "symbol": "string",
- "side": "Bid",
- "quantity": "string",
- "executedQuantity": "string",
- "quoteQuantity": "string",
- "executedQuoteQuantity": "string",
- "triggerPrice": "string",
- "timeInForce": "GTC",
- "selfTradePrevention": "RejectTaker",
- "status": "Cancelled",
- "createdAt": 0
}
]
Cancels all open orders on the specified market.
Instruction: orderCancelAll
X-API-KEY required | string API key |
X-SIGNATURE required | string Signature of the request |
X-TIMESTAMP required | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
symbol required | string Market to cancel orders for. |
{- "symbol": "string"
}
[- {
- "orderType": "Market",
- "id": "string",
- "clientId": 0,
- "symbol": "string",
- "side": "Bid",
- "quantity": "string",
- "executedQuantity": "string",
- "quoteQuantity": "string",
- "executedQuoteQuantity": "string",
- "triggerPrice": "string",
- "timeInForce": "GTC",
- "selfTradePrevention": "RejectTaker",
- "status": "Cancelled",
- "createdAt": 0
}
]
This endpoint allows a maker to submit a quote in response to an RFQ. The submitted quote will be evaluated and, if valid, may be accepted by the taker within the specified time window.
Instruction: quoteSubmit
X-API-KEY required | string API key |
X-SIGNATURE required | string Signature of the request |
X-TIMESTAMP required | integer <int64> Timestamp of the request in milliseconds |
X-WINDOW | integer <uint64> Time the request is valid for in milliseconds (default |
rfqId required | string RFQ ID. |
clientId | integer <uint32> Custom RFQ quote ID. |
bidPrice required | string <decimal> Bid price. |
askPrice required | string <decimal> Ask price. |
{- "rfqId": "string",
- "clientId": 0,
- "bidPrice": "string",
- "askPrice": "string"
}
{- "rfqId": "string",
- "quoteId": "string",
- "clientId": 0,
- "price": "string",
- "status": "Cancelled"
}
To use the websocket API, connect to
wss://ws.backpack.exchange
.
To subscribe to a stream with the name stream
send a text frame
over the websocket connection with the following JSON payload:
{
"method": "SUBSCRIBE",
"params": ["stream"]
}
Similarly, to unsubscribe from a stream with the name stream
:
{
"method": "UNSUBSCRIBE",
"params": ["stream"]
}
You can subscribe or unsubscribe from multiple streams if you include more than one in the params field.
All data from streams is wrapped in a JSON object of the following form:
{
"stream": "<stream>",
"data": "<payload>"
}
The following command can be used to test subscribing to a stream:
(sleep 1; \
echo '{"method":"SUBSCRIBE","params":["depth.SOL_USDC"]}';\
cat) |\
wscat -c wss://ws.backpack.exchange
The payloads for each stream time are outlined below.
Timestamps are in microseconds (except for the K-line start and end times). The event timestamp is the time the event was emitted from the websocket server, and the engine timestamp is the time the event was generated by the matching engine.
If a message aggregates more than one event (for example, a depth message), the engine timestamp will be the timestamp of the last matching engine event.
To keep the connection alive, a Ping
frame will be sent from the
server every 60s, and a Pong
is expected to be received from the
client. If a Pong
is not received within 120s, a Close
frame will be
sent and the connection will be closed.
If the server is shutting down, a Close
frame will be sent and then a
grace period of 30s will be given before the connection is closed. The
client should reconnect after receiving the Close
frame. The client
will be reconnected to a server that is not shutting down.
Subscribing to a private stream requires a valid signature generated from an ED25519 keypair. For stream subscriptions, the signature should be of the form:
instruction=subscribe×tamp=1614550000000&window=5000
Where the timestamp and window are in milliseconds.
Private streams are prefixed with account.
and require signature data
to be submitted in the subscribe parameters. The verifying key and
signature should be base64 encoded.
{
"method": "SUBSCRIBE",
"params": ["stream"],
"signature": ["<verifying key>", "<signature>", "<timestamp>", "<window>"]
}
On any mutation to an order the order will be pushed to the order update stream. The event type of the order update will be one of the following:
orderAccepted
orderCancelled
orderExpired
orderFill
account.orderUpdate
account.orderUpdate.<symbol>
{
"e": "orderAccepted", // Event type
"E": 1694687692980000, // Event time in microseconds
"s": "SOL_USD", // Symbol
"c": 123, // Client order ID
"S": "Bid", // Side
"o": "LIMIT", // Order type
"f": "GTC", // Time in force
"q": "32123", // Quantity
"Q": "32123", // Quantity in quote
"p": "20", // Price
"P": "21", // Trigger price
"X": "Filled", // Order state
"i": "1111343026172067" // Order ID
"t": 567, // Trade ID
"l": "1.23", // Fill quantity
"z": "321", // Executed quantity
"Z": "123", // Executed quantity in quote
"L": "20", // Fill price
"m": true, // Whether the order was maker
"n": "23", // Fee
"N": "USD", // Fee symbol
"V": "RejectTaker", // Self trade prevention
"T": 1694687692989999 // Engine timestamp in microseconds
}
Some fields are conditional on the order settings or event type:
c
- Only present if the order has a client order ID.q
- Only present if the order has a quantity set.Q
- Only present if the order is reverse market order.p
- Only present if the order is a limit order.P
- Only present if the order is a trigger order.t
- Only present if the event is a orderFill
event.l
- Only present if the event is a orderFill
event.L
- Only present if the event is a orderFill
event.m
- Only present if the event is a orderFill
event.n
- Only present if the event is a orderFill
event.N
- Only present if the event is a orderFill
event.On any mutation to a position the position will be pushed to the position update stream. The event type of the position update will be one of the following:
positionAdjusted
positionOpened
positionClosed
On subscription, a message will be sent to the client with the current
open positions, if any. The e
field will not be present in the
message.
account.positionUpdate
account.positionUpdate.<symbol>
{
"e": "positionOpened", // Event type
"E": 1694687692980000, // Event time in microseconds
"s": "SOL_USD_PERP", // Symbol
"b": 123, // Break event price
"B": 122, // Entry price
"l": 50, // Estimated liquidation price
"f": 0.5, // Initial margin fraction
"M": 122, // Mark price
"m": 0.01, // Maintenance margin fraction
"q": 5, // Net quantity
"Q": 6, // Net exposure quantity
"n": 732 , // Net exposure notional
"i": "1111343026172067" // Position ID
"p": -1, // PnL realized
"P": 0, // PnL unrealized
"T": 1694687692989999 // Engine timestamp in microseconds
}
The net quantity field will be positive if the position is long and negative if the position is short.
The net exposure quantity field includes exposure from the open position, as well as any open orders.
This WebSocket stream provides real-time updates on RFQs (Request for Quotes) that are relevant to makers. Events are pushed to this stream whenever there is a significant state change in an RFQ or its associated quotes, allowing makers to monitor and respond to RFQs as they progress through various states.
rfqActive
: Indicates that an RFQ is active and open for quotes.quoteAccepted
: Indicates that a quote submitted by the maker has
been accepted.quoteCancelled
: Indicates that a quote has been cancelled due to
quote submission, RFQ being filled, refreshed, cancelled, or expired.rfqFilled
: Indicates that an RFQ has been fully filled with a quote
from the maker.Makers should submit quotes before the submission time (w
field)
is reached, as indicated in each rfqActive
event. An RFQ remains
active until the expiration time (W
field). If no quote is
accepted or the RFQ is not cancelled, makers may continue to submit
quotes until expiration.
RFQs can periodically request new quotes by issuing additional
rfqActive
events. Each new rfqActive
event will have the same
RFQ ID (R
field) but updated values for submission time and
expiration time, allowing makers to participate in extended or
renewed quoting periods for ongoing RFQs.
account.rfqUpdate
account.rfqUpdate.<symbol>
RFQ Active
{
"e": "rfqActive", // Event type
"E": 1730225420369829, // Event time in microseconds
"R": 113392053149171712, // RFQ ID
"s": "SOL_USDC", // Symbol
"q": "10", // Quantity
"w": 1730225480368500, // Submission time in milliseconds
"W": 1730225540368500, // Expiry time in milliseconds
"X": "New", // RFQ status
"T": 1730225420368765 // Engine timestamp in microseconds
}
Quote Accepted
{
"e": "quoteAccepted", // Event type
"E": 1730225434631394, // Event time in microseconds
"R": 113392053149171712, // RFQ ID
"Q": 113392054083780608, // Quote ID
"C": "quote123", // Client Quote ID (optional)
"X": "New", // Quote status
"T": 1730225434629778 // Engine timestamp in microseconds
}
Quote Cancelled
{
"e": "quoteCancelled", // Event type
"E": 1730225583761963, // Event time in microseconds
"R": 113392061354344448, // RFQ ID
"Q": 113392062870847488, // Quote ID
"C": "quote123", // Client Quote ID (optional)
"X": "Cancelled", // Quote status
"T": 1730225583753811 // Engine timestamp in microseconds
}
RFQ Filled
{
"e": "rfqFilled", // Event type
"E": 1730225497648996, // Event time in microseconds
"R": 113392053149171712, // RFQ ID
"Q": 113392054083780608, // Quote ID
"C": "quote123", // Client Quote ID (optional)
"S": "Bid", // RFQ side (Bid or Ask)
"p": "21", // Fill price
"X": "Filled", // Quote status
"T": 1730225497647080 // Engine timestamp in microseconds
}
e
- Event type (e.g., rfqActive
, quoteAccepted
,
quoteCancelled
, rfqFilled
).E
- Event time in microseconds.R
- RFQ ID, identifying the request for quote.Q
- Quote ID, identifying the specific quote.C
- Client Quote ID.s
- Symbol associated with the RFQ.q
- Quantity for the RFQ.S
- Side of the RFQ, either "Bid" or "Ask".p
- Price associated with the fill event.w
- Submission time for the RFQ in milliseconds.W
- Expiry time for the RFQ in milliseconds.X
- Order status (e.g., New
, Cancelled
, Filled
).T
- Engine timestamp in microseconds.Some fields are conditional and may be present only in specific events.
Stream name format: bookTicker.<symbol>
{
"e": "bookTicker", // Event type
"E": 1694687965941000, // Event time in microseconds
"s": "SOL_USDC", // Symbol
"a": "18.70", // Inside ask price
"A": "1.000", // Inside ask quantity
"b": "18.67", // Inside bid price
"B": "2.000", // Inside bid quantity
"u": "111063070525358080", // Update ID of event
"T": 1694687965940999 // Engine timestamp in microseconds
}
Contains incremental depth updates. Each depth update has the absolute value of the depths at the given levels, and only changes when the depth has changed.
To obtain an initial snapshot of the depth, the client should query the REST API.
The depth stream will push updates as quickly as possible, but under
load it may aggregate more than one update into a single event. In
this case the U
and u
fields will not be the same. The U
field
is the first update ID in the event, and the u
field is the final
update ID in the event.
There is an alternative depth stream that aggregates updates into a single message over a 200ms period instead of pushing updates in realtime. This is useful for reducing network traffic.
Updates are sequential, so U
will always be u + 1
from the previous
message. If this is not the case, the client should assume that the
depth has been invalidated and requery the REST API.
Stream name format: depth.<symbol>
(realtime)
Stream name format: depth.200ms.<symbol>
(aggregated)
{
"e": "depth", // Event type
"E": 1694687965941000, // Event time in microseconds
"s": "SOL_USDC", // Symbol
"a": [ // Asks
[
"18.70",
"0.000"
]
],
"b": [ // Bids
[
"18.67",
"0.832"
],
[
"18.68",
"0.000"
]
],
"U": 94978271, // First update ID in event
"u": 94978271, // Last update ID in event
"T": 1694687965940999 // Engine timestamp in microseconds
}
Stream name format: kline.<interval>.<symbol>
{
"e": "kline", // Event type
"E": 1694687692980000, // Event time in microseconds
"s": "SOL_USD", // Symbol
"t": 123400000, // K-Line start time in seconds
"T": 123460000, // K-Line close time in seconds
"o": "18.75", // Open price
"c": "19.25", // Close price
"h": "19.80", // High price
"l": "18.50", // Low price
"v": "32123", // Base asset volume
"n": 93828, // Number of trades
"X": false // Is this k-line closed?
}
Stream name format: liquidation
{
"e": "liquidation", // Event type
"E": 1694688638091000, // Event time in microseconds
"q": "10", // Quantity
"p": "18.70", // Price
"s": "SOL_USDC", // Symbol
"T": 567, // Engine timestamp in microseconds
}
Stream name format: markPrice.<symbol>
{
"e": "markPrice", // Event type
"E": 1694687965941000, // Event time in microseconds
"s": "SOL_USDC", // Symbol
"p": "18.70", // Mark price
"f": "1.70", // Estimated funding rate
"i": "19.70", // Index price
"n": 1694687965941000, // Next funding timestamp in microseconds
}
The ticker stream pushes 24hr rolling statistics for a single symbol.
Stream name format: ticker.<symbol>
{
"e": "ticker", // Event type
"E": 1694687692980000, // Event time in microseconds
"s": "SOL_USD", // Symbol
"o": "18.75", // First price
"c": "19.24", // Last price
"h": "19.80", // High price
"l": "18.50", // Low price
"v": "32123", // Base asset volume
"V": "928190", // Quote asset volume
"n": 93828 // Number of trades
}
Contains public trade data for a single symbol. The trade ID is a sequential number specific to the symbol.
Stream name format: trade.<symbol>
{
"e": "trade", // Event type
"E": 1694688638091000, // Event time in microseconds
"s": "SOL_USDC", // Symbol
"p": "18.68", // Price
"q": "0.122", // Quantity
"b": "111063114377265150", // Buyer order ID
"a": "111063114585735170", // Seller order ID
"t": 12345, // Trade ID
"T": 1694688638089000, // Engine timestamp in microseconds
"m": true // Is the buyer the maker?
}