API v1.0.0

NationCam for developers

Everything the NationCam interface does, it does through this API. 37 operations, described below from the same document the server runs on.

Guide

Getting started

The API lives at https://nationcam.com/api/v1. Bodies are JSON, times are ISO 8601 in UTC, and every response carries an X-Request-Id to quote if something goes wrong.

An account admin creates a token under Dashboard, in the account’s API access panel. API access is part of selected plans; ask us if the panel says it is not on for your account. Then check the token works:

curl "https://nationcam.com/api/v1/credential" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

The machine-readable description is OpenAPI 3.1 at /api/v1/openapi.json (also .yaml). It needs no credential, and client generators can read it directly.

Guide

Tokens and scopes

Send the token as Authorization: Bearer … on every request. A token belongs to one account and never reaches another account’s data. It is a server-side secret: do not put one in a browser, an app a customer installs, or a URL. It is shown once when created; revoke it in the same panel.

A token holds scopes, chosen when it is made. An operation that needs a scope the token lacks answers 403.

Guide

Errors

Every error has the same shape. code is stable and meant for programs; message is meant for people. fields appears only when a field is wrong.

{
  "error": {
    "code": "validation_failed",
    "message": "the request is not valid",
    "request_id": "req_5f2c9a…",
    "fields": [{ "field": "body.name", "message": "is required" }]
  }
}
400bad_requestThe request could not be read, such as a bad cursor.
401unauthorizedNo valid credential.
403forbiddenA valid credential without the scope or the role.
404not_foundNo such thing, or not one this credential can see.
409conflictThe change does not fit the current state.
410goneIt existed and has expired.
415unsupported_media_typeA body that is not JSON.
422validation_failedA field is wrong; fields says which.
429rate_limitedOver the limit for the minute.
500internalOur fault. Quote the request id.
502upstream_failedThe streaming server did not do what was asked.
503unavailableA part this operation needs is not running.

Guide

Lists

Long lists come a page at a time. Ask with limit (50 unless you say otherwise, 200 at most). If the answer has a next_cursor, send it back as cursor for the next page; when it is absent you have everything.

{ "data": [ … ], "next_cursor": "MTIz" }

Guide

Rate limits

Each token has a number of requests it may make per minute. Every response says where you stand:

  • RateLimit-Limit: requests allowed per minute
  • RateLimit-Remaining: how many are left in this minute
  • RateLimit-Reset: seconds until the count starts over

Past the limit the answer is 429 with Retry-After. Wait that many seconds and carry on.

Guide

Webhooks

Instead of asking repeatedly, give us an https address and we will POST to it when something changes in the account. Add one with create-account-webhook; the answer carries a signing secret, shown once.

POST /your/endpoint
NationCam-Event: camera.paused
NationCam-Delivery: 1842
NationCam-Signature: t=1796400000,v1=5d41402abc4b2a76…

{
  "id": "evt_9f8e7d6c5b4a39281706f5e4",
  "type": "camera.paused",
  "created_at": "2026-12-04T15:04:05Z",
  "account_id": 12,
  "data": { … }
}

To check a delivery is ours, compute HMAC-SHA256 of <t>.<raw body> with your secret and compare it with v1. Refuse a t more than a few minutes old.

Answer 2xx within 10 seconds. Anything else is tried again after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours, then given up on. The same event can arrive twice; use id to ignore repeats. list-webhook-deliveries shows what your endpoint answered, and test-account-webhook sends a webhook.test event on demand.

camera.createdA camera was added. data is the camera.
camera.deletedA camera was deleted. data is its id and name.
camera.pausedA camera was paused. data is the camera.
camera.resumedA camera was resumed. data is the camera.
camera.updatedA camera's name or description changed. data is the camera.
location.createdA location was added. data is the location.
location.deletedA location was deleted. data is its id and name.
location.updatedA location was edited. data is the location.
member.joinedSomeone accepted an invitation. data is the member.
member.removedA member was removed or left. data is their user id.
member.updatedA member's role or cameras changed. data is the member.

Guide

AI connector

The same operations are offered to AI assistants as Model Context Protocol tools at https://nationcam.com/api/v1/mcp: 31 tools, one per operation that answers in JSON. Each operation below shows its tool name. A tool can do exactly what the token can, no more: the assistant only sees the tools the token’s scopes allow.

To add it to Claude Code:

claude mcp add --transport http nationcam https://nationcam.com/api/v1/mcp \
  --header "Authorization: Bearer $NATIONCAM_TOKEN"

Any client that speaks streamable HTTP and can send a header works the same way. Give an assistant a token with only the scopes it needs; a read-only token is a good place to start.

Reference

Credential

Check what a token or session is.

Check a credential

GET/api/v1/credential

any credentialtool: get_credential

Says what the credential on this request is. Use it to confirm a token or a session works before calling anything else.

Response · 200

account_idintegerThe account a token belongs to
adminrequiredbooleanWhether this is NationCam staff
kindrequired"session" | "token"What was presented: a signed-in person's session, or an account API token
scopesstring[] | nullWhat a token may do
user_idstringThe signed-in person, for a session
curl "https://nationcam.com/api/v1/credential" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Reference

