In this lesson, you will learn:
- How to access the built-in API documentation.
- How to perform a Suzieq API request via the browser.
- How to perform a Suzieq API query via Python.
You can find the scripts and code for this lesson within the Suzieq repo under the directory: 003_suzieq_interaction_methods/002_restapi.
Intro to Suzieq’s REST API
In addition to being able to interact with Suzieq via the CLI, GUI or Python, Suzieq provides a REST-based API.
We can confirm the ports that we have configured Suzieq to use by performing a docker-compose ps suzieq_restserver
, like this:
❯ docker-compose ps suzieq_restserver
Name Command State Ports
-------------------------------------------------------------------------------------
suzieq_restserver sq-rest-server Up 0.0.0.0:8000->8000/tcp,:::8000->8000/tcp
Security
Encryption
For this course, the API is exposed using HTTP. When using the REST API in production, it is recommended to encrypt the server-side traffic from the client to Suzieq by using HTTPS and TLS. The configuration for this is outside the scope of this course.
Further details on how to secure the REST API can be found at: https://suzieq.readthedocs.io/en/latest/rest-server/
API Key
This course uses a default API key. Therefore, if you are using Suzieq in an environment outside of development or test, I would recommend generating your own API key. Further information on how to generate your own key can be found at: https://suzieq.readthedocs.io/en/latest/rest-server/#setup-api-key.