API Currently, your Console can only have a single API key (auth_token). Managing this key, as well as enabling and disabling the use of the API can be done using the following endpoints.
Add an API token TIP
This will generate a new API token for you, overwriting the existing token if there is one.
POST /api/v1/token/add
Create a new API token.
Show details
Required Parameters auth_token string
A valid auth token
Response JSON structure with the new API token.
Example curl https://EXAMPLE.canary.tools/api/v1/token/add \
-d auth_token = EXAMPLE_AUTH_TOKEN
1 2
import requests
url = 'https://EXAMPLE.canary.tools/api/v1/token/add'
payload = {
'auth_token' : 'EXAMPLE_AUTH_TOKEN'
}
r = requests. post( url, data= payload)
print ( r. json( ) )
1 2 3 4 5 6 7 8 9 10 11
{
"result" : "success" ,
"token" : "<auth_token>"
}
1 2 3 4
Delete the API Token DELETE /api/v1/token/remove
Delete the existing API token.
Show details
Required Parameters auth_token string
A valid auth token
Response A JSON structure with result indicator.
Example curl -X DELETE https://EXAMPLE.canary.tools/api/v1/token/remove \
-d auth_token = EXAMPLE_AUTH_TOKEN
1 2
import requests
url = 'https://EXAMPLE.canary.tools/api/v1/token/remove'
payload = {
'auth_token' : 'EXAMPLE_AUTH_TOKEN'
}
r = requests. delete( url, data= payload)
print ( r. json( ) )
1 2 3 4 5 6 7 8 9 10 11
{
"result" : "success"
}
1 2 3
Disable the API POST /api/v1/settings/api/disable
Disable the Console API.
Show details
Required Parameters auth_token string
A valid auth token
Response JSON structure with result indicator.
Example curl https://EXAMPLE.canary.tools/api/v1/settings/api/disable \
-d auth_token = EXAMPLE_AUTH_TOKEN
1 2
import requests
url = 'https://EXAMPLE.canary.tools/api/v1/settings/api/disable'
payload = {
'auth_token' : 'EXAMPLE_AUTH_TOKEN'
}
r = requests. post( url, data= payload)
print ( r. json( ) )
1 2 3 4 5 6 7 8 9 10 11
{
"result" : "success"
}
1 2 3
Download the API Configuration File GET /api/v1/token/download
Download an API token configuration file for use by the Python API.
Show details
Required Parameters auth_token string
A valid auth token
Response File containing the API configuration.
Example curl https://EXAMPLE.canary.tools/api/v1/token/download \
-d auth_token = EXAMPLE_AUTH_TOKEN \
-G -O -J
1 2 3
import requests
import re
url = 'https://EXAMPLE.canary.tools/api/v1/token/download'
payload = {
'auth_token' : 'EXAMPLE_AUTH_TOKEN'
}
r = requests. get( url, params= payload)
filename = re. findall( "filename=(.+)" , r. headers[ "Content-Disposition" ] ) [ 0 ]
with open ( filename, 'wb' ) as f:
f. write( r. content)
print ( r. json( ) )
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
{
"result" : "success"
}
1 2 3
Enable the API TIP
Since we currently only allow for a single API key, this can only be achieved by logging into the Console and enabling the setting from your Global Settings page.
POST /api/v1/settings/api/enable
Enable the Console API.
Show details
Required Parameters auth_token string
A valid auth token
Response JSON structure with result indicator.
Example curl https://EXAMPLE.canary.tools/api/v1/settings/api/enable \
-d auth_token = EXAMPLE_AUTH_TOKEN
1 2
import requests
url = 'https://EXAMPLE.canary.tools/api/v1/settings/api/enable'
payload = {
'auth_token' : 'EXAMPLE_AUTH_TOKEN'
}
r = requests. post( url, data= payload)
print ( r. json( ) )
1 2 3 4 5 6 7 8 9 10 11
{
"result" : "success"
}
1 2 3
Last Updated: 10/23/2021, 8:58:50 PM