Cameras

An account's cameras: list, read, add, edit, pause, resume, delete, and whether each is sending video.

List an account's cameras

GET/api/v1/accounts/{account_id}/cameras

read:camerastool: list_account_cameras

The account's cameras in every status, private ones included, oldest first. A token sees all of them. A signed-in member sees what their membership allows: an account admin and a viewer of all cameras see every one, a restricted viewer only those picked for them.

Parameters

account_idrequiredinteger · pathThe account
limitinteger · queryHow many to return
cursorstring · queryThe next_cursor of the previous page; leave out for the first page

Response · 200

datarequiredobject[] | null
data[].aboutrequiredstringPlain-text description; may be empty
data[].account_idintegerThe account the camera belongs to; absent for a camera NationCam runs itself
data[].created_atrequireddate-time
data[].idrequiredinteger
data[].locationobjectThe location the camera is at; absent if it has none
data[].location.idrequiredinteger
data[].location.namerequiredstring
data[].location.slugrequiredstring
data[].namerequiredstring
data[].playbackrequiredobject
data[].playback.typerequiredstringThe stream's media type
data[].playback.urlrequiredstringThe live stream. An address starting with / is on the NationCam site itself and is meant for players on NationCam and on licensed embedding sites; a private camera's also needs a short-lived stream token
data[].review_notestringWhat the reviewer wrote, if anything
data[].slugrequiredstringThe camera's name in web addresses
data[].staterequiredobjectThe US state the camera is in
data[].state.idrequiredinteger
data[].state.namerequiredstring
data[].state.slugrequiredstring
data[].statusrequired"pending" | "active" | "paused" | "rejected" | "inactive"Where the camera is in its life: waiting for review, running, paused by the account, turned down in review, or switched off by NationCam. Whether it is sending video right now is the status operation's answer, not this
data[].updated_atrequireddate-time
data[].visibilityrequired"public" | "private"private if the camera or its location is private: only the account's members can watch it
next_cursorstringPass as cursor to get the next page; absent on the last page
curl "https://nationcam.com/api/v1/accounts/{account_id}/cameras" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Add a camera

POST/api/v1/accounts/{account_id}/cameras

write:camerastool: create_account_camera

Starts reading the camera's video and adds the camera to the account at one of its locations. A new camera is pending: it is not shown publicly until NationCam has reviewed it. An account has a limit on how many cameras it holds and how many it may add in 24 hours; past either, the answer is 429.

Parameters

account_idrequiredinteger · pathThe account

Request body

aboutstringPlain-text description
location_idrequiredintegerOne of the account's locations; the camera takes its state from it
namerequiredstring
rtsp_urlrequiredstringWhere the camera's video is read from: an rtsp:// or rtsps:// address. It is stored on the streaming server and never returned by this API

Response · 201

aboutrequiredstringPlain-text description; may be empty
account_idintegerThe account the camera belongs to; absent for a camera NationCam runs itself
created_atrequireddate-time
idrequiredinteger
locationobjectThe location the camera is at; absent if it has none
location.idrequiredinteger
location.namerequiredstring
location.slugrequiredstring
namerequiredstring
playbackrequiredobject
playback.typerequiredstringThe stream's media type
playback.urlrequiredstringThe live stream. An address starting with / is on the NationCam site itself and is meant for players on NationCam and on licensed embedding sites; a private camera's also needs a short-lived stream token
review_notestringWhat the reviewer wrote, if anything
slugrequiredstringThe camera's name in web addresses
staterequiredobjectThe US state the camera is in
state.idrequiredinteger
state.namerequiredstring
state.slugrequiredstring
statusrequired"pending" | "active" | "paused" | "rejected" | "inactive"Where the camera is in its life: waiting for review, running, paused by the account, turned down in review, or switched off by NationCam. Whether it is sending video right now is the status operation's answer, not this
updated_atrequireddate-time
visibilityrequired"public" | "private"private if the camera or its location is private: only the account's members can watch it
curl -X POST "https://nationcam.com/api/v1/accounts/{account_id}/cameras" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"string","rtsp_url":"rtsp://user:pass@camera.example.com:554/stream1","location_id":1}'

List whether an account's cameras are live

GET/api/v1/accounts/{account_id}/cameras/status

read:camerastool: list_account_camera_status

One entry per camera, in the same order and pages as the camera list. Answers are reused for about 15 seconds, so polling faster than that learns nothing new. If the streaming server cannot be asked about a camera, that camera is unknown; the request still succeeds.

Parameters

account_idrequiredinteger · pathThe account
limitinteger · queryHow many to return
cursorstring · queryThe next_cursor of the previous page; leave out for the first page

Response · 200

datarequiredobject[] | null
data[].camera_idrequiredinteger
data[].staterequired"live" | "offline" | "paused" | "pending" | "unknown"live: sending video. offline: should be but is not, or was switched off. paused: stopped by the account. pending: not reviewed yet. unknown: the streaming server could not be asked
next_cursorstringPass as cursor to get the next page; absent on the last page
curl "https://nationcam.com/api/v1/accounts/{account_id}/cameras/status" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Get a camera

