Skip to main content
This recipe reads GET /api/v1/events page after page, pausing a second between pages and stopping after 100 pages per run, then prints the cursor to store. Run it on a schedule with the cursor the last run printed. Delivery is at least once, so skip any cursor you already handled. The Next.js and FastAPI forms are a route your scheduler calls, refusing any call without the secret in INTERNAL_ROUTE_SECRET (sent as X-Internal-Secret). The Laravel form is a scheduled command and the Spring form a scheduled job. All four store the cursor between runs.

Prerequisites

  • MART_API_KEY: your API key, with the events:read scope.
  • MART_API_BASE: https://sandbox.mart.ps while you build, https://mart.ps when you go live.
  • MART_EVENTS_CURSOR: the cursor the last run printed. Leave it unset the first time.
One runtime: cURL 7.84 or later with jq; Node 22.18 or later, which runs the .ts file as it is; Python 3.9 or later with httpx; PHP 7.4 or later with its curl extension; Go 1.22 or later; or Java 17 or later with Jackson (jackson-databind). Each file reads its variables from the environment and sets a timeout on every call. Run it on your own server: a browser or an app never holds the key.

Run the recipe

Verify the result

Run it again with that cursor: with nothing new it prints events: 0 and the same cursor. Store the printed cursor, not the last event’s. See Follow events.

Troubleshooting

Every other code is in the error catalog.