Pagination
Read long lists of projects one page at a time with page and limit.
List a person's projects page by page reads a long list in pages. Two query parameters are required:
| Parameter | Meaning |
|---|---|
page | The page to read, starting at 1. |
limit | How many items a page holds, from 1 to 200. A larger number is read as 200. |
The answer wraps the items:
{
"has_more": true,
"page": 1,
"items_per_page": 20,
"items": [ … ]
}has_more is true when the page came back full, so there may be another.
The last page can come back full too; the page after it is then empty, with
has_more: false.
Read every page#
async function allProjects(uid) {
const projects = [];
for (let page = 1; ; page++) {
const url = `https://api.measuremaponline.com/api/v1/users/${uid}/projects?page=${page}&limit=200`;
const response = await fetch(url, {headers: {Authorization: process.env.MMO_API_KEY}});
const body = await response.json();
projects.push(...body.items);
if (!body.has_more) {
return projects;
}
}
}Projects are listed most recently opened first, so a project opened while you read can move between pages. For a complete snapshot of a small account, List all of a person's projects answers with every project at once.