Each API request only returns a limited amount of records. To allow users to fetch large amounts of records some of our endpoints implement a system of pagination.

Most paginated endpoints currently use cursor pagination. These endpoints will return a cursor next with each request response. To get the next set of records, the API user has to include the returned cursor on the following API request.

🚧

Default time range

Each endpoint includes a default time range which (for example 30 days for Get swaps by pool ). If you want to query data outside of default time range, you need to explicitely provide:

  • A start and end date: start_date and end_date
  • A time range days and either one of start_date or an end_date

For example:
Similarly if a user calls the API on 2022-12-01 with the following query:
/api/swaps/pool/0x5777d92f208679db4b9778590fa3cab3ac9e2168
The default time range for this endpoint is one month, so if you keep paginating until 2022-11-01, the API will return an empty array.

To paginate further, a user can specify a start_date and an end_date as follows:
/api/swaps/pool/0x5777d92f208679db4b9778590fa3cab3ac9e2168?network=ethereum&start_date=2022-10-01&end_date=2022-12-01

Alternatively:
/api/swaps/pool/0x5777d92f208679db4b9778590fa3cab3ac9e2168?network=ethereum&days=60

For example, calling the Get recent swaps endpoint:

https://services.blockpour.com/api/swaps/recent

Will return the 50 most recent swaps ordered from the most recent to the oldest:

  "statusCode": 200,
  "status": true,
  "data": [
   ...., 
   {
      "time": "2022-12-07T07:28:27.000Z",
      "pair": "0x8072dcd2ec9d20b0cdacd1f596328711d906bfe7",
      "token0": "0x5187816a80a61b67b9879aea87ea0890a493396b",
      "token1": "0xc2132d05d31c914a87c6611c10748aeb04b58e8f",
      "amount0": -216.06966141020132,
      "amount1": 1.057698,
      "amount_usd": "1.05777203886",
      "slippage": 1.4386992810494261,
      "receiver": "0x11ab72cbb42e24310f269c48f9d8355e437e3f63",
      "tx": "0x36b50e1c23a6c7d3b803d2e43f9c5a615061272b17ddb3f2d6351a3370075cb4",
      "price0": 0.0048955139372938335,
      "price1": 1.00007,
      "network": 137,
      "token0_symbol": "CORIS",
      "token1_symbol": "USDT",
      "exchange": "0x5757371414417b8c6caad45baef941abc7d3ab32",
    }
  ],
  "next": "MTY3MDM5ODEwNywzOTEtMHgzNmI1MGUxYzIzYTZjN2QzYjgwM2QyZTQzZjljNWE2MTUwNjEyNzJiMTdkZGIzZjJkNjM1MWEzMzcwMDc1Y2I0"
}

The next set of recent swaps can be queried with:

https://services.blockpour.com/api/swaps/recent?next=MTY3MDM5ODEwNywzOTEtMHgzNmI1MGUxYzIzYTZjN2QzYjgwM2QyZTQzZjljNWE2MTUwNjEyNzJiMTdkZGIzZjJkNjM1MWEzMzcwMDc1Y2I0

This will return all swaps with a timestamp older than "2022-12-07T07:28:27.000Z"** (the oldest timestamp in the previous returned data).

Pagination Direction

By default or if you provide an end_date param, the data will paginate backwards meaning that each new response will return older records.

🚧

If you only provide a start_date, the API will paginate forward.

Example 1: ?start_date=2022-01-01&end_date=2022-01-02&limit=100 will return records from the most recent to the oldest. If there are more than 100 records, you can retrieve the next set of records by calling ?start_date=2022-01-01&end_date=2022-01-02&limit=100&next={next} where {next} is returned in the previous query result.

Example 2: ?start_date=2022-01-01&limit=100. There is no end_date so the API responses will be paginated forward. The API will return the records from the oldest (after 2022-01-01T00:00:00Z) to the most recent.