Pagination
List endpoints in the Cannahub API are paginated with limit and offset, following the convention of the underlying Medusa backend. There are no cursors — you request a page by choosing how many records to return (limit) and how many to skip (offset), and you use the count in the response to know how many records exist in total.
All examples require a Bearer token and the Tenant-id header (see Authentication). Admin list endpoints reject callers without the appropriate role.
Query parameters
- Name
limit- Type
- integer
- Description
Maximum number of records to return in this page. Defaults vary per endpoint (commonly
20). Passlimit=0when you only need thecountand not the records.
- Name
offset- Type
- integer
- Description
Number of records to skip before collecting the page. Defaults to
0. To fetch page n (1-based) with a fixed page size, useoffset = (n - 1) * limit.
Endpoints also accept their own filters (for example search/q, location_id, date ranges) alongside limit/offset — see each entity page for the supported filters.
Page math (page size 20)
Page 1 → offset=0 limit=20
Page 2 → offset=20 limit=20
Page 3 → offset=40 limit=20
...
Page n → offset=(n-1)*20
Response shape
Paginated responses return the records in a named array plus a count of the total number of matching records (not just the current page). The array key is named after the resource — for example members, items, products — rather than a generic data.
- Name
<resource>- Type
- array
- Description
The records for the current page. The key matches the resource, e.g.
members,items.
- Name
count- Type
- integer
- Description
Total number of records matching the query across all pages.
Some endpoints (for example inventory) also echo back the offset and limit they applied, which is convenient when the client did not set them explicitly and got the defaults.
Response · /api/members
{
"members": [
{ "id": "cus_01J...", "firstName": "Juan" },
{ "id": "cus_02K...", "firstName": "Ana" }
],
"count": 137
}
Response · /api/inventory
{
"items": [
{ "id": "iitem_01HQ_BD_7G", "sku": "BD-7G-001" }
],
"count": 45,
"offset": 0,
"limit": 20
}
Because count is the total, you have reached the last page when offset + records.length >= count.
Examples
Request the second page of members (page size 20), i.e. records 21–40:
cURL
curl -G https://api.cannahub.tech/api/members \
-H "Authorization: Bearer {token}" \
-H "Tenant-id: high-up" \
-d limit=20 \
-d offset=20
Iterating through every page from JavaScript:
Fetching all pages
async function fetchAllMembers() {
const limit = 50
let offset = 0
const all = []
while (true) {
const res = await fetch(
`https://api.cannahub.tech/api/members?limit=${limit}&offset=${offset}`,
{
headers: {
Authorization: `Bearer ${token}`,
'Tenant-id': 'high-up',
},
},
)
const { members, count } = await res.json()
all.push(...members)
offset += limit
if (offset >= count) break
}
return all
}
Only need the total, not the records? Ask for limit=0:
Count only
curl -G https://api.cannahub.tech/api/members \
-H "Authorization: Bearer {token}" \
-H "Tenant-id: high-up" \
-d limit=0
# → { "members": [], "count": 137 }