Skip to content

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.

  • 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, or all:read.
  1. 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>"
  2. List the sites. -i prints 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, state and time_zone. A 401 means the token is wrong, a 403 that it lacks sites:read.

  3. Read the pagination headers. Every listing returns at most per_page records, 10 by default:

    X-Total: 3
    X-Total-Pages: 1
    X-Per-Page: 10
    X-Page: 1
    X-Next-Page:
    X-Prev-Page:
    X-Offset: 0

    An empty X-Next-Page means there are no further pages. See Pagination.

  4. Filter the list. Conditions go into the q parameter. 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"

    -G puts the parameters into the query string, --data-urlencode encodes the values, and -g stops curl from reading the square brackets as a pattern. See Filtering, searching and sorting.

  5. Fetch one site by the id from the list:

    Terminal window
    curl "$SEDISTO_HOST/api/rest/v1/sites/<site id>" \
    -H "Authorization: Bearer $SEDISTO_TOKEN"

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.