Using curl
While Swagger UI provides a visual interface into the API, it is often desirable to send API calls via the command line. For this, curl can be used.
Required information
To send a curl request to the API, two things are required:
An API key
The curl command string
Obtaining an API key
If an API key is not already available from previous API usage, the following steps should be followed.
Log into the planet console using a Reblaze account (i.e., not using SSO). The account must have an Access Level of Editor or higher.
Navigate to Account by selecting the user icon on the top right of the page
Navigate to Account Details -> API Keys. (If Account Details is not displayed in the Account menu, verify that the login was done directly into the planet using a Reblaze account. If SSO is used, Account Details will not be available in the interface.)
Select "New" -> Enter a name for the key -> "Confirm"
Copy the value of that key for use within curl. (Note: this is the string that the system generated, not the name you supplied.)
Using Swagger UI to construct the curl command string
Sending an API request via Swagger UI will also construct and display its curl command string:
Navigate to the planet's instance of Swagger UI.
Expand the desired namespace, and then the desired route within the namespace.
Select the "Try it Now" button
Edit the input fields (if any), providing all required inputs
Select the "Execute" button
After sending the request, Swagger UI will display the curl command string. Copy this.
To send this request using curl, edit the command string to include an additional header (Authorization:Basic
) for the API key obtained earlier.
Example
When Swagger UI is used to get a list of configurations via GET /api/v4/conf/configs
, it will also display this curl command:
To submit this command directly via curl, the following header must be added:
...without the <>
, and where api-key-obtained-earlier
is the string obtained above.
Manually constructing the curl command string
API calls using curl are constructed according to these requirements:
The API key is included, as explained above
Input parameters defined as query are encoded into the URL
Input parameters defined as header are included as headers
Input parameters defined as Request body are included via curl's
-d
option
Example: query and header parameters
A route to retrieve traffic data has this definition:
Note that limit
, offset
, filters
, and debug
are marked as query parameters, and therefore, will be encoded into the URL. However, syntax
and provider
are marked as header parameters.
The resulting curl command will look like this:
Example: request body
The POST /api/v4.0/data/timeline/parse call includes this input:
Let's say that an admin wants to submit the string timestamp between 2024-06-06 09:31:00 and 2024-06-06 09:36:00, status=301
. The curl command would look like this:
Last updated