Retrieving Audit Data Linked to a Route Destination

See files for this Use Case on the GitHub here

You can retrieve audit data linked to a route destination.

Description

You can get wide variety of data from a route destination: time points for last visited and departed, activities linked to a route destination, revenue, timeframe violation, geocoding state, notes, running service time, running travel time, running distance, fuel from start, fuel cost from start.

Retrieve a Route

Let us choose a route. For example, you can choose a route from topic Understanding Dynamic Arrival and Departure Times: optimization problem Single Driver Multiple Time Windows with 11 addresses adn 1 route. (see the optimization problem response data here ). You can see there the parameters:

"optimization_problem_id": "06BF0EFE40FCCC24957686DFE2DE353A",
"route_id": "DD376C7148E7FEE36CFABE2BD9978BDD"
Addresses:
"route_destination_id": 183045807,
"route_destination_id": 183045808,
"route_destination_id": 183045809,
"route_destination_id": 183045810,
"route_destination_id": 183045811,
"route_destination_id": 183045812,
"route_destination_id": 183045813,
"route_destination_id": 183045814,
"route_destination_id": 183045815,
"route_destination_id": 183045816,
"route_destination_id": 183045817

you can see the route on a map as:

Add an Info To a Destination

Set GPS position of a device

You can set GPS postion of a device with the coordintes of a destination.

The endpoint: https://www.route4me.com/track/set.php

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
format string Response format GET
member_id integer Member ID GET
route_id string Route ID GET
course integer Vehicle movement course GET
speed double Vehicle movement speed GET
lat double Latitude GET
lng double Longitude GET
device_type string Device type GET
device_guid string Device ID GET
vehicle_id string Vehicle ID GET


1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/track/set.php
4 SET apikey=11111111111111111111111111111111
5 SET frm=XML
6 SET membid=1
7 SET route_id=DD376C7148E7FEE36CFABE2BD9978BDD
8 SET course=70
9 SET speed=60
10 :: bellow is position of the address: 1659 Hibbard Dr, Stow, OH 44224
11 SET lat=41.194505989552
12 SET lng=-81.443351581693
13 SET devtype=android_phone
14 SET devguid="HK5454H0K454564WWER445"
15 SET vehid=FFFF72BF6E06DC3C746673279BDAAE05
16 
17 ECHO ON
18 
19 :: There are also several optional parameters: tx_id, altitude, device_timestamp, app_version
20 
21 curl -o file1.txt -g -X GET -k "%url%?api_key=%apikey%&format=%frm%&member_id=%membid%&route_id=%route_id%&course=%course%&speed=%speed%&lat=%lat%&lng=%lng%&device_type=%devtype%&device_guid=%devguid%&vehicle_id=%vehid%"
22 
23 timeout /t 30

You can expect this API response:

{"status":true}

Mark a Destination as Detected as Visited

You can mark programmatically a destination as "visited" (this is similar to pressing on a button "Visited" by a driver).

The endpoint: https://www.route4me.com/api.v4/address.php

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
route_destination_id integer Route destination ID (Address ID) GET
is_visited integer If equal to 1, the destination will be marked as visited POST


1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/address.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=DD376C7148E7FEE36CFABE2BD9978BDD
6 SET routedestinationid=183045808
7 
8 ECHO ON
9 
10 :: is_visited=1 means address was visited, is_visited=0 --- not visited
11 
12 curl -o file1.txt -k -g -X PUT -H "Content-Type: application/json" -d "@mark_address_as_detected_as_visited_data.json" "%url%?api_key=%apikey%&route_id=%routeid%&route_destination_id=%routedestinationid%"
13 
14 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to this block in the response file:

"is_visited": true,
"timestamp_last_visited": 1472831090,

Mark a Destination as Detected as Departed

You can mark programmatically a destination as "departed"" (this is similar to pressing on a button "Departed" by a driver).

The endpoint: https://www.route4me.com/api.v4/address.php

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
route_destination_id integer Route destination ID (Address ID) GET
is_departed integer If equal to 1, the destination will be marked as departed POST


1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/address.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=DD376C7148E7FEE36CFABE2BD9978BDD
6 SET routedestinationid=183045808
7 
8 ECHO ON
9 
10 :: is_departed=1 means address was departed, is_departed=0 --- not departed
11 
12 curl -o file1.txt -k -g -X PUT -H "Content-Type: application/json" -d "@mark_address_as_detected_as_departed_data.json" "%url%?api_key=%apikey%&route_id=%routeid%&route_destination_id=%routedestinationid%"
13 
14 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to this block in the response file:

