PostHog
Paginate a PostHog HogQL query
Personal API keys cannot use OFFSET with the PostHog Query API. For ad hoc paging, use a keyset predicate on the sort column. Use Batch Exports when you need a complete export.
Documentation reviewed · 2 methods with sources
Ways to do it
API
POST /api/projects/{project_id}/query
Run a named HogQLQuery with a bounded result set through the Query API.
Read source: PostHog warehouse query pagination- Requirements
- A PostHog personal API key with project query read permission, project ID, and the correct US or EU API host.
- Limitations
- Personal API keys get HTTP 400 for OFFSET pagination. For ad hoc event pages, use a timestamp cursor and account for rows with the same timestamp at a page boundary.
Example shell
curl --fail "https://us.posthog.com/api/projects/$POSTHOG_PROJECT_ID/query/" \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
-H 'Content-Type: application/json' --data-binary @- <<'JSON'
{"query":{"kind":"HogQLQuery","name":"events_after_cursor","query":"SELECT event, timestamp FROM events WHERE timestamp > '2026-11-27 00:00:00' ORDER BY timestamp LIMIT 1000"}}
JSONInterface
PostHog SQL editor
Use the SQL editor to inspect a bounded result and apply LIMIT or OFFSET interactively.
Read source: PostHog SQL editor- Requirements
- A PostHog project with access to the SQL editor.
- Limitations
- SQL insights default to 100 rows. Set a LIMIT explicitly if you need a different page size.
Example text
SELECT event, timestamp FROM events ORDER BY timestamp LIMIT 100 OFFSET 100