Pagination

Learn how pagination works with the Blockdaemon APIs.

Background

Certain resources contain more data than is practical to return in a single request. Pagination splits the data across multiple responses. Each response returns a subset of the items requested and a continuation token (next_page_token).

📘

Note:

Continuation responses incur additional compute units.

How It Works

When making an API request, the response is paginated based on the specified page_size. To get the next batch of items, copy the returned continuation token (next_page_token) to the page_token query parameter and repeat the request with the new URL.

Here is an example of how to make a paginated request using the Get a List of Transaction Inputs and Outputs endpoint:

  1. Send an API request.
curl --request GET  
     --url '<https://svc.blockdaemon.com/universal/v1/bitcoin/mainnet/account/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa/utxo?spent=false&check_mempool=false&from=961846434&to=1119612834&order=desc&page_size=3'>  
     --header 'X-API-Key: 2go1YqUcuAr4WZ2-3WgSD3c7qpatZqQuNWhTVBldKZnTSUtw'  
     --header 'accept: application/json'
  1. The response will include a next_page_token which can be used to retrieve more items in subsequent requests. Here is a sample response:

❗️

Note:

If no next_page_token is returned, then no more data is available.

{
  "total": 3,
  "data": [
    {
      "status": "mined",
      "is_spent": false,
      "value": 546,
      "mined": {
        "index": 0,
        "tx_id": "385e7bfe62c8743b0bd5d3f4594ada38b2eb0764c4d89061591c11ba851c1ae0",
        "date": 1690886734,
        "block_id": "000000000000000000037cd5a51126baf707ae6ba6f3ab30738fc8bd689185c4",
        "block_number": 801188,
        "confirmations": 24,
        "meta": {
          "addresses": [
            "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
          ],
          "index": 0,
          "script": "76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac",
          "script_type": "pubkeyhash"
        }
      }
    },
    {
      "status": "mined",
      "is_spent": false,
      "value": 954,
      "mined": {
        "index": 0,
        "tx_id": "982c91b83f1e73eae8e8b0a24b5b1c13f6e0d6cd691b420f5f74a749aed9d0f4",
        "date": 1690825153,
        "block_id": "000000000000000000041b17b5d048819e4672d23ca3a0e1672617f1661e3899",
        "block_number": 801101,
        "confirmations": 111,
        "meta": {
          "addresses": [
            "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
          ],
          "index": 0,
          "script": "76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac",
          "script_type": "pubkeyhash"
        }
      }
    },
    {
      "status": "mined",
      "is_spent": false,
      "value": 546,
      "mined": {
        "index": 0,
        "tx_id": "6ea5c5ab313b8982ca88f311a45f6dadc571d3e288809c9bc240c551cab839ca",
        "date": 1690741749,
        "block_id": "000000000000000000000663d5e45c2c6cb11436d7aff7a71db07c70027ab5e3",
        "block_number": 800942,
        "confirmations": 270,
        "meta": {
          "addresses": [
            "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
          ],
          "index": 0,
          "script": "76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac",
          "script_type": "pubkeyhash"
        }
      }
    },
  ],
  "meta": {
    "paging": {
      "next_page_token": "b2d0e8bb9bcece54157064c82f2739ba3ca8d60a004940dfeee7ceb396714234-0-799694"
    }
  }
}
  1. Copy the token from thenext_page_token type into the page_token query parameter in the next request. Here is an example:
curl --request GET  
     --url '<https://svc.blockdaemon.com/universal/v1/bitcoin/mainnet/account/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa/utxo?spent=false&check_mempool=false&from=961846434&to=1119612834&order=desc&page_token=b2d0e8bb9bcece54157064c82f2739ba3ca8d60a004940dfeee7ceb396714234-0-799694&page_size=3'>  
     --header 'X-API-Key: 2go1YqUcuAr4WZ2-3WgSD3c7qpatZqQuNWhTVBldKZnTSUtw'  
     --header 'accept: application/json'

This request will return the next set of items from the last response.

👋 Need Help?

Contact us through email or our support page for any issues, bugs, or assistance you may need.