Pagination
All list endpoints in the HookSniff API use cursor-based pagination. This is faster and more reliable than offset-based pagination for large datasets.
How It Works
Each response includes a cursor field pointing to the next page. Pass it as a query parameter to get the next batch:
# First page
GET /v1/endpoints?limit=20
# Response: { "data": [...], "cursor": "eyJpZCI6MTB9" }
# Next page
GET /v1/endpoints?limit=20&cursor=eyJpZCI6MTB9
# Response: { "data": [...], "cursor": "eyJpZCI6MjB9" }
# No more pages
GET /v1/endpoints?limit=20&cursor=eyJpZCI6MjB9
# Response: { "data": [...], "cursor": null }Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| limit | integer | 20 | Number of items per page (max 100) |
| cursor | string | null | Pagination cursor from previous response |
| iterator | string | null | Alternative: event iterator for deliveries |
Manual Pagination
Node.js
// Manual pagination
let cursor = undefined;
do {
const page = await hs.endpoint.list({ limit: 20, cursor });
for (const ep of page.data) {
console.log(ep.url);
}
cursor = page.cursor;
} while (cursor);Python
# Manual pagination
cursor = None
while True:
page = hs.endpoint.list(limit=20, cursor=cursor)
for ep in page.data:
print(ep.url)
cursor = page.cursor
if not cursor:
breakGo
cursor := ""
for {
page, _ := hs.Endpoint.List(ctx, &hooksniff.EndpointListOptions{
Limit: hooksniff.Int32(20),
Cursor: &cursor,
})
for _, ep := range page.Data {
fmt.Println(ep.Url)
}
if page.Cursor == nil || *page.Cursor == "" {
break
}
cursor = *page.Cursor
}Auto-Paginate Helpers
All SDKs provide iterator helpers that handle pagination automatically:
Node.js
// Iterate all endpoints (auto-paginates)
for await (const ep of hs.endpoint.listIterator({ limit: 100 })) {
console.log(ep.url);
}
// Collect all into array
const allEndpoints = await hs.endpoint.listAll();Python
# Iterate all endpoints (auto-paginates)
for ep in hs.endpoint.list_iterator(limit=100):
print(ep.url)
# Collect all into list
all_endpoints = list(hs.endpoint.list_iterator())Go
// Iterate all endpoints (auto-paginates)
iter := hs.Endpoint.ListIterator(ctx, &hooksniff.EndpointListOptions{
Limit: hooksniff.Int32(100),
})
for iter.Next() {
ep := iter.Current()
fmt.Println(ep.Url)
}
if err := iter.Err(); err != nil {
log.Fatal(err)
}Filtering & Sorting
Many list endpoints support additional filters:
# Filter deliveries by event type
GET /v1/webhooks?event_type=order.created&limit=20
# Filter by endpoint
GET /v1/webhooks?endpoint_id=ep_abc123&limit=20
# Filter by status
GET /v1/webhooks?status=failed&limit=20
# Filter by date range
GET /v1/webhooks?after=2024-01-01T00:00:00Z&before=2024-01-31T23:59:59Z