GET/api/v1/cameras/{camera_id}

read:camerastool: get_camera

One camera the caller may see. A camera in another account answers 404, the same as one that does not exist.

Parameters

camera_idrequiredinteger · pathThe camera

Response · 200

aboutrequiredstringPlain-text description; may be empty
account_idintegerThe account the camera belongs to; absent for a camera NationCam runs itself
created_atrequireddate-time
idrequiredinteger
locationobjectThe location the camera is at; absent if it has none
location.idrequiredinteger
location.namerequiredstring
location.slugrequiredstring
namerequiredstring
playbackrequiredobject
playback.typerequiredstringThe stream's media type
playback.urlrequiredstringThe live stream. An address starting with / is on the NationCam site itself and is meant for players on NationCam and on licensed embedding sites; a private camera's also needs a short-lived stream token
review_notestringWhat the reviewer wrote, if anything
slugrequiredstringThe camera's name in web addresses
staterequiredobjectThe US state the camera is in
state.idrequiredinteger
state.namerequiredstring
state.slugrequiredstring
statusrequired"pending" | "active" | "paused" | "rejected" | "inactive"Where the camera is in its life: waiting for review, running, paused by the account, turned down in review, or switched off by NationCam. Whether it is sending video right now is the status operation's answer, not this
updated_atrequireddate-time
visibilityrequired"public" | "private"private if the camera or its location is private: only the account's members can watch it
curl "https://nationcam.com/api/v1/cameras/{camera_id}" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Edit a camera

PATCH/api/v1/cameras/{camera_id}

write:camerastool: update_camera

Changes the name, the description, or both; a field left out is left alone. The video source, the location and the status are not changed here.

Parameters

camera_idrequiredinteger · pathThe camera

Request body

aboutstringPlain-text description; an empty string clears it
namestring

Response · 200

aboutrequiredstringPlain-text description; may be empty
account_idintegerThe account the camera belongs to; absent for a camera NationCam runs itself
created_atrequireddate-time
idrequiredinteger
locationobjectThe location the camera is at; absent if it has none
location.idrequiredinteger
location.namerequiredstring
location.slugrequiredstring
namerequiredstring
playbackrequiredobject
playback.typerequiredstringThe stream's media type
playback.urlrequiredstringThe live stream. An address starting with / is on the NationCam site itself and is meant for players on NationCam and on licensed embedding sites; a private camera's also needs a short-lived stream token
review_notestringWhat the reviewer wrote, if anything
slugrequiredstringThe camera's name in web addresses
staterequiredobjectThe US state the camera is in
state.idrequiredinteger
state.namerequiredstring
state.slugrequiredstring
statusrequired"pending" | "active" | "paused" | "rejected" | "inactive"Where the camera is in its life: waiting for review, running, paused by the account, turned down in review, or switched off by NationCam. Whether it is sending video right now is the status operation's answer, not this
updated_atrequireddate-time
visibilityrequired"public" | "private"private if the camera or its location is private: only the account's members can watch it
curl -X PATCH "https://nationcam.com/api/v1/cameras/{camera_id}" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'

Delete a camera

DELETE/api/v1/cameras/{camera_id}

write:camerastool: delete_camera

Stops reading the camera's video and removes the camera. This cannot be undone.

Parameters

camera_idrequiredinteger · pathThe camera

Answers 204 with no body.

curl -X DELETE "https://nationcam.com/api/v1/cameras/{camera_id}" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Pause a camera

POST/api/v1/cameras/{camera_id}/pause

write:camerastool: pause_camera

Stops reading the camera's video. Only an active camera can be paused; any other status answers 409. A public camera stays listed, with a placeholder.

Parameters

camera_idrequiredinteger · pathThe camera

Response · 200

aboutrequiredstringPlain-text description; may be empty
account_idintegerThe account the camera belongs to; absent for a camera NationCam runs itself
created_atrequireddate-time
idrequiredinteger
locationobjectThe location the camera is at; absent if it has none
location.idrequiredinteger
location.namerequiredstring
location.slugrequiredstring
namerequiredstring
playbackrequiredobject
playback.typerequiredstringThe stream's media type
playback.urlrequiredstringThe live stream. An address starting with / is on the NationCam site itself and is meant for players on NationCam and on licensed embedding sites; a private camera's also needs a short-lived stream token
review_notestringWhat the reviewer wrote, if anything
slugrequiredstringThe camera's name in web addresses
staterequiredobjectThe US state the camera is in
state.idrequiredinteger
state.namerequiredstring
state.slugrequiredstring
statusrequired"pending" | "active" | "paused" | "rejected" | "inactive"Where the camera is in its life: waiting for review, running, paused by the account, turned down in review, or switched off by NationCam. Whether it is sending video right now is the status operation's answer, not this
updated_atrequireddate-time
visibilityrequired"public" | "private"private if the camera or its location is private: only the account's members can watch it
curl -X POST "https://nationcam.com/api/v1/cameras/{camera_id}/pause" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Resume a camera

