Pagination
Cursor pagination on every list: ?limit= and ?cursor=, answered with { data, nextCursor }.
Lists return the newest items first, a page at a time:
{
"data": [
{
"id": "3EB0A1B2C3D4E5F60718",
"status": "read"
},
{
"id": "3EB0C9D8E7F6A5B40312",
"status": "delivered"
}
],
"nextCursor": "eyJ0IjoiMjAyNi0xMC0xM1QwODowMDowMC4wMDBaIn0"
}| Parameter | Meaning |
|---|---|
limit | Meaning1–100, default 25 (campaign recipients: 1–500, default 50). Otherwise 400 PAGINATION_LIMIT_INVALID. |
cursor | MeaningThe nextCursor of the previous page, unchanged. A tampered cursor answers 400 PAGINATION_CURSOR_INVALID. |
nextCursor: null means you reached the last page. Cursors are opaque: don’t build or parse them. Items added while you page don’t shift or duplicate the next pages.
Reading every page
import os, requests
def all_messages(**filters):
cursor = None
while True:
params = {"limit": 100, **filters, **({"cursor": cursor} if cursor else {})}
res = requests.get("https://mursilat.com/api/v2/messages",
headers={"Authorization": f"Bearer {os.environ['WASLA_API_KEY']}"},
params=params, timeout=30)
res.raise_for_status()
page = res.json()
yield from page["data"]
cursor = page["nextCursor"]
if not cursor:
break