API Movimatica

SUMMARY

Movimatica API will let you interact with our system in many different ways:

  • you can request, send and modify data about activities, vehicles and all the other things your account has access to
  • you can interact with vehicles and their features, for example engine lock and telemetry data collection
  • you can download the periodical reports we generate and upload your own activities by sending their data as a JSON object

This is just a brief list of the available features, click here for the complete documentation.

HOW TO ACCESS IT

To access the API you only need a Movimatica account and its credentials; to put it simply, if you can login at Movimatica.com you are ready to go.
The first step is to login using the API to get the token required for every other operation.
You have to send a login request with your credentials like this (note: the following example uses JavaScript and jQuery, it’s not mandatory to use them):

$.ajax({
  type: 'GET',
  url: 'https://api.movimatica.com/rest2/user/login',
  data: {username: your_username, password: your_password},
  success: function(answer) {
    var your_token = answer.token;
  }
});

Explanation: this is an example of login request, if it is successful it returns an object (answer) containing the token (answer.token).

HOW TO USE IT

Once you have the token you have to include it in the requests like this (note: the following example uses JavaScript and jQuery, it’s not mandatory to use them):

$.ajax({
  type: 'GET',
  url: 'https://api.movimatica.com/rest2/user/logout',
  headers: {
    'Authorization': 'Bearer ' + your_token
  },
  success: function(answer) {
    . . .
  }
});

The token (your_token) is included in the request headers and preceded by ‘Authorization’: ‘Bearer ‘.
That’s it, all the non-login requests will follow this syntax and return data that can be used by the users as they want.

ABOUT THE TOKEN

The token expires after some time and you will have to login again to get a new one.
If the token is not expired you don’t have to login as the system recognizes an user by the token assigned to it.
An easy way to check if the token is still valid is to make a request to “/user/me” and look for the response code, if it’s 200 the token it’s still valid, if it’s 401 the token is expired.