Basics

Zebrabase is fully driven by REST API so you can do any action without using the web interface. API is accessible on the URL <your domain>/api, e.g. demo.zebrabase.org/api. The domain part of the URL is omitted in the examples.

All examples in this documentation are shown in the format <method> <url> [optional DATA: data] or as a curl command (see next section).

Authentication

To communicate with API you have to obtain an access token first:

POST /api/auth/token DATA: {"username": "<username>", "password": "<password>"}

curl /api/auth/token -X POST -d '{"username": "<username>", "password": "<password>"}'

(If using Windows command prompt for curl commands, there may occur syntax problems with using single quotes (') in the statement. You can try to run the command as is in Git Bash, use the Microsoft WSL tool, or save the input data as an external JSON file and import it into the curl statement.)

Response: { "token": "<your access token>" }

You have to send this token in the headers of any further request: -H 'Authorization: Token <your token>', e.g. curl /api/substock/536 -H 'Authorization: Token <your token>'. This header is mandatory for all API requests so it is omitted in all examples.

In the current version, the access token does not expire. Token expiration may be added in the future, therefore, please, consider implementing some fallback solutions in your scripts.

Security

Your access token should be kept secret. It's not advisable to put it in the code and upload it to a public repository.

If you want to build your own script, please create a special user for it (user type: machine) and make sure to grant it just the permissions it will need. Create a separate permission group if necessary.

Excel spreadsheet

You can use this Excel spreadsheet for accessing and downloading certain lists (substocks, fishlines, ...) from your database instance. It works based on APIs, i.e. you will need to input your credentials and generate a token to be able to access the data.