How do I paginate through BTQL project_logs query results?

Last updated: March 25, 2025

Context

When querying project_logs using BTQL, results are automatically paginated with a default limit. To retrieve all results matching your query criteria, you'll need to handle pagination using cursors.

Answer

To retrieve all results from a BTQL project_logs query, follow these steps:

  1. Make your initial query without a cursor:

    {
      "query": "select: id, created 
      from: project_logs('your-project-id') 
      filter: created > '2025-03-21 22:00:00'"
    }
  2. Check the response for:

    • The data array containing your results

    • A cursor value in the response

  3. If a cursor is present, make subsequent queries by adding the cursor to your query:

    {
      "query": "select: id, created 
      from: project_logs('your-project-id') 
      filter: created > '2025-03-21 22:00:00'
      cursor: 'YOUR-CURSOR-VALUE'"
    }
  4. Continue making queries with the new cursor until you receive a response where:

    • The data array is empty, AND

    • No cursor is provided in the response

    This indicates you've retrieved all results.

Reference: BTQL Documentation - Limit and Cursor