Requests that return potentially large collections should respond to the ?page and ?perPage parameters. For example:
curl https://api.0x.org/sra/orders?page=3&perPage=20
Page numbering should be 1-indexed, not 0-indexed. If a query provides an unreasonable (ie. too high) perPage value, the response can return a validation error as specified in the errors section. If the query specifies a page that does not exist (ie. there are not enough records), the response should just return an empty records array.
All endpoints that are paginated should return a total, page, perPage and a records value in the top level of the collection. The value of total should be the total number of records for a given query, whereas records should be an array representing the response to the query for that page. page and perPage, are the same values that were specified in the request.
These requests include the asset_pairs
, orders
, and orderbook
endpoints.
The Standard Relayer API V3 does not specify how to deal with different chain ids (formerly called network ids). The recommendation is to provide a different SRA URL for every chain id that you support. For example, if your mainnet SRA endpoint is hosted at https://api.0x.org/sra
then the Kovan endpoint could be hosted at https://kovan.api.0x.org/sra
.
A Link Header can be included in a response to provide clients with more context about paging For example:
Link: <https://api.0x.org/sra/token_pairs?page=3&perPage=20>; rel="next",
<https://api.github.com/user/repos?page=10&perPage=20>; rel="last"
This Link
response header contains one or more Hypermedia link relations.
The possible rel
values are:
Name | Description |
---|---|
next | The link relation for the immediate next page of results. |
last | The link relation for the last page of results. |
first | The link relation for the first page of results. |
prev | The link relation for the immediate previous page of results. |
Rate limit guidance for clients can be optionally returned in the response headers:
Header Name | Description |
---|---|
X-RateLimit-Limit | The maximum number of requests you're permitted to make per hour. |
X-RateLimit-Remaining | The number of requests remaining in the current rate limit window. |
X-RateLimit-Reset | The time at which the current rate limit window resets in UTC epoch seconds. |
For example:
curl -i https://api.0x.org/sra/token_pairs
HTTP/1.1 200 OK
Date: Mon, 20 Oct 2017 12:30:06 GMT
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 56
X-RateLimit-Reset: 1372700873
When a rate limit is exceeded, a status of 429 Too Many Requests should be returned.
Unless the spec defines otherwise, errors to bad requests should respond with HTTP 4xx or status codes.
Code | Reason |
---|---|
400 | Bad Request – Invalid request format |
404 | Not found |
429 | Too many requests - Rate limit exceeded |
500 | Internal Server Error |
501 | Not Implemented |
For all 400 responses, see the error response schema.
{
"code": 101,
"reason": "Validation failed",
"validationErrors": [
{
"field": "maker",
"code": 1002,
"reason": "Invalid address"
}
]
}
General error codes:
100 - Validation Failed
101 - Malformed JSON
102 - Order submission disabled
103 - Throttled
Validation error codes:
1000 - Required field
1001 - Incorrect format
1002 - Invalid address
1003 - Address not supported
1004 - Value out of range
1005 - Invalid signature or hash
1006 - Unsupported option
- All requests and responses should be of application/json content type
- All token amounts are sent in amounts of the smallest level of precision (base units). (e.g if a token has 18 decimal places, selling 1 token would show up as selling
'1000000000000000000'
units by this API). - All addresses are sent as lower-case (non-checksummed) Ethereum addresses with the
0x
prefix. - All parameters should use
lowerCamelCase
.
Retrieves a list of available asset pairs and the information required to trade them. This endpoint should be paginated.
- assetDataA=&assetDataB [string]: these are assetData fields. Returns asset pairs that contain assetDataA and assetDataB (in any order). Setting only assetDataA or assetDataB returns pairs filtered by that asset only (optional)
{
"total": 43,
"page": 1,
"perPage": 100,
"records": [
{
"assetDataA": {
"minAmount": "0",
"maxAmount": "10000000000000000000",
"precision": 5,
"assetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498"
},
"assetDataB": {
"minAmount": "0",
"maxAmount": "50000000000000000000",
"precision": 5,
"assetData": "0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063"
}
},
...
]
}
minAmount
- the minimum trade amount the relayer will acceptmaxAmount
- the maximum trade amount the relayer will acceptprecision
- the desired price precision a relayer would like to support within their orderbookassetData
- the assetData representing that token
Retrieves a list of orders given query parameters. This endpoint should be paginated. For querying an entire orderbook snapshot, the orderbook endpoint is recommended.
Filter parameters:
- makerAssetProxyId [string]: returns orders where the maker asset is of certain asset proxy id (example:
0xf47261b0
forERC20
,0x02571792
forERC721
) - takerAssetProxyId [string]: returns orders where the taker asset is of certain asset proxy id(example:
0xf47261b0
forERC20
,0x02571792
forERC721
) - makerAssetAddress [string] returns orders where the contract address for the maker asset matches the value specified
- takerAssetAddress [string] returns orders where the contract address for the taker asset matches the value specified
Order specific parameters:
- senderAddress [string]: returns orders with the specified senderAddress
- makerAssetData [string]: returns orders with the specified makerAssetData
- takerAssetData [string]: returns orders with the specified takerAssetData
- traderAssetData [string]: returns orders where either makerAssetData or takerAssetData has the value specified
- makerAddress [string]: returns orders with the specified makerAddress
- takerAddress [string]: returns orders with the specified takerAddress
- traderAddress [string]: returns orders where either makerAddress or takerAddress has the value specified
- feeRecipientAddress [string]: returns orders where feeRecipientAddress is feeRecipient address
- makerFeeAssetData [string]: returns orders with the specified makerFeeAssetData
- takerFeeAssetData [string]: returns orders with the specified takerFeeAssetData
All parameters are optional.
If both makerAssetData and takerAssetData are specified, returned orders will be sorted by price determined by (takerAssetAmount/makerAssetAmount) in ascending order. By default, orders returned by this endpoint are unsorted.
While there is some redundancy in supporting maker/takerAssetType, maker/takerAssetAddress, and maker/takerAssetData, they are actually all needed. For example, you cannot query "all ERC712 orders", or "all Cryptokitties orders", or "all ERC20 orders" with just maker/takerAssetData and need the other query params to do so.
{
"total": 984,
"page": 1,
"perPage": 100,
"records": [
{
"order": {
"chainId": 1,
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
"makerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
"takerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"makerAssetAmount": "10000000000000000",
"takerAssetAmount": "20000000000000000",
"makerFee": "100000000000000",
"takerFee": "200000000000000",
"expirationTimeSeconds": "1532560590",
"salt": "1532559225",
"makerAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"takerAssetData": "0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063",
"makerFeeAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"takerFeeAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"signature": "0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33"
},
"metaData": {}
}
...
]
}
Retrieves a specific order by orderHash.
{
"order": {
"chainId": 1,
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
"makerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
"takerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"makerAssetAmount": "10000000000000000",
"takerAssetAmount": "20000000000000000",
"makerFee": "100000000000000",
"takerFee": "200000000000000",
"expirationTimeSeconds": "1532560590",
"salt": "1532559225",
"makerAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"takerAssetData": "0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063",
"makerFeeAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"takerFeeAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"signature": "0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33"
},
"metaData": {}
}
Returns HTTP 404 if no order with specified orderHash was found.
Retrieves the orderbook for a given asset pair. This endpoint should be paginated.
- baseAssetData [string]: assetData (makerAssetData or takerAssetData) designated as the base currency in the currency pair calculation of price (required)
- quoteAssetData [string]: assetData (makerAssetData or takerAssetData) designated as the quote currency in the currency pair calculation of price (required)
{
"bids": {
"total": 325,
"page": 2,
"perPage": 100,
"records": [
{
"order": {
"chainId": 1,
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
"makerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
"takerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"makerAssetAmount": "10000000000000000",
"takerAssetAmount": "20000000000000000",
"makerFee": "100000000000000",
"takerFee": "200000000000000",
"expirationTimeSeconds": "1532560590",
"salt": "1532559225",
"makerAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"takerAssetData": "0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063",
"makerFeeAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"takerFeeAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"signature": "0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33"
}
"metaData": {}
},
...
]
}
"asks": {
"total": 500,
"page": 2,
"perPage": 100,
"records": [
{
"order": {
"chainId": 1,
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
"makerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"takerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"makerAssetAmount": "20000000000000000",
"takerAssetAmount": "10000000000000000",
"makerFee": "200000000000000",
"takerFee": "100000000000000",
"expirationTimeSeconds": "1532560590",
"salt": "1532559225",
"makerAssetData": "0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063",
"takerAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"makerFeeAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"takerFeeAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"signature": "0x013842a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b3518891"
},
"metaData": {}
},
...
]
}
}
bids
- array of signed orders wheretakerAssetData
is equal tobaseAssetData
asks
- array of signed orders wheremakerAssetData
is equal tobaseAssetData
Bids will be sorted in descending order by price, and asks will be sorted in ascending order by price. Within the price sorted orders, the orders are further sorted by taker fee price which is defined as the takerFee divided by takerTokenAmount. After taker fee price, orders are to be sorted by expiration in ascending order.
The way pagination works for this endpoint is that the page and perPage query params apply to both bids
and asks
collections, and if page
* perPage
> total
for a certain collection, the records
for that collection should just be empty.
Relayers have full discretion over the orders that they are willing to host on their orderbooks (e.g what fees they charge, etc...). In order for traders to discover their requirements programmatically, they can send an incomplete order to this endpoint and receive the missing fields, specifc to that order. This gives relayers a large amount of flexibility to tailor fees to unique traders, trading pairs and volume amounts. Submit a partial order and receive information required to complete the order: senderAddress
, feeRecipientAddress
, makerFee
, takerFee
.
{
"chainId": 1,
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
"makerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
"takerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"makerAssetAmount": "10000000000000000",
"takerAssetAmount": "20000000000000000",
"makerAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"takerAssetData": "0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063",
"expirationTimeSeconds": "1532560590"
}
Returns a HTTP 201 response with the following payload:
{
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
"makerFee": "100000000000000",
"takerFee": "200000000000000",
"makerFeeAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"takerFeeAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498"
}
Error response will be sent with a non-2xx HTTP status code. See the Errors section for more information.
Retrieves a list of all fee recipient addresses for a relayer. This endpoint should be paginated.
No custom parameters, just pagination parameters.
{
"total": 3,
"page": 1,
"perPage": 10,
"records": [
"0x6eC92694ea172ebC430C30fa31De87620967A082",
"0x9e56625509c2f60af937f23b7b532600390e8c8b",
"0xa2b31dacf30a9c50ca473337c01d8a201ae33e32"
]
}
Submit a signed order to the relayer.
{
"chainId": 1,
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
"makerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
"takerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"makerAssetAmount": "10000000000000000",
"takerAssetAmount": "20000000000000000",
"makerFee": "100000000000000",
"takerFee": "200000000000000",
"expirationTimeSeconds": "1532560590",
"salt": "1532559225",
"makerAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"takerAssetData": "0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063",
"makerFeeAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"takerFeeAssetData": "0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498",
"signature": "0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33"
}
Returns HTTP 201 upon success.
Error response will be sent with a non-2xx HTTP status code. See the Errors section for more information.