1

API to Pull Event and Trip Data

Topic: API to Pull Event and Trip Data

Hello Team,

Based on the previous email communication with Tim Scherbakov and : John Grygorcewicz (Phoenix)  we are trying to pull the data for Event and Trip by using the below API call and we are using new token to get the data but seems we are getting error code (Attached Screenshot)

Event:

API Call : https://hst-api.wialon.com/wialon/ajax.html?sid={}&svc=unit/get_drive_rank_settings&params={"itemId":717361}

Reference used for API Call :https://sdk.wialon.com/wiki/en/sidebar/remoteapi/apiref/unit/get_drive_rank_settings

Trip:

API Call : https://hst-api.wialon.com/wialon/ajax.html?sid={}&svc=unit/get_trips&params={"itemId":717361}

Reference used for API Call : https://sdk.wialon.com/wiki/en/sidebar/ … /get_trips

2

API to Pull Event and Trip Data

Re: API to Pull Event and Trip Data

Hello All,

1. Which account do you use to pull the data via API?

- Driver

What kind of drivers do you need?

- We need the list of all driver who are active and inactive in the system.We will be using this as master data to again connect with trip and event.

1. Do you need to pull the list of drivers created in the system?  ---- Yes
2. Do you need to pull the currently assigned driver? ---- Yes
3. Do you need to pull history data driver to know the driver who was driving the vehicle and made violations some time ago? ---- Yes

- Fleet

1. Do you need to pull the list of fleets (unit groups) created in the system? ---- Yes we are looking for the Fleet data (Group of Vehicle)
2. If not, could you please let us know your business case?

- Vehicle

1. Do you need to pull the list of vehicles created in the system? ---- Yes
2. Do you need to pull live location of vehicles? ---- We dont need to live location of vehicle.But yes we need location log record information for trip and event.
3. What kind of data do you need to pull?
- We need the list of all Vehicle in the system.We will be using this as master data to again connect with trip and event.

- Trip

1. Do you need history trips? ---- Yes We need history and on going trip data

- Event

1. What kind of events do you need?
- We are looking for event such as Speeding,Harsh Braking,Harsh Cornering etc basically to understand the driving behaviour and when did it happned.
2. Do you mean harsh driver behavior events? -- Yes

3

API to Pull Event and Trip Data

Re: API to Pull Event and Trip Data

Jayateerth.Sullad wrote:

Hello Team,

Based on the previous email communication with Tim Scherbakov and : John Grygorcewicz (Phoenix)  we are trying to pull the data for Event and Trip by using the below API call and we are using new token to get the data but seems we are getting error code (Attached Screenshot)

Event:

API Call : https://hst-api.wialon.com/wialon/ajax.html?sid={}&svc=unit/get_drive_rank_settings&params={"itemId":717361}

Reference used for API Call :https://sdk.wialon.com/wiki/en/sidebar/remoteapi/apiref/unit/get_drive_rank_settings

Trip:

API Call : https://hst-api.wialon.com/wialon/ajax.html?sid={}&svc=unit/get_trips&params={"itemId":717361}

Reference used for API Call : https://sdk.wialon.com/wiki/en/sidebar/ … /get_trips

Hello !
Unfortunately, there is not attached the screenshot.
Could you please specify about error

Diana Cheley
Wialon Hosting Expert
Gurtam
4

API to Pull Event and Trip Data

Re: API to Pull Event and Trip Data

The error is from the token side or from your API call?

Phoenix Solusi
Mobile Visible Secure
Specialists in data acquisition and analysis for mobile and fixed assets. Integration in to content management systems is a specialty we have.
5

API to Pull Event and Trip Data

Re: API to Pull Event and Trip Data

Hello All,

Reposting again with below question and answers


- Driver

What kind of drivers do you need?

- We need the list of all driver who are active and inactive in the system.We will be using this as master data to again connect with trip and event.

1. Do you need to pull the list of drivers created in the system?  ---- Yes
2. Do you need to pull the currently assigned driver? ---- Yes
3. Do you need to pull history data driver to know the driver who was driving the vehicle and made violations some time ago? ---- Yes

- Fleet

1. Do you need to pull the list of fleets (unit groups) created in the system? ---- Yes we are looking for the Fleet data (Group of Vehicle)
2. If not, could you please let us know your business case?

- Vehicle

1. Do you need to pull the list of vehicles created in the system? ---- Yes
2. Do you need to pull live location of vehicles? ---- We dont need to live location of vehicle.But yes we need location log record information for trip and event.
3. What kind of data do you need to pull?
- We need the list of all Vehicle in the system.We will be using this as master data to again connect with trip and event.

- Trip

