TraX offers a web API designed on REST principles. For details on how the API functions and its development, refer to:
- TraX API reference - OpenAPI document detailing operations, server URLs, etc.
- TraX API release log - Chronologically ordered list of notable changes for each release of API.
Autentication & Authorization
Authentication and authorization are handled using the OAuth Resource Owner Password Credentials Grant flow part of the OAuth 2.0 Authorization Framework RFC.
The OAuth Resource Owner Password Credentials Grant Flow
In summary, the OAuth Resource Owner Password Credentials Grant flow involves obtaining an access token by submitting account credentials to a token endpoint. This access token must then be used for all future API requests.
When the request is successful, the response payload will appear as follows:
{ "access_token": "", "token_type": "bearer", "expires_in": 3599 }
The access_token
attribute holds the access token, and the expires_in
attribute shows how long the access token is valid. When the access token has expired, a new one must be requested.
RECOMMENDED: Make the TraX API client code request a new access token at activation, and use the
expires_in
attribute divided by two (2) to schedule the request of a new access token to ensure a valid access token is always available.
Credentials needed for API access will be provided during the initial stages of the onboarding process.
Obtain an Access Token
To retrieve an access token, construct a request like this:
- Request header
content-type: application/x-www-form-urlencoded
- Request operation:
POST [TraX web API token endpoint]/oauth/token
- Request payload:
grant_type=password& client_id=<Client id>& client_secret=<Client secret>& username=<Client username>& password=<Client password>
Using the Access Token for API Requests
The Authorization
header must be included in all API calls. Here's an API call example that receives a list of vehicles from the TraX vehicle store:
- Request header:
Authorization: Bearer [your access token]
- Request operation:
GET [TraX web API server URL]/trax/fleets/{fleetId}/vehicles
- Response payload example:
{ "vehicles": [ { "vehicleId": "740f410b-7f37-4dbc-9cc5-f7c160005dc7", "vin": "C25HA5R6LO5T2TE", "vehicleName": "SPACE TRUCK 8459", "brand": "Volvo", "model": "VHD 300 AF" } ] }
Remember to change the fleetId
in the URL to a fleet ID that has been onboarded to the SKF platform.
Comments
0 comments
Article is closed for comments.