Skip to content

REST API

Nanitor offers a REST API on top of its application. To be able to use the REST API you will need an API key. Additionally, make sure the API service on the Nanitor server is up and running (systemctl status nanitor-system-api.service).

The instructions below explain how you can retrieve an API key to leverage the Nanitor API and will give a basic functional example with a troubleshooting section in case the API call returns an unexpected error.

Obtaining an API Key

Using the REST API needs an API Key that can be obtained from a Nanitor administrator. From the Organization Management menu, select API Keys:

API Key

Create a new API key by clicking the Create API Key button on the top right:

Create API Key

Give the API Key a descriptive name. You can choose between a key with read-only access or a key with both read and write access.

API Key Name and permissions

Now you need to copy the API key and keep it in a safe place since it can't be revealed again! If you lose it you need to delete it and create a new one.

API Key revealed

Deleting an API Key

In the list of API keys go to the API key that you need to remove. In the Actions column select Delete from the dots menu.

Delete API Key Confirm the delete action by typing delete in the confirmation field.

Deletion confirmation

Basic usage of the REST API

After having retrieved an API key you are now able to use the API. The basic endpoint for any API endpoint is https://<yournanitorinstnce>/system_api followed by the actual endpoint as listed in the documentation at https://api-docs.nanitor.com/

A valid REST API call needs to include the API token inside the header of the request (e.g. -header 'Authorization: Bearer {yourapikey}') and the REST API endpoint (e.g. /assets)). To simply pull a list of all assets using the curl command line tool, you would do:

curl  --request GET 'https://<yournanitorinstnce>/system_api/assets/  -header 'Authorization: Bearer <yourapikey>'

Available REST endpoints

All available REST API endpoints are documented in the Nanitor REST API documentation:

https://api-docs.nanitor.com/

Troubleshooting

When you receive a 5xx error it might be possible that the API service is not enabled and/or not running. Log into the console of the Nanitor server and run these commands as a root user:

systemctl enable nanitor-system-api.service
systemctl start nanitor-system-api.service