POST/api/v1/cameras/{camera_id}/resume

write:camerastool: resume_camera

Starts reading a paused camera's video again. Only a paused camera can be resumed; any other status answers 409.

Parameters

camera_idrequiredinteger · pathThe camera

Response · 200

aboutrequiredstringPlain-text description; may be empty
account_idintegerThe account the camera belongs to; absent for a camera NationCam runs itself
created_atrequireddate-time
idrequiredinteger
locationobjectThe location the camera is at; absent if it has none
location.idrequiredinteger
location.namerequiredstring
location.slugrequiredstring
namerequiredstring
playbackrequiredobject
playback.typerequiredstringThe stream's media type
playback.urlrequiredstringThe live stream. An address starting with / is on the NationCam site itself and is meant for players on NationCam and on licensed embedding sites; a private camera's also needs a short-lived stream token
review_notestringWhat the reviewer wrote, if anything
slugrequiredstringThe camera's name in web addresses
staterequiredobjectThe US state the camera is in
state.idrequiredinteger
state.namerequiredstring
state.slugrequiredstring
statusrequired"pending" | "active" | "paused" | "rejected" | "inactive"Where the camera is in its life: waiting for review, running, paused by the account, turned down in review, or switched off by NationCam. Whether it is sending video right now is the status operation's answer, not this
updated_atrequireddate-time
visibilityrequired"public" | "private"private if the camera or its location is private: only the account's members can watch it
curl -X POST "https://nationcam.com/api/v1/cameras/{camera_id}/resume" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Get whether a camera is live

GET/api/v1/cameras/{camera_id}/status

read:camerastool: get_camera_status

The same answer the account-wide status list gives for this camera.

Parameters

camera_idrequiredinteger · pathThe camera

Response · 200

camera_idrequiredinteger
staterequired"live" | "offline" | "paused" | "pending" | "unknown"live: sending video. offline: should be but is not, or was switched off. paused: stopped by the account. pending: not reviewed yet. unknown: the streaming server could not be asked
curl "https://nationcam.com/api/v1/cameras/{camera_id}/status" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Reference

Locations

The places cameras are grouped under, and the states they are in.

List an account's locations

GET/api/v1/accounts/{account_id}/locations

read:locationstool: list_account_locations

The account's locations in every status, oldest first. A token sees all of them, as do an account admin and a viewer of all cameras; a restricted viewer sees only the locations that hold a camera picked for them.

Parameters

account_idrequiredinteger · pathThe account
limitinteger · queryHow many to return
cursorstring · queryThe next_cursor of the previous page; leave out for the first page

Response · 200

datarequiredobject[] | null
data[].account_idintegerThe account the location belongs to; absent for one NationCam runs itself
data[].addressrequiredstringStreet address; may be empty
data[].camera_countrequiredintegerHow many cameras are at the location, in any status
data[].coordinatesobjectWhere it is on the map; these also turn on the weather panel. Absent if not set
data[].coordinates.latrequirednumber
data[].coordinates.lngrequirednumber
data[].created_atrequireddate-time
data[].descriptionrequiredstringPlain text; may be empty
data[].hostobjectWho hosts the cameras here. Absent if not set
data[].host.namestring
data[].host.sincedateThe day the host joined, as YYYY-MM-DD
data[].host.urlstringThe host's website: an http or https address
data[].idrequiredinteger
data[].namerequiredstring
data[].review_notestringWhat the reviewer wrote, if anything
data[].slugrequiredstringThe location's name in web addresses
data[].staterequiredobjectThe US state the location is in
data[].state.idrequiredinteger
data[].state.namerequiredstring
data[].state.slugrequiredstring
data[].statusrequired"pending" | "approved" | "rejected"Where the location is in review. Only an approved location is shown publicly
data[].updated_atrequireddate-time
data[].visibilityrequired"public" | "private"private: only the account's members can see the location and watch its cameras
next_cursorstringPass as cursor to get the next page; absent on the last page
curl "https://nationcam.com/api/v1/accounts/{account_id}/locations" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Add a location

POST/api/v1/accounts/{account_id}/locations

write:locationstool: create_account_location

Adds a location to the account. A new location is pending: it is not shown publicly until NationCam has reviewed it. Cameras can be added to it straight away.

Parameters

account_idrequiredinteger · pathThe account

Request body

addressstring
coordinatesobject
coordinates.latrequirednumber
coordinates.lngrequirednumber
descriptionstringPlain text
hostobject
host.namestring
host.sincedateThe day the host joined, as YYYY-MM-DD
host.urlstringThe host's website: an http or https address
namerequiredstring
state_idrequiredintegerThe US state it is in; see the states list

Response · 201

