What does a list response look like?
JSON
{
"data": [ /* message objects */ ],
"total": 140,
"limit": 25,
"position": 0,
"next_position": 25
}| Name | Type | Description |
|---|---|---|
data | array | The messages on this page. |
total | integer | Total messages matching the filters. |
limit / position | integer | Echo of the page size and offset you requested. |
next_position | integer | null | Pass as position to get the next page. null on the last page. |
How do I page through everything?
Node.js
let position = 0;
while (position !== null) {
const res = await fetch(`https://api.tuskmail.africa/v1/messages?folder=inbox&limit=100&position=${position}`, { headers });
const page = await res.json();
for (const m of page.data) console.log(m.subject);
position = page.next_position;
}Remember the rate limit: 60 requests per minute.