REST API
Your first request
This guide takes you from a token to your first successful call to the REST API: listing the sites of an installation with curl, reading the pagination headers, and narrowing the list with a filter.
Before you start
Section titled “Before you start”- The operator has created an integration for you in the portal under Apps and given you its API key and the installation’s hostname. See Authentication and permissions.
- The integration holds
sites:read, orall:read.
-
Put the hostname and the token into shell variables. Use the hostname exactly as the operator gave it to you.
Terminal window export SEDISTO_HOST="https://acme.sedisto.eu"export SEDISTO_TOKEN="<your token>" -
List the sites.
-iprints the response headers as well.Terminal window curl -i "$SEDISTO_HOST/api/rest/v1/sites" \-H "Authorization: Bearer $SEDISTO_TOKEN"The body is a JSON array of sites, each with its
id,name,stateandtime_zone. A401means the token is wrong, a403that it lackssites:read. -
Read the pagination headers. Every listing returns at most
per_pagerecords, 10 by default:X-Total: 3X-Total-Pages: 1X-Per-Page: 10X-Page: 1X-Next-Page:X-Prev-Page:X-Offset: 0An empty
X-Next-Pagemeans there are no further pages. See Pagination. -
Filter the list. Conditions go into the
qparameter. This request returns only active sites whose name contains “Berlin”:Terminal window curl -g -G "$SEDISTO_HOST/api/rest/v1/sites" \-H "Authorization: Bearer $SEDISTO_TOKEN" \--data-urlencode "q[state_eq]=active" \--data-urlencode "q[name_cont]=Berlin"-Gputs the parameters into the query string,--data-urlencodeencodes the values, and-gstopscurlfrom reading the square brackets as a pattern. See Filtering, searching and sorting. -
Fetch one site by the
idfrom the list:Terminal window curl "$SEDISTO_HOST/api/rest/v1/sites/<site id>" \-H "Authorization: Bearer $SEDISTO_TOKEN"
Next steps
Section titled “Next steps”To explore further without writing curl commands, install sedisto-cli and configure it with the same hostname and token. See Using sedisto-cli. To build an integration, continue with Syncing bookings to sedisto.