1. Home
  2. API
  3. Fleet Management API
  1. Home
  2. Fleet Management
  3. Fleet Management API

Fleet Management API

For this example I’m using Postman, however you are free to use any tool you are comfortable with. Download the collection file below to get started right away.

We have multiple environments, depending on where your solution is hosted you need one of the below endpoints:

EnvironmentEndpoint
staginghttps://fleetmanagement-api.staging.gpscockpit.net/
clust02 (Europe/USA)https://fleetmanagement-api-clust02.gpscockpit.com/
clust03 (KSA)https://fleetmanagement-api-clust03.gpscockpit.com/
clust04 (UAE)https://fleetmanagement-api-clust04.gpscockpit.com/
clust05 (OMN)https://fleetmanagement-api-clust05.gpscockpit.com/

Example 1: Authenticate using password

Get authenticated with username and password. The response will contain a token to be used for subsequent API calls.

Request

POST /api/authentication HTTP/1.1
Host: https://fleetmanagement-api.staging.gpscockpit.net

{
"username": "example@provider.com",
"password": "b44463cb1f9f55990d1ea866f928334785a64e4732b866261ef2e50ee3797c55",
"appName":"Something that what is using the API (ie. MyApp)",
"appVersion":"1.0"
}

The password needs to be SHA256 encoded.

Example password: “secret”
SHA256 hashed: 2bb80d537b1da3e38bd30361aa855686bde0eacd7162fef6a25fe97bf527a25b

There are several online tools do convert the password, for example:
http://hash.online-convert.com/sha256-generator

Response

{
    "token": "eyJhbGciOiJ...",
    "tokenExpires": "2022-10-04T12:26:41Z",
    ...
}

Example 2: Get assets

Retrieve a list of all of your assets.

Request

GET /api/asset HTTP/1.1
Host: https://fleetmanagement-api.staging.gpscockpit.net
Authorization: Bearer eyJhbGciOiJ...

Response

[
    {
        "id": 12345,
        "name": "ABC",
        "code": "ABC",
        "plateNumber": "ABC",
        "vehicleType": 0,
        "brand": "Mercedes",
        "model": "A",
        "color": "White",
        "isCommentWarning": false,
        "deviceId": 201460,
        "unitId": "358480083060170",
        "isActive": true,
        "isArchived": false
    }
]

Example 3: Get a single asset by ID

Retrieve a particular asset by ID.

Request

GET /api/asset/12345 HTTP/1.1
Host: https://fleetmanagement-api.staging.gpscockpit.net
Authorization: Bearer eyJhbGciOiJ...

Response

[
    {
        "id": 12345,
        "name": "ABC",
        "code": "123",
        "plateNumber": "AB-CD-EF",
        "vehicleType": 0,
        "brand": "Mercedes",
        "model": "A",
        "color": "White",
        "isCommentWarning": false,
        "deviceId": 201460,
        "unitId": "358480083060170",
        "isActive": true,
        "isArchived": false
    }
]

Example 4: Get a trips between certain date and time

Retrieve a list of trips for a particular asset by ID and start and end datetime. A trip starts when the ignition is turned on until the ignition is turned off.

DateTime can be passed as unix time / epoch date. Seconds since 1 january 1970.

Request

GET /api/trip?assetId=12345&start=0&end=1667762796 HTTP/1.1
Host: https://fleetmanagement-api.staging.gpscockpit.net
Authorization: Bearer eyJhbGciOiJ...

Response

[
  {
    "id": 0,
    "assetId": 12345,
    "deviceId": 0,
    "assetName": "string",
    "beginTS": "2022-11-06T19:22:19.567Z",
    "endTS": "2022-11-06T19:22:19.567Z",
    "beginLatitude": 0,
    "beginLongitude": 0,
    "endLatitude": 0,
    "endLongitude": 0,
    "beginCity": "string",
    "beginAddress": "string",
    "beginAddressFull": "string",
    "endCity": "string",
    "endAddress": "string",
    "endAddressFull": "string",
    "comment": "string",
    "segmentDistanceInKilometers": 0,
    "jsonLocationData": "string",
    "driver": "string",
    "tripMethod": 0,
    "tripType": 0,
    "kmPrivate": 0,
    "maxSpeed": 0,
    "driverName": "string",
    "driverId": 0,
    "isPrivate": true,
    "isHidden": true
  }
]

Example 5: Get distance travelled summary between certain date and time

Retrieve a summary of distance travelled particular asset (or device) by ID and start and end datetime.

Request

GET /api/trip/messagesummary?deviceid=0&assetId=12345&start=0&end=1667762796 HTTP/1.1
Host: https://fleetmanagement-api.staging.gpscockpit.net
Authorization: Bearer eyJhbGciOiJ...

Response

{
  "deviceId": 0,
  "assetId": 0,
  "distanceInKm": 0,
  "beginLatitude": 0,
  "beginLongitude": 0,
  "endLatitude": 0,
  "endLongitude": 0,
  "calibratedOdoValueBegin": 0,
  "calibratedOdoValueEnd": 0,
  "firstMessage": "2022-11-09T09:52:30.140Z",
  "lastMessage": "2022-11-09T09:52:30.140Z"
}

Example 6: Update asset properties

Update existing assets. It’s required to include all properties, including existing.

Request

PUT /api/asset/12345
HTTP/1.1
Host: https://fleetmanagement-api.staging.gpscockpit.net
Authorization: Bearer eyJhbGciOiJ...

{

  "driverId": 4021997,
  "assetId": 4022799,
  "startDate": 1313120000,
  "endDate": 1313130000
}

Response

{
  "id": 12345,
  "deviceId": 0,
  "name": "string",
  "assignmentStart": "2022-12-15T14:01:43.252Z",
  "assignmentEnd": "2022-12-15T14:01:43.252Z",
  "assetTypeId": 0,
  "code": "string",
  "plateNumber": "string",
  "year": "string",
  "vin": "string",
  "brand": "string",
  "model": "string",
  ...
}

Example 6: Assign driver to asset

Assign a driver to an asset for a period of time.

Request

PUT /api/asset/12345/assigndriver
HTTP/1.1
Host: https://fleetmanagement-api.staging.gpscockpit.net
Authorization: Bearer eyJhbGciOiJ...

{
  "driverId": 67890,
  "assetId": 12345,
  "startDate": 1675247937,
  "endDate": 1675247937
}

Response

{

    "isSuccess": true,

    "message": "Assignment was successful!",

    "id": 0,

    "errorItems": {},

    "errorCount": 0

}

API documentation

https://fleetmanagement-api.staging.gpscockpit.net/swagger

Updated on May 23, 2023

Article Attachments

Related Articles

Leave a Comment