"is_departed": true,
"timestamp_last_departed": 1472831623,

Set Gas Price

You can set gas price for a route and then audit the fuel cost for a route and destinations.

The endpoint: https://www.route4me.com/api.v4/route.php

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
gas_price double Price of gas (used to compute route costs) POST


1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/route.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=DD376C7148E7FEE36CFABE2BD9978BDD
6 
7 ECHO ON
8 
9 curl -o file1.txt -g -k -X PUT -H "Content-Type: application/json" -d "@set_gas_price_data.json" "%url%?route_id=%routeid%&api_key=%apikey%"
10 
11 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to these parameters in the response file:

"mpg": 36.5,
"gas_price": 5

Where mpg means miles per gallon.

Add a Note To a Destination

You can attach a note to a route destination.

The endpoint: https://www.route4me.com/actions/addRouteNotes.php

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
address_id integer Route destintion ID GET
dev_lat double Device position latitude GET
dev_lng double Device position longitude GET
device_type string Device type GET
strNoteContents string Note content, text POST
strUpdateType string Note update type POST


1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/actions/addRouteNotes.php
4 
5 SET apikey=11111111111111111111111111111111
6 SET routeid=DD376C7148E7FEE36CFABE2BD9978BDD
7 
8 :: "2705 N River Rd, Stow, OH 44224"
9 SET addrid=183045812
10 SET dev_lat=41.145240783691
11 SET dev_lng=-81.410247802734
12 SET dev_type=web
13 SET updatetype=dropoff
14 SET content=Note example for Destination Audit Use Case
15 
16 ECHO ON
17 
18 curl -o file1.txt -g -k -X POST -H "Content-Type: multipart/form-data;" -F "strNoteContents=%content%" -F "strUpdateType=%dropoff%" "%url%?api_key=%apikey%&route_id=%routeid%&address_id=%addrid%&dev_lat=%dev_lat%&dev_lng=%dev_lng%&device_type=%dev_type%"
19 
20 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to this parameter in the response file:

"contents": "Note example for Destination Audit Use Case"

Set Revenue to a Destination

You can set revenue for each destination in order to get total route revenue. Let us choose following addresses and revenues:

route_destination_id = 183045808, revenue = 200
route_destination_id = 183045810, revenue = 400

The endpoint: https://www.route4me.com/api.v4/route.php

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
revenue double Route destination revenue POST


1 @ECHO OFF
2 SET url=https://www.route4me.com/api.v4/address.php
3 SET apikey=11111111111111111111111111111111
4 SET routeid=DD376C7148E7FEE36CFABE2BD9978BDD
5 SET routedestinationid=183045808
6 
7 ECHO ON
8 
9 curl -o file1.txt -g -k -X PUT -H "Content-Type: application/json" -d "@set_address_revenue_data.json" "%url%?api_key=%apikey%&route_id=%routeid%&route_destination_id=%routedestinationid%"
10 
11 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to this parameter in the response file:

"revenue": 200

You can repeat this script for second route destionation with 183045810.

Retrieve Audit Data from a Route Destination

Now you can retrieve different audit data from a route destination:

Retrieve Route Total Revenue

You can retrieve total route revenue aggregated from destinations' revenues.

The endpoint: https://www.route4me.com/api.v4/route.php

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET


1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/route.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=DD376C7148E7FEE36CFABE2BD9978BDD
6 
7 ECHO ON
8 
9 curl -o file1.txt -g -k -X GET "%url%?route_id=%routeid%&api_key=%apikey%"
10 
11 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to this parameter in the response file:

"route_revenue": 600

Retrieve Fuel Expenditure and Cost

You can retrieve information about fuel expenditure and cost for a route destination.

The endpoint: http://www.route4me.com/api.v4/address.php

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
route_destination_id integer Route destination ID GET


1 @ECHO OFF
2 
3 SET url=http://www.route4me.com/api.v4/address.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=DD376C7148E7FEE36CFABE2BD9978BDD
6 SET routedestinationid=183045815
7 
8 ECHO ON
9 curl -o file1.txt -g -X GET "%URL%?api_key=%apikey%&route_id=%routeid%&route_destination_id=%routedestinationid%"
10 
11 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to these parameters in the response file:

"fuel_from_start": 1.0030555555556,
"fuel_cost_from_start": 5.0152777777778

Retrieve Running Service and Travel Times, Distance

You can retrieve running service and travel times, running distance from a route destination.

The endpoint: http://www.route4me.com/api.v4/address.php

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
route_destination_id integer Route destination ID GET


1 @ECHO OFF
2 
3 SET url=http://www.route4me.com/api.v4/address.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=DD376C7148E7FEE36CFABE2BD9978BDD
6 SET routedestinationid=183045814
7 
8 ECHO ON
9 curl -o file1.txt -g -X GET "%URL%?api_key=%apikey%&route_id=%routeid%&route_destination_id=%routedestinationid%"
10 
11 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to these parameters in the response file:

"running_service_time": 1300,
"running_travel_time": 3944,
"running_wait_time": 0,
"running_distance": 32.81

Retrieve Notes from a Route Destination

You can retrieve notes attached to a route destination.

The endpoint: http://www.route4me.com/api.v4/address.php

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
route_destination_id integer Route destination ID GET
notes_id integer If equal to 1, the notes will be included in a response GET


1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/address.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=DD376C7148E7FEE36CFABE2BD9978BDD
6 SET routedestinationid=183045812
7 
8 ECHO ON
9 curl -o file1.txt -g -k -X GET "%URL%?api_key=%apikey%&route_id=%routeid%&route_destination_id=%routedestinationid%&notes=1"
10 
11 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to these parameters in the response file:

"notes": [{
"note_id": 743510,
"route_id": "DD376C7148E7FEE36CFABE2BD9978BDD",
"route_destination_id": 183045812,
"ts_added": 1473089861,
"activity_type": "",
"upload_id": "",
"upload_extension": null,
"upload_url": null,
"upload_type": null,
"contents": "Note example for Destination Audit Use Case",
"lat": 41.145241,
"lng": -81.410248,
"device_type": "web"
}
]

Retrieve Activities Related to a Route Destination

You can get activities associated with a route destination - "mark-destination-visited", "mark-destination-departed", "note-insert" etc.

The endpoint: http://www.route4me.com/api.v4/address.php

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
activity_type string Activity type GET


Destination Visited

1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api/get_activities.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=DD376C7148E7FEE36CFABE2BD9978BDD
6 SET act_type=mark-destination-visited
7 
8 ECHO ON
9 curl -o file1.txt -g -k -X GET "%url%?api_key=%apikey%&route_id=%routeid%&activity_type=%act_type%"
10 
11 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to these parameters in the response file:

"activity_type": "mark-destination-visited",
"activity_timestamp": "1473174799",
"activity_message": "The address '512 Florida Pl, Barberton, OH 44203' was marked as visited from Web Interface"

Destination Departed

1 @ECHO OFF
2 
3 :: You should insert real test data and your API key for accurate testing
4 
5 SET url=https://www.route4me.com/api/get_activities.php
6 SET apikey=11111111111111111111111111111111
7 SET routeid=DD376C7148E7FEE36CFABE2BD9978BDD
8 SET act_type=mark-destination-departed
9 
10 ECHO ON
11 curl -o file1.txt -g -k -X GET "%URL%?api_key=%apikey%&route_id=%routeid%&activity_type=%act_type%"
12 
13 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to these parameters in the response file:

"activity_type": "mark-destination-departed",
"activity_timestamp": "1473174554",
"activity_message": "The address '512 Florida Pl, Barberton, OH 44203' was marked as departed from Web Interface"

Note Inserted

1 @ECHO OFF
2 
3 :: You should insert real test data and your API key for accurate testing
4 
5 SET url=https://www.route4me.com/api/get_activities.php
6 SET apikey=11111111111111111111111111111111
7 SET routeid=DD376C7148E7FEE36CFABE2BD9978BDD
8 SET act_type=note-insert
9 
10 ECHO ON
11 curl -o file1.txt -g -k -X GET "%URL%?api_key=%apikey%&route_id=%routeid%&activity_type=%act_type%"
12 
13 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to these parameters in the response file:

"activity_type": "note-insert",
"activity_timestamp": "1473089862",
"activity_message": "A note was added to address '2705 N River Rd, Stow, OH 44224' from Web Interface"

Get Information about Timeframe Violations

You can get information about timeframe violations associated with a route destination.

The endpoint: http://www.route4me.com/api.v4/address.php

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
route_destination_id integer Route destination ID GET


1 @ECHO OFF
2 
3 SET url=http://www.route4me.com/api.v4/address.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=DD376C7148E7FEE36CFABE2BD9978BDD
6 SET routedestinationid=183045808
7 
8 ECHO ON
9 curl -o file1.txt -g -X GET "%URL%?api_key=%apikey%&route_id=%routeid%&route_destination_id=%routedestinationid%"
10 
11 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to this parameter in the response file:

"timeframe_violation_state": 3