Routes for Cars & Trucks

Product Used: Directions API


NextBillion.ai’s Routing APIs provides the mode feature to determine the correct routes for a given driving mode. In case of trucks, you can further customize the suggested routes by adding truck size, truck weight and axle load constraints to ensure the safety and legitimacy of the routes. In this example, we will create requests to get suitable routes for different types of vehicles in the fleet

Vehicle Type: Pickup Truck

Following is a request to get the directions for a pickup truck with

  • An “origin” and “destination” set
  • “mode” option set to “car” to emulate driving conditions for a pickup truck
  • “avoid” option set to “highway”

Request

1curl --location 'https://api.nextbillion.io/directions/json?origin=28.53086731,-81.39337678&destination=28.46057639,-81.45685023&avoid=highway&mode=car&key=<your_api_key>'

Response

1{
2 "status": "Ok",
3 "routes": [
4 {
5 "geometry": "uncmDrcxoN?X@zH@|@?pD@X?J?d@?nA?T?\\@`A?b@?|@?H@T?zC?R@h@?n@?|@@bB?~@@zA?N|A@`B?n@?v@?nA?hCClAC^?d@Cl@A`@?jBAX?x@AdB?\\?l@?x@AB?jDAhC?l@?d@AP?R?~@?tDAjAAfB?`A?L?b@@h@@X?h@@\\?L@`A@Z@lB?jA?t@?dA?\\?ZAj@?rA?z@AfA?lA?X?P?bB?n@?L?XAh@?LA`@?\\?d@?j@?T?N?V?tAAd@?ZAP?H?xA?nBARAj@?Z?TAv@@BJPt@Hd@DPHb@BP@F@J?F@F?L@J?N@bA?x@@rD?lD@rA@fJ?f@?vD@fG?vD@xE?z@?~B?Z@tD@bBB~AB|A@bA@jA@vC?`A?b@?N?r@EJEdBCt@ARAd@AtB?|@Bh@Hj@Ll@Lr@Rr@RX`@pATp@FVDNBJNl@HXH`@P|@Fb@BXBZB\\?H?T@P@|B@j@?n@@`A?f@?~@?V@\\?V?~@@XhA?F@X?`@BVBF@J@TD^JFBVH\\N\\RFDjAv@n@b@`Ap@h@^VPbAp@RNLHpA|@FFJDvBzAh@^j@`@b@XpA|@bAp@`@XB@fAv@|B~APLb@Zj@^d@\\rBvA`BhA@?^XPLz@j@fAt@x@j@|AfAl@d@j@\\~AhAHDFFbAp@nA|@bAr@PLTPNJZR^Xb@Xn@d@r@d@JHNJp@b@xAbA~@p@bBjA\\VRLVPdAr@j@`@l@`@jBrAh@\\bDzBh@^PLz@j@PLhBnALHdCfBTN`C~At@h@n@b@l@`@\\VPLx@f@hBrAPLNJ`Ar@bBhAFDp@f@^\\^^NPLNTXZd@Vf@Vh@Th@Rj@Pl@DLH^Pv@DXDRFh@Hn@Dp@Bv@@v@@xA?H?L?lG?xA?`@?p@AzD?pD?v@?L?R?V?X?\\?p@?r@?tC?pA?p@?dA?h@?|@?v@?d@?v@@\\?f@?R?R?X?l@?T?jB?f@?|B?Z@VP?N?pB?tAAhDAbAAjA?`CAv@AL?dB?hA?V?f@?F?X?P?tB@hB?nA?lB@h@?P@t@@NAnA?V?R@R?\\Bf@DpALr@Jv@J\\Dd@FrBXx@Ff@Dd@BH?v@BV@F?F?d@AVAJA`@?PAb@AXAL?JAN?NAV?b@AdBEh@Cr@?~@Ev@Cp@Cf@Ch@EXCXCZCd@Gh@E\\C^A`@CtBS|@EbAEr@Ez@ChAEX?zB?d@C^CZ?N?PA|A@xAAx@?rA?V?\\?xA?F?F?JEBAFCFEFEBCBCBE@EDMCkDBC@EBC?E@EAE?ECCAECCEACAC?E?E@C@CBCDkBCAqB",
6 "distance": 13175.0,
7 "duration": 1076.8,
8 "legs": [
9 {
10 "distance": {
11 "value": 13175
12 },
13 "duration": {
14 "value": 1076
15 },
16 "steps": []
17 }
18 ]

Vehicle Type: Truck

Following is a Directions Flexible request to get the directions for a freight truck with axle load settings An “origin” and “destination” set “mode” option set to “truck” to emulate driving conditions for a freight truck “truck_axle_load” configured to get legitimate routes

Request

1curl --location 'https://api.nextbillion.io/directions/json?origin=33.02655433,-96.75117698&destination=33.02519670,-96.88507592&mode=truck&key=<your_api_key>&option=flexible&truck_axle_load=9'

Response

1{
2 "status": "Ok",
3 "routes": [
4 {
5 "geometry": "unqhEzuomQ?c@W@@rD??Av@???h@?@@p@?j@?lB?^T?@?T@R?N?LAN?LCPEXKN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AAvA?T??AnA@fA?dFC`I?~A?v@??Ab@?@?hI?nDKXEl@IzACv@EzA??C`B?`@AdBAv@AZA^Ep@??Ef@C^CZOtACXCn@CZ?@A|@AlAAd@@nACn@@`@BXB\\Fd@?@F^Hb@hBjH\\zALh@ZpAJf@BJPn@Vv@DJJTFNl@jA??G\\E^Ah@?@Af@?`A?v@???pB?f@?`A?zD???`@??@dB???tA?fA@H???~AAzA?T?lAAxB?fA?|@???n@?@[???i@?a@?g@???i@@??QAA?g@???u@@??]?m@A_B@A?M?wA?iCAkC?i@@??{@?q@?}@Ai@?A?K?c@AUAWAKA]EQCMC]IME??OG[O[QGCA?IIIGINIHIHCDQLUN[PGB]JWB]@I???mF?[@i@BSD_@JKFOJm@h@g@r@a@z@A?IVmAfCS\\SRKHOJUL_@LIBM@??C@M@M?Q?WA??_@@AJ?J??Ar@Ar@Ct@A\\??M`FA|@ExAGlCAb@AVAZ??Ab@Gn@?@Gj@??Q~@E\\CFG`@E`@ARAN?T?@?hA?@?rB???vC?dB?@?`A?h@?x@Aj@?V?lA@n@Ap@???~@?b@AxA?ZAnAAtB?tBAfB???rB???f@?V?@Ab@?|A???hD?b@??AjE?@?R?lB?hA?@@|A?p@?t@?^?@?|A??AjA?@?Z?V@~@A`D?`B?hA?@?xA?`@??Ax@?r@Av@???dC?\\?`@?@AbBa@?k@@q@@SAA?M?O?Y?W?S?IA??A^?@\\@??J?D?F?V?Z@@?ZAP?\\AF?",
6 "distance": 17908.922,
7 "duration": 1320.995,
8 "start_location": {
9 "latitude": 33.02651,
10 "longitude": -96.75118
11 },
12 "end_location": {
13 "latitude": 33.0252,
14 "longitude": -96.88501
15 },
16 "legs": [
17 {
18 "distance": {

Vehicle Type: Freight Truck

Following is a request to get the directions for a freight truck with

  • An “origin” and “destination” set
  • “mode” option set to “truck” to emulate driving conditions for a freight truck
  • “truck_size” constraints configured to get legitimate routes

Request

1curl --location 'https://api.nextbillion.io/directions/json?origin=29.59932895,-95.66323222&destination=29.58789146,-95.67311985&mode=truck&key=<your_api_key>&option=flexible&truck_size=220,250,400'

Response

1{
2 "status": "Ok",
3 "routes": [
4 {
5 "geometry": "ubtsD~e{fQJJ??HMHQHSFSFWFSBUBQBQBM@OHe@?AFa@Hm@H_@??H[HSJSPUTWPORMTKVKVGRC??DAVAT?Z@dAFp@Bh@?H?P?b@Az@EJ?JA??JAj@GNCVA`@A^A\\B\\B^H`@J^L\\NZPXPVTHJLJRXT\\`BnCRZJPPXRVTTJH?@HFPJDDHBJD??FBb@NLBJBLJVDN@P?T?VAPA??B?XEb@KBPJv@BP??BT?@BNDx@Dx@@x@?T?d@??GxBInAOxA]nBkArFQx@Q|@SjAKt@E^Gn@E`@C|@CnA??Ah@?x@B|@DlAJjBRnC??JdARlBLt@F\\??Jr@DPBL@F@NFZZI@?LCd@M??TIRKRQVYHI??DIRYNSBSFIJMHIHK??JKJKLKPMLMLKPKPKPK??RILGPILGLEJEHCFCFAZI@?|@Q",
6 "distance": 2837.028,
7 "duration": 332.238,
8 "start_location": {
9 "latitude": 29.59931,
10 "longitude": -95.6632
11 },
12 "end_location": {
13 "latitude": 29.5879,
14 "longitude": -95.67309
15 },
16 "legs": [
17 {
18 "distance": {

Visit Directions API & documentation to know more about the available features.