Docs

List books

Public API

Returns books for active maturities admitted by the current policy, with market metadata and the top 3 ask/bid levels. Unlisted and past maturities are excluded, even when requested with ids. If a maturity leaves the policy, its books are hidden immediately, including books with existing offers. Supports filtering, sorting, and pagination; default sort is id ascending.


GET
/v0/midnight/books

Query Parameters

sort?string

Sort by comma-separated fields (id, ask, bid, maturity). Prefix a field with - for descending. Max 3 fields.

maturity_lte?integer

Inclusive upper maturity bound in unix seconds.

Range1 <= value <= 9007199254740991
maturity_gte?integer

Inclusive lower maturity bound in unix seconds.

Range1 <= value <= 9007199254740991
maturities?array<>

Exact maturity timestamp filter in unix seconds (comma-separated). Maximum 150 values.

Itemsitems <= 150
collateral_tokens?array<string>

Collateral token filter (comma-separated 20-byte 0x-prefixed EVM addresses, matches any collateral). Maximum 150 values.

Itemsitems <= 150
loan_tokens?array<string>

Loan token address filter (comma-separated 20-byte 0x-prefixed EVM addresses). Maximum 150 values.

Itemsitems <= 150
chain_ids?array<>

Integer EVM chain ID filter (comma-separated, e.g. 1 for Ethereum). Currently accepts at most one chain id.

Itemsitems <= 1
ids?string

Market ID filter as a single comma-separated query parameter of 32-byte 0x-prefixed hex IDs. Returns books for matching currently listed markets. Maximum 20 IDs.

limit?number

Maximum number of items to return (max 20, default 10).

cursor?string

Opaque pagination cursor from a previous response.

Response Body

application/json

application/json

application/json

application/json

curl -X GET "https://example.com/v0/midnight/books"
{  "cursor": "eyJzb3J0IjpbImlkIl0sImlkIjoiMHgxMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExIiwiYXNrIjoiMCIsImJpZCI6IjAiLCJtYXR1cml0eSI6MTc2MTkyMjgwMH0",  "data": [    {      "market_id": "0x12590ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67",      "chain_id": 1,      "midnight": "0x2F7a3AA739ba5792Ce1b4eA046117f2C0095BCA6",      "loan_token": "0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078",      "collaterals": [        {          "token": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",          "lltv": "860000000000000000",          "liquidation_cursor": "300000000000000000",          "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401"        }      ],      "maturity": 1761922800,      "rcf_threshold": "0",      "enter_gate": "0x0000000000000000000000000000000000000000",      "liquidator_gate": "0x0000000000000000000000000000000000000000",      "asks": [        {          "tick": 495,          "price": "500000000000000000",          "units": "369216000000000000000000",          "assets": "184608000000000000000000",          "count": 5        }      ],      "bids": [        {          "tick": 495,          "price": "500000000000000000",          "units": "369216000000000000000000",          "assets": "184608000000000000000000",          "count": 5        }      ]    }  ]}
{  "error": {    "code": "VALIDATION_ERROR",    "message": "Limit must be greater than 0.",    "details": [      {        "field": "limit",        "issue": "Limit must be greater than 0."      }    ],    "request_id": "req-123"  }}
{  "error": {    "code": "VALIDATION_ERROR",    "message": "Limit must be greater than 0.",    "details": [      {        "field": "limit",        "issue": "Limit must be greater than 0."      }    ],    "request_id": "req-123"  }}
{  "error": {    "code": "VALIDATION_ERROR",    "message": "Limit must be greater than 0.",    "details": [      {        "field": "limit",        "issue": "Limit must be greater than 0."      }    ],    "request_id": "req-123"  }}