Skip to main content

Getting started with the REST API

Let's walk through core API concepts as we tackle some every day use cases. You will first need to generate an API key.

Overview

We are curing to use cURL. If you are using an alternative client, ensure that you are able to send the required User Agent header in each request.

Hello, World! :D

Generate an API key and let's get started by testing our setup.

$ curl -H "x-nabis-access-token: <access-token>" \
https://platform-api.nabis.pro/v2/nabis-days-off
>
> [
> {
> "date":"2022-01-01",
> "description":"This year's New Years Day"
> },
> ...
> ]%

Let's add the -i flag to include headers:

$ curl -i -H "x-nabis-access-token: <access-token>" \
https://platform-api.nabis.pro/v2/nabis-days-off

> HTTP/1.1 200 OK
> Date: Sun, 07 Aug 2022 11:15:14 GMT
> Content-Type: application/json; charset=utf-8
> Content-Length: 517
> Connection: keep-alive
> X-Frame-Options: SAMEORIGIN
> X-Permitted-Cross-Domain-Policies: none
> Referrer-Policy: no-referrer
> Access-Control-Allow-Origin: *
> ETag: W/"205-tARba5EOhSEMX2NJJ33BWs9hg5I"
>
> [{
> "date":"2022-01-01",
> "description":"This year's New Years Day"
> }, ...]%

There are some interesting bits in the response. As we expected, the Content-Type is application/json.

Headers beginning with X- are custom headers and are not included in the HTTP spec. For example, this API leverages the header x-nabis-access-token for authentication.

Making a call

To get a list of orders for your organization, call GET /orders, but remember /orders is paginated so we will receive a paginated response body with additional data about our request so we know how many calls to make in order to fetch all of the data we want.

Keep in mind that both limit and page are required query parameters for /orders. If we don't supply both with our query, we will be returned a 400 error - Bad request exception.

Get the first page, page 0

$ curl -H "x-nabis-access-token: <access-token>" \
https://platform-api.nabis.pro/v2/orders?page=0&limit=100
>
> {
> "data": [{
> "id": "544e23bc-563e-402a-8b43-126656377d89", ...
> }],
> "page": 1,
> "totalCount" 1152,
> "totalNumPages": 11,
> "nextPage": 2,
> "prevPage": 0
> }%

Get the second page, page 1

$ curl -H "x-nabis-access-token: <access-token>" \
https://platform-api.nabis.pro/v2/orders?page=1&limit=100
>
> {
> "data": [{
> "id": "70e2be90-1662-49ab-85b3-8c92499c55ef", ...
> }],
> "page": 1,
> "totalCount" 1152,
> "totalNumPages": 11,
> "nextPage": 2,
> "prevPage": 0
> }%

Get the last page, page 11

$ curl -H "x-nabis-access-token: <access-token>" \
https://platform-api.nabis.pro/v2/orders?page=11&limit=100
>
> {
> "data": [{
> "id": "350bb797-a976-4f01-962d-63da5d41a50e", ...
> }],
> "page": 11,
> "totalCount" 1152,
> "totalNumPages": 11,
> "nextPage": null,
> "prevPage": 10
> }%

Next Steps

Be sure to check out the documentation on Date and Times along with Pagination. Or, just jump straight into the API Reference.