This is an overview of how you can use the AMM API.
Before proceeding with using the AMM API, it is highly recommended that the AMM is upgraded to 2.17.5+, so that all the developed API features are available. If you are using an AMM version previous to 2.17.5, please review the release notes as to any API feature exceptions.
The AMM API provides a powerful and flexible interface between deployed devices and AMM. It enables you to develop custom applications tailored to your business needs, whether for smartphones, CRM systems, ERP platforms, or other domains.
For example, you can use the API to:
The steps to use the AMM API are as follows:
Start by installing a REST Client. The two supported tools are :
When using HTTPS, it is recommended to use a valid CA-signed certificate with a complete certificate chain. Otherwise, the connection may result in errors or require the use of the -k option in curl (or equivalent) to avoid exceptions, which can expose you to security risks. In Postman, you can disable self signed errors.
In order to be able to define an API client, an end user must be created with select Develop privileges defined under Tabs:
This end user should be created with the least amount of privileges.
The following permissions should not be granted to end users, as they are administrative actions that can affect the performance of the AMM.
- Develop > API Group Usage Control
- Develop > API User Access Control
Refer to Creating an AMM user for more information.
Depending on the AMM version and features, certain special privileges are not included under the All tab and must be explicitly granted. As an admin, you can create a new user or modify an existing one to assign these permissions. To do this, uncheck the All checkbox for Tabs and manually grant the required permissions. Note that special permissions marked with a * prefix can only be granted by users who already have those specific permissions.
The API Client represents the identity of the application that needs to connect to the AMM API. All the API calls will be traced and related to an API Client. To create an API client :
The AMM will generate a unique client ID and secret key for this client. These credentials are required for authentication.
For more information on creating an API Client, refer to API Client.
The AMM implements rate limits to manage API usage and prevent resource exhaustion. Recommended API configuration is as follows:
Configuration | Value |
Request Timeout | Leave it at default 300 seconds |
System Wide Rate Limit | Leave it at default 10,000 requests/hour |
Owner Group Rate Limit | Leave it at default 360 requests/hour |
Number of Clients | Maximum 20 |
API Client(s) per Owner Group | 1 |
Near realtime or frequent polling intervals may be difficult to implement for large fleets. Setting the polling interval to 5,10 or 30 minutes for each gateway or group is advisable.
For more information on adjusting rate limits, refer to API Group Usage Control.
To integrate to AMM APIs, you will first need to authenticate. This requires:
User credentials are not sent in plain text. By default, all API communication to the AMM server uses HTTPS. It is not recommended to use HTTP.
AMM uses the OAuth 2.0 protocol for authentication. AMM supports three ways of getting an access token. Select the flow that best suits your application:
You can find more details about how authentication works as well as sample API calls in this AMM API documentation section .
Specs: rfc6749
The method depends on which Oauth flow method your application uses. Following examples use Resource Owner Flow:
This is how it looks in Postman:
curl -X POST \
https://<AMM IP address>/api/oauth/token \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Authorization: Basic <Base64 encoded client_id:client_secret>' \
-d 'grant_type=password&username=<AMM API user name>&password=<AMM API user password>'
Replace <AMM IP address>, <Base64 encoded client_id:client_secret>, <AMM API user name>, and <AMM API user password> with the actual values.
A successful response will be in JSON format and include the access token.
Tokens are your own property and responsibility: Never share a token with anyone or between two applications. For example, don’t share it in a public source repository.
The client accesses protected resources in AMM by presenting the access token.
The method in which the client utilizes the access token to authenticate with the AMM involves using the HTTP “Authorization” request header field [RFC2617].
For example, replace {accessToken} by your access token in the Authorization header:
GET https://<AMM IP address>/api/v1/applications
Authorization: Bearer {accessToken}
Why you must not use a token as a parameter...
Another possibility is to send the access token in the HTTP request URI, where the client adds the access token to the request URI query component. However, its use is not recommended, due to its security deficiencies.
For example:
https://<AMM IP address>/api/v1/applications?access_token={accessToken}&name=myApplication
Because of the security weaknesses associated with the URI method, including the high likelihood that the URL containing the access token will be logged, it SHOULD NOT be used unless it is impossible to transport the access token in the “Authorization” request header field.
Once you have created the API Client and picked the most appropriate OAuth2 flow for your application, you can start calling AMM API using the language of your choice (Java, Javascript, Ruby, Python…).
AMM provides all the features in its API, making it really easy to integrate with your backend to automate your flows.
Have a look at the API & Examples page to find API Libraries in several languages to illustrate what will be described below.
First, you need to get your gateway information. One of the most important fields is the uid
which is used by the API to identify your gateway. The uid
is the gateway ESN. If you don’t know the uid, you can retrieve it using the following command:
> GET https://<AMM IP address>/api/v1/systems?heartbeat=1440&platforms=MG90,GX440,LX60,MP70
Using Postman:
Using curl:
curl -X GET -H 'Authorization: Bearer <access token>' \
'https://<AMM IP address>/api/v1/systems?heartbeat=14400&platforms=MG90,GX440,LX60,MP70' \
Copy the uid field for the specific gateway from the response below:
{
"All gateways": [{
"My MG90 devices": [
{
"uid": "ND6123999011020",
"name": "my MG90 A"
}, {
"uid": "ND90410999011035",
"name": "my MG90 B"
}]
}, {
"My ALEOS devices": [
{
"uid": "CA13999002410",
"name": "my GX440"
}, {
"uid": "WM80520999021016",
"name": "my LX60"
},{
"uid": "N655119991021018",
"name": "my MP70 A"
}, {
"uid": "N660940999011023",
"name": "my MP70 B"
}]
}, {
"uid": "ND90410999011039",
"name": "my unregistered MG90"
}
]
}
Once you can identify your gateway, you are ready to get data values from it.
To get the latest location and heartbeat information from a gateway:
> GET https://<AMM IP address>/api/v1/systems/<uid>/data?ids=ReportIdleTime,GPS Location-latitude,GPS Location-longitude
Using Postman:
Using curl:
curl -X GET -H 'Authorization: Bearer <access token>' \
'https://<AMM IP address>/api/v1/systems/<uid>/data?ids=ReportIdleTime,GPS Location-latitude,GPS Location-longitude' \
Below is an example of what you could see.
{
"ReportIdleTime": [{
"value": "2796808",
"timestamp": 1581500240000
}],
"GPS Location-latitude": [{
"value": "49.273376",
"timestamp": 1579136926000
}],
"GPS Location-longitude": [{
"value": "-123.103834",
"timestamp": 1579136926000
}]
}
The AMM API uses standard HTTP status codes to indicate the outcome of a request. Understanding these codes and their corresponding messages is essential for effective error handling in your applications.
For more details, see AMM API Error Handling
Now that you can get data from AMM, you can create charts, tables, show alerts in your custom application using the API. For more details, see AMM API Reference
Now you’re ready to go further and develop features such as:
Also take a look at the API Libraries & Examples to find more sample applications!