account_idintegerThe account the location belongs to; absent for one NationCam runs itself
addressrequiredstringStreet address; may be empty
camera_countrequiredintegerHow many cameras are at the location, in any status
coordinatesobjectWhere it is on the map; these also turn on the weather panel. Absent if not set
coordinates.latrequirednumber
coordinates.lngrequirednumber
created_atrequireddate-time
descriptionrequiredstringPlain text; may be empty
hostobjectWho hosts the cameras here. Absent if not set
host.namestring
host.sincedateThe day the host joined, as YYYY-MM-DD
host.urlstringThe host's website: an http or https address
idrequiredinteger
namerequiredstring
review_notestringWhat the reviewer wrote, if anything
slugrequiredstringThe location's name in web addresses
staterequiredobjectThe US state the location is in
state.idrequiredinteger
state.namerequiredstring
state.slugrequiredstring
statusrequired"pending" | "approved" | "rejected"Where the location is in review. Only an approved location is shown publicly
updated_atrequireddate-time
visibilityrequired"public" | "private"private: only the account's members can see the location and watch its cameras
curl -X POST "https://nationcam.com/api/v1/accounts/{account_id}/locations" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"string","state_id":1}'

Get a location

GET/api/v1/locations/{location_id}

read:locationstool: get_location

One location the caller may see. A location in another account answers 404, the same as one that does not exist.

Parameters

location_idrequiredinteger · pathThe location

Response · 200

account_idintegerThe account the location belongs to; absent for one NationCam runs itself
addressrequiredstringStreet address; may be empty
camera_countrequiredintegerHow many cameras are at the location, in any status
coordinatesobjectWhere it is on the map; these also turn on the weather panel. Absent if not set
coordinates.latrequirednumber
coordinates.lngrequirednumber
created_atrequireddate-time
descriptionrequiredstringPlain text; may be empty
hostobjectWho hosts the cameras here. Absent if not set
host.namestring
host.sincedateThe day the host joined, as YYYY-MM-DD
host.urlstringThe host's website: an http or https address
idrequiredinteger
namerequiredstring
review_notestringWhat the reviewer wrote, if anything
slugrequiredstringThe location's name in web addresses
staterequiredobjectThe US state the location is in
state.idrequiredinteger
state.namerequiredstring
state.slugrequiredstring
statusrequired"pending" | "approved" | "rejected"Where the location is in review. Only an approved location is shown publicly
updated_atrequireddate-time
visibilityrequired"public" | "private"private: only the account's members can see the location and watch its cameras
curl "https://nationcam.com/api/v1/locations/{location_id}" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Edit a location

PATCH/api/v1/locations/{location_id}

write:locationstool: update_location

Changes the fields given; a field left out is left alone. coordinates and host are each replaced whole, and null clears them. The status, the visibility and the account are not changed here.

Parameters

location_idrequiredinteger · pathThe location

Request body

addressstringAn empty string clears it
coordinatesobject | nullReplaces both numbers; null removes the location from the map
coordinates.latrequirednumber
coordinates.lngrequirednumber
descriptionstringAn empty string clears it
hostobject | nullReplaces the whole host; null clears it
host.namestring
host.sincedateThe day the host joined, as YYYY-MM-DD
host.urlstringThe host's website: an http or https address
namestring
state_idinteger

Response · 200

account_idintegerThe account the location belongs to; absent for one NationCam runs itself
addressrequiredstringStreet address; may be empty
camera_countrequiredintegerHow many cameras are at the location, in any status
coordinatesobjectWhere it is on the map; these also turn on the weather panel. Absent if not set
coordinates.latrequirednumber
coordinates.lngrequirednumber
created_atrequireddate-time
descriptionrequiredstringPlain text; may be empty
hostobjectWho hosts the cameras here. Absent if not set
host.namestring
host.sincedateThe day the host joined, as YYYY-MM-DD
host.urlstringThe host's website: an http or https address
idrequiredinteger
namerequiredstring
review_notestringWhat the reviewer wrote, if anything
slugrequiredstringThe location's name in web addresses
staterequiredobjectThe US state the location is in
state.idrequiredinteger
state.namerequiredstring
state.slugrequiredstring
statusrequired"pending" | "approved" | "rejected"Where the location is in review. Only an approved location is shown publicly
updated_atrequireddate-time
visibilityrequired"public" | "private"private: only the account's members can see the location and watch its cameras
curl -X PATCH "https://nationcam.com/api/v1/locations/{location_id}" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'

Delete a location

DELETE/api/v1/locations/{location_id}

write:locationstool: delete_location

Removes a location that has no cameras. One that still has cameras, in any status, answers 409: delete those first. This cannot be undone.

Parameters

location_idrequiredinteger · pathThe location

Answers 204 with no body.

curl -X DELETE "https://nationcam.com/api/v1/locations/{location_id}" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

List the US states

GET/api/v1/states

any credentialtool: list_states

Every state a location can be in, by name. Needs a credential but no particular scope.

Response · 200

datarequiredobject[] | null
data[].idrequiredinteger
data[].namerequiredstring
data[].slugrequiredstring
curl "https://nationcam.com/api/v1/states" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Reference

Archive

Stills: the latest frame of a camera and the frames kept from earlier.

List a camera's archived frames for one day

GET/api/v1/cameras/{camera_id}/frames

read:archivetool: list_camera_frames

Every still the archive holds for that day, oldest first. A day with none answers an empty list.

Parameters

