SSoftLinkSMSDocs

Pagination

Walk through long lists with stable cursors.

List endpoints (GET /sms, GET /email, GET /webhook-events) return items newest first, a page at a time:

{
  "next": "https://api.softlinksms.co.ke/api/v1/sms?cursor=cD0yMDI2LTEwLTE5KzA4JTNBMTU%3D&page_size=100",
  "previous": null,
  "results": [ { "id": "3fae8b8e-9c3a-4e9a-9d3a-7e8e9c3a4e9a", "...": "..." } ]
}
  • next is the full URL of the next (older) page, or null on the last page.
  • previous is the URL of the newer page, or null on the first.
  • page_size sets how many items per page: default 100, maximum 1000.

Follow next until it's null. Don't build cursor values yourself; they're opaque and may change format.

import os
import requests

url = "https://api.softlinksms.co.ke/api/v1/sms?status=error&page_size=1000"
headers = {"X-Api-Key": os.environ["SOFTLINK_API_KEY"]}

while url:
    page = requests.get(url, headers=headers, timeout=30).json()
    for message in page["results"]:
        print(message["recipient"], message["status"])
    url = page["next"]

Cursors are stable: messages sent while you're paging don't shift items between pages or produce duplicates. Filters such as status and search carry through in the next URL.