iNode API
The iNode API allows you to programmatically access your traffic data, devices, and links. This page covers everything you need to get started - from authenticating your requests to running full API examples in multiple languages. Whether you're integrating iNode into an existing system or building a custom workflow, the sections below will walk you through the setup step by step.
Authentication
iNode supports two authentication methods: OAuth2 and API Key. Choose the method that best fits your setup. OAuth2 is recommended for applications that need token refresh capabilities, while the API Key method is simpler and ideal for quick integrations.
OAuth2
To use OAuth2, contact the SMATS support team to receive your client_id and client_secret, which will be linked to your account.
Once you have those credentials, you can use your company owner account's username and password alongside the client_id and client_secret to retrieve an access token.
Examples
cURL
Python
Build the authentication body as shown below. Note that the content-type must be set to application/x-www-form-urlencoded.
auth_body = {
'grant_type': 'password',
'username': USERNAME,
'password': PASSWORD,
'client_id': CLIENT_ID,
'client_secret': CLIENT_SECRET,
'scope': 'sync'
}auth_response = requests.post("https://inode.smatstraffic.com/api/oauth/token/", data=auth_body)
auth_response_json = auth_response.json()
access_token = auth_response_json['access_token']
refresh_token = auth_response_json['refresh_token']API Key
The API Key method is the simplest way to access the iNode API. To retrieve your key, navigate to Settings > My Profile > API Access in the iNode dashboard and copy the key shown there.
Important Note
Only iNode users with the Owner role can access the API Key from the dashboard.
Once you have your API Key, include it in the Authorization header of every request you send to the iNode API, as shown in the examples below.
Examples
The examples below are making a get request to the iNode v1 endpoint for retrieving the links.
cURL
curl 'https://inode.smatstraffic.com/api/v1/links/' -H 'Authorization: Token xxxxxxxxxxxxxxxxxxxxxxxx'
Python
import requests
headers = {
'Authorization': 'Token xxxxxxxxxxxxxxxxxxxxxxxxxxx'
}
response = requests.get('https://inode.smatstraffic.com/api/v1/links/', headers=headers)PHP
GO
req, err := http.NewRequest("GET", "https://inode.smatstraffic.com/api/v1/links/", nil)
if err != nil {
// handle err
}
req.Header.Set("Authorization", "Token xxxxxxxxxxxxxxxxxxxxxxxx")
resp, err := http.DefaultClient.Do(req)
if err != nil {
// handle err
}
defer resp.Body.Close()API example
The following Python examples show how to make authenticated API calls to retrieve your links and devices. Two versions are provided - one for each authentication method. Both examples retrieve the full list of links and devices every minute in a loop.
OAuth2 Authentication
Use this example if you authenticated using the OAuth2 method. This includes logic for refreshing your access token automatically when it expires (after 5 days).
Start by defining your credentials and endpoint URLs:
Python
Important Note
The content-type must be application/x-www-form-urlencoded.
Next, authenticate and store your tokens. The get_new_token function handles refreshing when the access token expires:
With authentication set up, the loop below retrieves your links and devices every 60 seconds. If the token has expired (401 response), it automatically refreshes before continuing:
API Key Authentication
If you've retrieved your API Key from iNode > Settings > Profile > API Access (Owner only), use the following example instead. This approach is simpler - no token management is required.
Set up your endpoint URLs and include your API Key in the header:
Python
import requestsBASE_URL = "https://inode.smatstraffic.com/api/"
AUTH_URL = BASE_URL + "oauth/token/"
V1_URL = BASE_URL + "v1/"
LINKS_URL = V1_URL + "links/"
DEVICES_URL = V1_URL + "devices/"
API_ACCESS_KEY = '<---api key retrieved from iNode profile page of the owner--->'
header = {
'Authorization': 'Token %s' % API_ACCESS_KEY
}Then run the loop to retrieve your links and devices every 60 seconds:
Swagger documentation
iNode's full API reference is available through the Swagger documentation. You can access it here.
Important Note
You must be logged into iNode to access the Swagger documentation.