camera_idrequiredinteger · pathThe camera
daystring · queryA day on the archive's clock, YYYY-MM-DD; leave out for today

Response · 200

datarequiredobject[] | null
data[].local_timerequiredstringThe same moment on the archive's clock, HH:MM
data[].taken_atrequireddate-timeWhen it was captured
data[].urlrequiredstringWhere to get the JPEG: a path on this API, fetched with the same credential. Add ?w=320 or ?w=640 for a smaller copy
dayrequiredstringThe day listed
timezonerequiredstringThe archive's clock: days and local times are in it
curl "https://nationcam.com/api/v1/cameras/{camera_id}/frames" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

List the days a camera has archived frames for

GET/api/v1/cameras/{camera_id}/frames/days

read:archivetool: list_camera_frame_days

How far back the archive goes depends on the plan; days that have been cleared out are not listed.

Parameters

camera_idrequiredinteger · pathThe camera

Response · 200

datarequiredstring[] | nullDays that have at least one frame, newest first, YYYY-MM-DD
timezonerequiredstring
curl "https://nationcam.com/api/v1/cameras/{camera_id}/frames/days" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Get one archived frame

GET/api/v1/cameras/{camera_id}/frames/{day}/{file}

read:archive

The JPEG itself. Use the url from the frame list rather than building this address.

Parameters

camera_idrequiredinteger · pathThe camera
dayrequiredstring · pathYYYY-MM-DD
filerequiredstring · pathThe frame, HHMM.jpg
w320 | 640 · queryA smaller copy this many pixels wide; leave out for full size

Answers 200 with the file itself (image/jpeg).

curl "https://nationcam.com/api/v1/cameras/{camera_id}/frames/{day}/{file}" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN" \
  -o out.jpeg

Get a camera's latest still

GET/api/v1/cameras/{camera_id}/still.jpg

read:archive

A JPEG of what the camera shows now, refreshed about once a minute. 404 if the camera has no picture to take one from; 502 if the streaming server could not supply it.

Parameters

camera_idrequiredinteger · pathThe camera
w320 | 640 · queryA smaller copy this many pixels wide; leave out for full size

Answers 200 with the file itself (image/jpeg).

curl "https://nationcam.com/api/v1/cameras/{camera_id}/still.jpg" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN" \
  -o out.jpeg

Reference

Accounts

The accounts a credential can reach.

List the accounts this credential can use

GET/api/v1/accounts

any credentialtool: list_accounts

For a signed-in person: every account they are a member of, their own first. For a token: its one account. Needs a credential but no particular scope.

Response · 200

datarequiredobject[] | null
data[].all_camerasrequiredbooleanWhether the caller sees every camera of the account; false only for a restricted viewer
data[].camera_countrequiredinteger
data[].idrequiredinteger
data[].location_countrequiredinteger
data[].namerequiredstring
data[].personalrequiredbooleanA person's own account, made for them the first time they add a location
data[].role"admin" | "viewer"The signed-in person's role in it; absent for a token and for staff who are not members
curl "https://nationcam.com/api/v1/accounts" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Reference

Members

Who belongs to an account, what they may see, and invitations.

Invite someone to an account

POST/api/v1/accounts/{account_id}/invites

write:memberstool: create_account_invite

Makes a single-use invitation carrying a role and what it may watch, valid for 7 days. The token is in this response only: it is stored hashed, so a lost one cannot be shown again; make a new one.

Parameters

account_idrequiredinteger · pathThe account

Request body

all_camerasbooleanLeave out, or true, for every camera. false limits a viewer to camera_ids. An admin always sees every camera
camera_idsinteger[] | nullWith all_cameras false: the account's cameras this viewer may watch
rolerequired"admin" | "viewer"

Response · 201

all_camerasrequiredboolean
camera_idsrequiredinteger[] | null
expires_atrequireddate-time
idrequiredinteger
rolerequired"admin" | "viewer"
tokenrequiredstringThe invitation itself. Shown only in this response; give it to the person, who accepts it once signed in
curl -X POST "https://nationcam.com/api/v1/accounts/{account_id}/invites" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"role":"admin"}'

List an account's members

GET/api/v1/accounts/{account_id}/members

read:memberstool: list_account_members

Everyone in the account, with their role and, for a restricted viewer, the cameras picked for them. For account admins and tokens; a viewer cannot see the member list.

Parameters

account_idrequiredinteger · pathThe account

Response · 200

datarequiredobject[] | null
data[].all_camerasrequiredbooleanfalse for a viewer limited to camera_ids
data[].camera_idsrequiredinteger[] | nullThe cameras a restricted viewer may watch; empty for everyone else
data[].created_atrequireddate-time
data[].rolerequired"admin" | "viewer"admin: manages the account and sees every camera. viewer: only watches
data[].updated_atrequireddate-time
data[].user_idrequiredstringThe person, as the sign-in system identifies them
curl "https://nationcam.com/api/v1/accounts/{account_id}/members" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Change a member's role and cameras

PUT/api/v1/accounts/{account_id}/members/{user_id}

write:memberstool: update_account_member

Replaces the member's role and what they may watch. An account must keep at least one admin: demoting the last one answers 409.

