Pagination
List endpoints return results in pages. Control the window with two query parameters and read the pagination object to know how many pages there are.
Parameters
| Parameter | Type | Default | Notes |
|---|---|---|---|
page |
integer | 1 |
1-based page number. |
limit |
integer | 50 |
Items per page. Maximum 250. |
Requests for a limit above 250 are capped at 250. A page below 1 is treated as 1.
The pagination object
Every paginated response includes a pagination object alongside the named results array (members, recognitions, responses, questions, or feedback):
{
"statusCode": 200,
"message": "success",
"members": [ /* ... up to `limit` items ... */ ],
"pagination": {
"currentPage": 2,
"totalPages": 4,
"totalItems": 183,
"pageSize": 50
}
}
| Field | Meaning |
|---|---|
currentPage |
The page you just received. |
totalPages |
Total number of pages for the query. |
totalItems |
Total matching records across all pages. |
pageSize |
The effective page size (your limit, capped at 250). |
Looping through every page
Keep requesting until currentPage reaches totalPages.
import os, requests
def all_members(team_id):
base = "https://api.happily.ai/prod/1/members"
headers = {"x-api-key": os.environ["HAPPILY_API_KEY"]}
page, out = 1, []
while True:
res = requests.get(base, params={"team_id": team_id, "page": page, "limit": 250}, headers=headers)
body = res.json()
out.extend(body.get("members", []))
if page >= body["pagination"]["totalPages"]:
break
page += 1
return out
async function allMembers(teamId) {
const headers = { "x-api-key": process.env.HAPPILY_API_KEY };
const out = [];
let page = 1;
while (true) {
const url = new URL("https://api.happily.ai/prod/1/members");
url.search = new URLSearchParams({ team_id: teamId, page, limit: 250 });
const body = await (await fetch(url, { headers })).json();
out.push(...(body.members ?? []));
if (page >= body.pagination.totalPages) break;
page++;
}
return out;
}
Tip
Use the largest page size (limit=250) for bulk exports to minimize round trips and stay well within rate limits.
Get an API key