Connect to Enthusiast’s API
Once you have the API token for a service account, you can connect to Enthusiast’s API.
Trying out the API Using Swagger UI
Authorization
- In the main sidebar, click API Documentation. Swagger UI will open in a new tab.
- In Swagger UI, click Authorize in the top-right corner.
- Enter
Token <API_TOKEN>
in the authorization field and click Authorize.
:::success You can now interact with the API. Let’s query some data. :::
Navigating the Endpoints
The Swagger UI lists all available endpoints organized by functionality. You can test an endpoint directly from your browser using the Try it out feature.
Example: Retrieving Data Sets with GET /api/data_sets
- Find the
GET /api/data_sets
endpoint in the list. - Expand the endpoint by clicking on it.
- Click Try it out.
- Click Execute to send the request.
Using curl
To authenticate with Enthusiast’s API using curl
from the terminal, include the API token in the header of each request:
-
GET and DELETE Request:
curl -X 'GET/DELETE' \ 'http://localhost:8000/api/<PATH>' \ -H 'accept: application/json' \ -H 'Authorization: Token <API_TOKEN>'
-
POST, PUT and PATCH Request:
curl -X 'POST/PUT/PATCH' \ 'http://localhost:8000/api/<PATH>' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -H 'Authorization: Token <API_TOKEN>' \ -d '{ "key": "value" }'
:::info
Replace <API_TOKEN>
with your actual API token and <PATH>>
with the specific API endpoint.
:::
Example curl
command:
curl -X 'GET' \
'http://localhost:8000/api/data_sets' \
-H 'accept: application/json' \
-H 'Authorization: Token <API_TOKEN>'
Last updated on