Skip to content

Your first API call

Three calls take you from a new token to a Monitor’s uptime. Each is shown in curl, in JavaScript (fetch, in Node 18 or later) and in Python (its standard library alone). Pick a language once, and the page keeps it.

Make an API token and copy it. Then put it in the UUP_API_TOKEN environment variable, where every example reads it:

Terminal window
export UUP_API_TOKEN="uup_api_…"

Keep the token out of your code and out of anything you commit. Anyone who has it can do what it allows.

Everything in the API lives under a Project, so start by finding yours. This lists the Projects your token reaches:

Terminal window
curl -H "Authorization: Bearer $UUP_API_TOKEN" \
"https://api.uup.dev/v1/projects"

Each Project in data has an id, such as prj_01J9Z3K8X4M2N6P8Q0R2S4T6V8. Copy the one you want.

Put that id in the path:

Terminal window
curl -H "Authorization: Bearer $UUP_API_TOKEN" \
"https://api.uup.dev/v1/projects/prj_01J9Z3K8X4M2N6P8Q0R2S4T6V8/monitors"

Each Monitor comes with its id, its status and its Checks. A long list comes a page at a time: How requests work says how to ask for the next one.

Put a Monitor’s id, such as mon_01J9Z3K8X4M2N6P8Q0R2S4T6V8, after the Project’s:

Terminal window
curl -H "Authorization: Bearer $UUP_API_TOKEN" \
"https://api.uup.dev/v1/projects/prj_01J9Z3K8X4M2N6P8Q0R2S4T6V8/monitors/mon_01J9Z3K8X4M2N6P8Q0R2S4T6V8/uptime"

The answer gives the uptime percentage over each window the dashboard shows, with the time we were watching and the hours not measured beside it. Uptime from the API says how to read them and how to show them.

A refusal comes with a status and a body that says what to do. The examples above print the body as it comes, except Python’s, which raises an error for any status from 400. Errors and limits lists every refusal.