1. Do you need history trips? ---- Yes We need history and on going trip data

- Event

1. What kind of events do you need?
- We are looking for event such as Speeding,Harsh Braking,Harsh Cornering etc basically to understand the driving behaviour and when did it happned.
2. Do you mean harsh driver behavior events? -- Yes

6

API to Pull Event and Trip Data

Re: API to Pull Event and Trip Data

Hello!

1. To get list of created items in system, like units, unit's groups, drivers and etc , it needs to execute request core/search_items
just to specify required items or sub-items types.
More information you can find here in video and several examples

2.To get history of drivers assignment for certain unit or all unit - request resource/get_driver_bindings

3. To get currently assigned driver(s) to unit - https://sdk.wialon.com/wiki/en/sidebar/ … it_drivers

4. To get history of trips - several ways :
1) via events special algorithm (the same is used in Wialon  mobile app) - https://sdk.wialon.com/wiki/en/sidebar/ … nts/events
More information how to use these kinds of request here
2) via report with table Trips, which already created in system
Please look example how to execute report -  https://sdk.wialon.com/wiki/en/sidebar/ … es/reports
3) via track layer with parameter "tripDetector":1 render/create_messages_layer

5. The events which dedicated to Eco driving functional can be get from particular report.
You need to create report with table  Eco Driving and then execute report via API the same as get trips (p . 4 - 2)

Diana Cheley
Wialon Hosting Expert
Gurtam
7

API to Pull Event and Trip Data

Re: API to Pull Event and Trip Data

Hello Dina,

Thank you for your response.

We are getting error while trying to fetch the Event and Trip data(attached screenshot)

Below is the API call what we are using

Event
=======
https://hst-api.wialon.com/wialon/ajax.html?sid=02a936db90d4d0cf023ab6e6988290c0&svc=unit/get_drive_rank_settings&params={"itemId":18759541}

Trip
===========
https://hst-api.wialon.com/wialon/ajax.html?sid=02a936db90d4d0cf023ab6e6988290c0&svc=events/get&params={"selector":{
"type":"trips","timeFrom":"20210128","timeTo":"20210128" }

Please let us know if these api call are correct or any changes are required

8

API to Pull Event and Trip Data

Re: API to Pull Event and Trip Data

Hello!

Jayateerth.Sullad , for the fisrt request unit/get_drive_rank_settings  error1 means not valid session.
So please make sure that you apply the id of current session (which you get after login).
Also please note after login (or after last request to server) the session duration will be interrupted after 5 minutes, if there are no one requests send to server.  To hold session it needs to sends request every 5 min, or it can be executed avl_evts (without any parameters) , for example, every 2-5 sec.

Regarding events/get request. 
Before you get events, you need to load it. You can use the combination of load + get
For example, get trips for certain peridof.

svc = events/load
params = {"ivalType":1,"itemId":21728414,"timeFrom":1618779600,"timeTo":1619557199,"detectors":[{"type":"trips","filter1":0}],"selector":{"type":"trips","timeFrom":1618779600,"timeTo":1619557199,"detalization":3}}
sid = 0239e78693b85d6f2e25e7c10328776e

Response returns trips in "selector".trips

+ show spoiler
{
    "events": {
        "trips": {
            "0": 2
        }
    },
    "states": {
        "trips": {
            "updateTime": 1618779600
        }
    },
    "selector": {
        "trips": {
            "0": [
                {
                    "from": {
                        "t": 1618813640,
                        "y": 45.8631362915,
                        "x": 2.62300014496
                    },
                    "to": {
                        "t": 1618828815,
                        "y": 42.5501365662,
                        "x": 1.14278304577
                    },
                    "m": 1618829115,
                    "f": 2,
                    "state": 1,
                    "max_speed": 130,
                    "curr_speed": 0,
                    "avg_speed": 116,
                    "distance": 489706,
                    "odometer": 1740792832,
                    "course": 0,
                    "altitude": 100,
                    "pos_flags": 0
                },
                {
                    "from": {
                        "t": 1619211603,
                        "y": 9.00438213348,
                        "x": -79.5143661499
                    },
                    "to": {
                        "t": 1620281583,
                        "y": 40.4190673828,
                        "x": 2.12330007553
                    },
                    "m": 1620281892,
                    "f": 2,
                    "state": 1,
                    "max_speed": 150,
                    "curr_speed": 0,
                    "avg_speed": 770906,
                    "distance": 2147483648,
                    "odometer": 1741282560,
                    "course": 0,
                    "altitude": 100,
                    "pos_flags": 0
                }
            ]
        }
    }
}
Diana Cheley
Wialon Hosting Expert
Gurtam