Parameters

account_idrequiredinteger · pathThe account
user_idrequiredstring · pathThe member

Request body

all_camerasbooleanLeave out, or true, for every camera. false limits a viewer to camera_ids. An admin always sees every camera
camera_idsinteger[] | nullWith all_cameras false: the account's cameras this viewer may watch
rolerequired"admin" | "viewer"

Response · 200

all_camerasrequiredbooleanfalse for a viewer limited to camera_ids
camera_idsrequiredinteger[] | nullThe cameras a restricted viewer may watch; empty for everyone else
created_atrequireddate-time
rolerequired"admin" | "viewer"admin: manages the account and sees every camera. viewer: only watches
updated_atrequireddate-time
user_idrequiredstringThe person, as the sign-in system identifies them
curl -X PUT "https://nationcam.com/api/v1/accounts/{account_id}/members/{user_id}" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"role":"admin"}'

Remove a member

DELETE/api/v1/accounts/{account_id}/members/{user_id}

write:memberstool: remove_account_member

Takes a person out of the account. An account admin or a token removes anyone; any signed-in member may remove themselves. Removing the last admin answers 409.

Parameters

account_idrequiredinteger · pathThe account
user_idrequiredstring · pathThe member

Answers 204 with no body.

curl -X DELETE "https://nationcam.com/api/v1/accounts/{account_id}/members/{user_id}" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Accept an invitation

POST/api/v1/invites/accept

signed-in admin only, not for tokens

Joins the signed-in person to the account the invitation is for. Only a signed-in person can accept; a token cannot. 404 for an unknown invitation, 409 if it was already used or the person is already a member, 410 if it has expired.

Request body

tokenrequiredstringThe invitation, as its creator received it

Response · 200

account_idrequiredintegerThe account that was joined
all_camerasrequiredbooleanfalse for a viewer limited to camera_ids
camera_idsrequiredinteger[] | nullThe cameras a restricted viewer may watch; empty for everyone else
created_atrequireddate-time
rolerequired"admin" | "viewer"admin: manages the account and sees every camera. viewer: only watches
updated_atrequireddate-time
user_idrequiredstringThe person, as the sign-in system identifies them

Reference

Tokens

An account's API tokens. Creating and revoking is done by a signed-in admin.

See whether an account has API access

GET/api/v1/accounts/{account_id}/api-access

read:tokenstool: get_account_api_access

API access is part of a paid plan. While it is off the account cannot create tokens and its existing tokens do not work.

Parameters

account_idrequiredinteger · pathThe account

Response · 200

enabledrequiredbooleanWhether this account may hold API tokens
curl "https://nationcam.com/api/v1/accounts/{account_id}/api-access" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Turn an account's API access on or off

PUT/api/v1/accounts/{account_id}/api-access

signed-in admin only, not for tokens

NationCam staff only. Turning it off stops every token of the account from working; turning it back on restores the ones that were not revoked.

Parameters

account_idrequiredinteger · pathThe account

Request body

enabledrequiredbooleanWhether this account may hold API tokens

Response · 200

enabledrequiredbooleanWhether this account may hold API tokens

List an account's API tokens

GET/api/v1/accounts/{account_id}/tokens

read:tokenstool: list_account_tokens

Every token of the account, newest first, including expired and revoked ones. The secret is never included.

Parameters

account_idrequiredinteger · pathThe account

Response · 200

datarequiredobject[] | null
data[].created_atrequireddate-time
data[].created_byrequiredstringThe person who created it
data[].expires_atdate-timeWhen it stops working; absent if it does not expire
data[].hintrequiredstringThe first characters of the token, to tell tokens apart
data[].idrequiredinteger
data[].last_used_atdate-timeRecorded at most once a minute
data[].namerequiredstringWhat the token is for, as its creator named it
data[].revoked_atdate-time
data[].scopesrequiredstring[] | nullWhat the token may do
data[].statusrequired"active" | "expired" | "revoked"
curl "https://nationcam.com/api/v1/accounts/{account_id}/tokens" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Create an API token

POST/api/v1/accounts/{account_id}/tokens

signed-in admin only, not for tokens

Creates a token for the account and returns it once. Needs a signed-in admin of the account: a token cannot create tokens. The account must have API access. Scopes: read:cameras, write:cameras, read:locations, write:locations, read:archive, read:members, write:members, read:tokens, read:webhooks, write:webhooks.

Parameters

account_idrequiredinteger · pathThe account

Request body

expires_atdate-timeWhen it should stop working; leave out for a token that does not expire
namerequiredstringWhat the token is for
scopesrequiredstring[] | nullWhat the token may do; see the scopes list

Response · 201

created_atrequireddate-time
created_byrequiredstringThe person who created it
expires_atdate-timeWhen it stops working; absent if it does not expire
hintrequiredstringThe first characters of the token, to tell tokens apart
idrequiredinteger
last_used_atdate-timeRecorded at most once a minute
namerequiredstringWhat the token is for, as its creator named it
revoked_atdate-time
scopesrequiredstring[] | nullWhat the token may do
statusrequired"active" | "expired" | "revoked"
tokenrequiredstringThe token itself. Shown only in this response: store it now, it cannot be read again

