Nodegrid enables using different methods for API authentication, they are: ticket, username, and API key. In this guide you will learn how to create an API account and how to query information using the API.
Adding the API account from GUI
1. Login to your Nodegrid GUI device as admin
2. Navigate to Security :: Local Accounts and click Add
3. Define the name of the API user
4. In Account Type, select API account
5. Optional - Define the Account Expiration Date
6. Select the privilege group for the API user.
Note: Copy and store the API Key as it will not be possible to recover it after clicking on Save button
7. Click Save
Retrive information using the API and the API account
You can check the available API options in the API documentation.
For this demonstration, I'm using "Get access table information".
As showed in the image, you can use ticket, username and api_key parameters. For api_key, I'm removing the "ticket:" information and adding "username": "test", "api_key": "GC9kdnyjPnPWCF+qG4KeTzJk3kgZpBTeaw==". The code should look like this for Python:
import requests
url = 'https://192.168.42.214/api/v1/access/table'
headers = {"username": "test", "api_key": "GC9kdnyjPnPWCF+qG4KeTzJk3kgZpBTeaw==", "Content-Type": "application/json", "accept": "application/json"}
response = requests.get(url, headers=headers, verify=False)
print("Response Status Code: ", response.status_code)
print("Response: ", response.text)
Note that you must add the address of your device in URL and the path to the API.
An example using Curl example: