Scanning a Barcode Label and Finding the Route a Specific Item Is On

See files for this Use Case on the GitHub here

Description

For the cases when your route is scheduled to deliver or pickup several different items, you can include a list of those items in the custom data fields. This custom data may later be used to find a route that contains specific items. Please note that you may store only the items' barcodes in the custom data.

Solution

Optimization Parameters and addresses

Let us choose a Single Depot Multiple Driver option for this use case. You can create an optimization problem with these parameters:

ParameterTypeDescriptionHTTP method
api_keystringAPI KEY of the userGET
redirectintegerIf equal to 1, will be redirected, if 0 - notGET
addressesarrayValid JSON array of Address objects. Click here to see the JSON SchemaPOST
parametersRoute ParametersValid JSON string of RouteParameters object. Click here to see the JSON SchemaPOST

You can see the addresses on the map as:

Create an Optimization

You can create new optimization for this use case example. From the cUrl example bellow you can see that:

ParameterTypeDescription
api_keystringAPI KEY of the user
input dataPOST dataValid JSON object string. Click here to see the JSON Schema
1 @ECHO OFF
2 :: Single Depot, Multiple Driver, No Time Window
3 
4 ::See video tutorial here: http://support.route4me.com/route-planning-help.php?id=manual0:tutorial2:chapter2:subchapter1
5 
6 SET URL=https://www.route4me.com/api.v4/optimization_problem.php
7 SET apikey=11111111111111111111111111111111
8 SET route_path_output=Points
9 
10 ECHO ON
11 
12 curl -o file1.txt -g -X POST -k -d "@single_depot_multiple_driver_notime_window_data.json" "%URL%?api_key=%apikey%&route_path_output=%route_path_output%"
13 
14 timeout /t 30

You can expect an Optimization problem (see link), which generated some routes already.

View the Optimization details

You can get more details from the newly created optimization problem:

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

HTTP Parameters

AttributeTypeDescriptionHTTP
method
api_keystringAPI KEY of the userGET
optimization_problem_idstringOptimization problem IDGET


1 @ECHO OFF
2 SET url=https://www.route4me.com/api.v4/optimization_problem.php
3 SET apikey=11111111111111111111111111111111
4 SET optprobid=51F656ECE6A33C9E2001A9B333F8B55B
5 
6 ECHO ON
7 curl -o file1.txt -g -X GET -k "%URL%?api_key=%apikey%&optimization_problem_id=%optprobid%"
8 
9 timeout /t 30

See sample RESPONSE JSON data here

The system will send the RESPONSE with an array of the addresses, which belongs to 5 generated routes:

"route_id": "718B766A18B391AE7980F2F91B2F2BAC"
"route_id": "723A57B984CDE04877C2E7EA8D1C84D9"
"route_id": "A54ECDCE6754822D50CAA50756AA53E7"
"route_id": "D74C13DC038A698AED9A863AC27FE9E5"
"route_id": "FE206E064BCF73128D05F2789EFCB1E5"

Let us to choose "route_id": "723A57B984CDE04877C2E7EA8D1C84D9" and see its details.

Details of the Chosen Route

You can get more details of the route:

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

HTTP Parameters

AttributeTypeDescriptionHTTP
method
api_keystringAPI KEY of the userGET
route_idstringRoute IDGET
route_path_outputstringIf equal to 'Poitns', you'll get an array of the path points to next addressGET


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

See sample RESPONSE JSON data here

You can draw the route on the map as:

Add a Item's Name to the Route Destination

Let us add a barcode to the destination (route_destination_id=187554385) selected on the map above as a custom data. As an example you can take this barcode:

This barcode is a representation of the text "ipad-air-2-12345".

You can scan this barcode by any modern barcode scanner and you'll get text "ipad-air-2-12345" in your application's text field and you can use this text to search for a route with this text item.

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 intenger Route destination ID GET
custom_fields array Array of custom fields with string values POST


From the cUrl example bellow you can see that:

1 @ECHO OFF
2 SET url=https://www.route4me.com/api.v4/address.php
3 
4 :: You should insert real test data and your API key for accurate testing
5 
6 SET apikey=11111111111111111111111111111111
7 SET routeid=723A57B984CDE04877C2E7EA8D1C84D9
8 SET routedestinationid=187554385
9 
10 ECHO ON
11 
12 curl -o file1.txt -g -k -X PUT -H "Content-Type: application/json" -d "@update_route_destination_custom_data.json" "%url%?api_key=%apikey%&route_id=%routeid%&route_destination_id=%routedestinationid%"
13 
14 timeout /t 30

See sample response data (see here).

Pay attention to the parameter custom_fields:

"custom_fields": {
"package_item": "ipad-air-2-12345"
}

Find a Route by Custom Fields Data

Now you can find a route which contains the destination attributed with some custom data. You can find this route even if the destination was moved from one route to another.

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
query string Text to be searched for GET


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

See sample response data (see here).