Revoke an API token

DELETE/api/v1/accounts/{account_id}/tokens/{token_id}

signed-in admin only, not for tokens

The token stops working at once and cannot be restored. It stays in the list, marked revoked. Needs a signed-in admin of the account.

Parameters

account_idrequiredinteger · pathThe account
token_idrequiredinteger · pathThe token's id

Answers 204 with no body.

Reference

Webhooks

Addresses that are told when something changes.

List an account's webhooks

GET/api/v1/accounts/{account_id}/webhooks

read:webhookstool: list_account_webhooks

Parameters

account_idrequiredinteger · pathThe account

Response · 200

datarequiredobject[] | null
data[].created_atrequireddate-time
data[].created_byrequiredstring
data[].descriptionrequiredstring
data[].eventsrequiredstring[] | null
data[].failed_last_dayrequiredintegerDeliveries given up on in the last 24 hours
data[].idrequiredinteger
data[].last_delivered_atdate-timeThe last delivery the subscriber accepted; absent if there has been none
data[].urlrequiredstring
curl "https://nationcam.com/api/v1/accounts/{account_id}/webhooks" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Add a webhook

POST/api/v1/accounts/{account_id}/webhooks

write:webhookstool: create_account_webhook

Subscribes an https address to events in the account. The response carries the signing secret, once. An account can hold 10 webhooks.

Parameters

account_idrequiredinteger · pathThe account

Request body

descriptionstring
eventsrequiredstring[] | nullThe event types to receive; see the event list
urlrequiredstringWhere events are sent: an https address on the public internet

Response · 201

created_atrequireddate-time
created_byrequiredstring
descriptionrequiredstring
eventsrequiredstring[] | null
failed_last_dayrequiredintegerDeliveries given up on in the last 24 hours
idrequiredinteger
last_delivered_atdate-timeThe last delivery the subscriber accepted; absent if there has been none
secretrequiredstringSigns every delivery. Shown only in this response: store it now, it cannot be read again
urlrequiredstring
curl -X POST "https://nationcam.com/api/v1/accounts/{account_id}/webhooks" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/hooks/nationcam","events":["string"]}'

Delete a webhook

DELETE/api/v1/accounts/{account_id}/webhooks/{webhook_id}

write:webhookstool: delete_account_webhook

Stops deliveries at once, including ones waiting to be retried.

Parameters

account_idrequiredinteger · pathThe account
webhook_idrequiredinteger · pathThe webhook

Answers 204 with no body.

curl -X DELETE "https://nationcam.com/api/v1/accounts/{account_id}/webhooks/{webhook_id}" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

List a webhook's recent deliveries

GET/api/v1/accounts/{account_id}/webhooks/{webhook_id}/deliveries

read:webhookstool: list_webhook_deliveries

The last 50, newest first, with what the subscriber answered. Finished deliveries are kept for a week.

Parameters

account_idrequiredinteger · pathThe account
webhook_idrequiredinteger · pathThe webhook

Response · 200

datarequiredobject[] | null
data[].attemptsrequiredinteger
data[].created_atrequireddate-time
data[].delivered_atdate-time
data[].eventrequiredstring
data[].idrequiredinteger
data[].last_errorstring
data[].last_statusintegerThe HTTP status the subscriber last answered
data[].next_attempt_atdate-timeWhen a pending delivery is tried next
data[].statusrequired"pending" | "delivered" | "failed"pending: not accepted yet, will be tried (again). failed: given up on after six tries
curl "https://nationcam.com/api/v1/accounts/{account_id}/webhooks/{webhook_id}/deliveries" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

Send a test event to a webhook

POST/api/v1/accounts/{account_id}/webhooks/{webhook_id}/test

write:webhookstool: test_account_webhook

Queues a webhook.test event for this webhook, whatever it subscribed to. It is delivered within a few seconds; the delivery list shows what the subscriber answered.

Parameters

account_idrequiredinteger · pathThe account
webhook_idrequiredinteger · pathThe webhook

Response · 202

queuedrequiredbooleanA webhook.test event was queued; see the delivery list for the outcome
curl -X POST "https://nationcam.com/api/v1/accounts/{account_id}/webhooks/{webhook_id}/test" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"

List the events a webhook can receive

GET/api/v1/webhook-events

any credentialtool: list_webhook_events

Every delivery is a POST with a JSON body {id, type, created_at, account_id, data}. It carries NationCam-Event, NationCam-Delivery and NationCam-Signature: t=<unix seconds>,v1=<hex>, where the hex is HMAC-SHA256, keyed with the webhook's secret, of <t>.<body>. Answer 2xx within 10 seconds to accept it; anything else is retried after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours, then given up on. Events are sent for changes made through this API.

Response · 200

datarequiredobject[] | null
data[].descriptionrequiredstring
data[].typerequiredstring
curl "https://nationcam.com/api/v1/webhook-events" \
  -H "Authorization: Bearer $NATIONCAM_TOKEN"