Navigation | Routing API | Quick start | 2GIS Documentation

Quick start

Quick start will help you get started with the service and become familiar with its features.

After going through all the steps of the quickstart, you will:

  1. Learn how to use Routing API.
  2. Send a request to build a car route with multiple waypoints.

A request example is provided using cURL.

  1. Sign in to the Platform Manager.
  2. Create a demo key (if you have not used Urbi products before) or request a production key: follow the link to contact a manager on the API Keys tab.

In the Platform Manager, you can also:

  • See information on your current keys: which services are enabled, which limit is set for each, when a key will be deactivated, and more.
  • Set restrictions for a key by HTTP headers or by IP and subnet.
  • Check the statistics of request distribution for each key.

To plot a car route with multiple waypoints, send the POST request to /routing/7.0.0/global. Follow these steps:

  1. In the request URL, specify the API key value for the key parameter:

    http://routing.api.2gis.com/routing/7.0.0/global?key=API_KEY
    
  2. In the request body, pass the JSON with the necessary parameters:

    {
        "points": [
            {
                "type": "stop",
                "lon": 55.280689,
                "lat": 25.204066
            },
            {
                "type": "stop",
                "lon": 55.28275,
                "lat": 25.217127
            }
        ],
        "locale": "en",
        "transport": "car",
        "route_mode": "fastest",
        "traffic_mode": "jam"
    }
    

For more information about the parameters, see API Reference.

Request example:

curl --location --request POST 'http://routing.api.2gis.com/routing/7.0.0/global?key=API_KEY' \
--header 'Content-Type: application/json' \
--data '{
    "points": [
        {
            "type": "stop",
            "lon": 55.280689,
            "lat": 25.204066
        },
        {
            "type": "stop",
            "lon": 55.28275,
            "lat": 25.217127
        }
    ],
    "locale": "en",
    "transport": "car",
    "route_mode": "fastest",
    "traffic_mode": "jam"
}'

Response example:

response.json
{
    "query": {
        "locale": "en",
        "points": [
            {
                "lat": 25.204066,
                "lon": 55.280689,
                "type": "stop"
            },
            {
                "lat": 25.217127,
                "lon": 55.28275,
                "type": "stop"
            }
        ],
        "route_mode": "fastest",
        "traffic_mode": "jam",
        "transport": "car"
    },
    "result": [
        {
            "algorithm": "with traffic jams",
            "begin_pedestrian_path": {
                "geometry": {
                    "selection": "LINESTRING(55.280688 25.204065, 55.280666 25.203932)"
                }
            },
            "end_pedestrian_path": {
                "geometry": {
                    "selection": "LINESTRING(55.283007 25.217086, 55.282750 25.217127)"
                }
            },
            "filter_road_types": ["dirt_road"],
            "id": "12347215104271596957",
            "maneuvers": [
                {
                    "comment": "start",
                    "icon": "start",
                    "id": "11940630674476452829",
                    "outcoming_path": {
                        "distance": 147,
                        "duration": 45,
                        "geometry": [
                            {
                                "color": "ignore",
                                "length": 163,
                                "selection": "LINESTRING(55.280666 25.203932, 55.280693 25.203929, 55.280755 25.203939, 55.280806 25.203957, 55.280841 25.203991, 55.280870 25.204037, 55.280951 25.204521, 55.281052 25.205127)",
                                "style": "living_zone"
                            }
                        ],
                        "names": ["29a"]
                    },
                    "outcoming_path_comment": "150 m straight",
                    "type": "begin"
                },
                {
                    "comment": "Right turn onto 29a",
                    "icon": "crossroad_right",
                    "id": "4251688040716627615",
                    "outcoming_path": {
                        "distance": 72,
                        "duration": 22,
                        "geometry": [
                            {
                                "color": "ignore",
                                "length": 79,
                                "selection": "LINESTRING(55.281052 25.205127, 55.281762 25.205029)",
                                "style": "living_zone"
                            }
                        ],
                        "names": ["29a"]
                    },
                    "outcoming_path_comment": "70 m straight",
                    "turn_angle": 90,
                    "turn_direction": "right",
                    "type": "crossroad"
                },
                {
                    "comment": "Right turn onto 4",
                    "icon": "crossroad_right",
                    "id": "4528036972455162115",
                    "outcoming_path": {
                        "distance": 1845,
                        "duration": 227,
                        "geometry": [
                            {
                                "color": "fast",
                                "length": 537,
                                "selection": "LINESTRING(55.281762 25.205029, 55.281749 25.204813, 55.281714 25.204483, 55.281602 25.203809, 55.281540 25.203437, 55.281502 25.203370, 55.281454 25.203329, 55.281381 25.203292, 55.281256 25.203309, 55.279796 25.203509, 55.279254 25.203583, 55.279137 25.203600, 55.279066 25.203614, 55.279006 25.203639, 55.278941 25.203682, 55.278891 25.203734, 55.278857 25.203787, 55.278829 25.203852, 55.278806 25.203954)",
                                "style": "living_zone"
                            },
                            {
                                "color": "fast",
                                "length": 1526,
                                "selection": "LINESTRING(55.278806 25.203954, 55.278820 25.204074, 55.278877 25.204668, 55.279253 25.207544, 55.279358 25.208337, 55.279445 25.208999, 55.279471 25.209174, 55.279527 25.209537, 55.279578 25.209717, 55.279634 25.209874, 55.279702 25.210038, 55.279792 25.210205, 55.279929 25.210414, 55.280083 25.210615, 55.280223 25.210766, 55.280395 25.210921, 55.280478 25.210984, 55.280577 25.211060, 55.280663 25.211123, 55.280780 25.211208, 55.280869 25.211262, 55.281028 25.211360, 55.281353 25.211559, 55.281498 25.211648, 55.281651 25.211742, 55.281886 25.211885, 55.282071 25.211999, 55.282201 25.212078, 55.282676 25.212369, 55.282944 25.212533, 55.283135 25.212678, 55.283298 25.212816, 55.283456 25.212973, 55.283597 25.213135, 55.283713 25.213284, 55.284033 25.213731, 55.284454 25.214328, 55.284505 25.214404)",
                                "style": "normal"
                            }
                        ],
                        "names": ["4"]
                    },
                    "outcoming_path_comment": "1.8 km straight",
                    "turn_angle": 84,
                    "turn_direction": "right",
                    "type": "crossroad"
                },
                {
                    "comment": "Left turn onto Al Boursa",
                    "icon": "crossroad_left",
                    "id": "9999251387212387066",
                    "outcoming_path": {
                        "distance": 161,
                        "duration": 25,
                        "geometry": [
                            {
                                "color": "fast",
                                "length": 180,
                                "selection": "LINESTRING(55.284505 25.214404, 55.284572 25.214505, 55.284405 25.214599, 55.284341 25.214636, 55.284095 25.214774, 55.283305 25.215222)",
                                "style": "normal"
                            }
                        ],
                        "names": ["Al Boursa"]
                    },
                    "outcoming_path_comment": "150 m straight",
                    "turn_angle": -89,
                    "turn_direction": "left",
                    "type": "crossroad"
                },
                {
                    "comment": "Slight right turn",
                    "icon": "crossroad_slightly_right",
                    "id": "8435699398754017605",
                    "outcoming_path": {
                        "distance": 117,
                        "duration": 16,
                        "geometry": [
                            {
                                "color": "fast",
                                "length": 131,
                                "selection": "LINESTRING(55.283305 25.215222, 55.283255 25.215294, 55.283222 25.215348, 55.283198 25.215406, 55.283186 25.215467, 55.283182 25.215520, 55.283188 25.215584, 55.283194 25.215607, 55.283205 25.215646, 55.283246 25.215714, 55.283318 25.215798, 55.283403 25.215884, 55.283514 25.215974, 55.283545 25.215996, 55.283615 25.216049, 55.283674 25.216083)",
                                "style": "living_zone"
                            }
                        ],
                        "names": []
                    },
                    "outcoming_path_comment": "100 m straight",
                    "turn_angle": 34,
                    "turn_direction": "slightly_right",
                    "type": "crossroad"
                },
                {
                    "comment": "Left turn",
                    "icon": "crossroad_left",
                    "id": "7083204653764479677",
                    "outcoming_path": {
                        "distance": 78,
                        "duration": 21,
                        "geometry": [
                            {
                                "color": "fast",
                                "length": 19,
                                "selection": "LINESTRING(55.283674 25.216083, 55.283720 25.216109, 55.283754 25.216125, 55.283714 25.216195)",
                                "style": "living_zone"
                            },
                            {
                                "color": "ignore",
                                "length": 67,
                                "selection": "LINESTRING(55.283714 25.216195, 55.283662 25.216264, 55.283442 25.216622, 55.283430 25.216641, 55.283414 25.216652, 55.283396 25.216654)",
                                "style": "living_zone"
                            }
                        ],
                        "names": []
                    },
                    "outcoming_path_comment": "80 m straight",
                    "turn_angle": -83,
                    "turn_direction": "left",
                    "type": "crossroad"
                },
                {
                    "comment": "Right turn",
                    "icon": "crossroad_right",
                    "id": "2233853289092092922",
                    "outcoming_path": {
                        "distance": 10,
                        "duration": 3,
                        "geometry": [
                            {
                                "color": "ignore",
                                "length": 11,
                                "selection": "LINESTRING(55.283396 25.216654, 55.283397 25.216726, 55.283386 25.216745)",
                                "style": "normal"
                            }
                        ],
                        "names": []
                    },
                    "outcoming_path_comment": "10 m straight",
                    "turn_angle": 61,
                    "turn_direction": "right",
                    "type": "crossroad"
                },
                {
                    "comment": "Slight right turn",
                    "icon": "crossroad_slightly_right",
                    "id": "12458741320396161745",
                    "outcoming_path": {
                        "distance": 106,
                        "duration": 33,
                        "geometry": [
                            {
                                "color": "ignore",
                                "length": 119,
                                "selection": "LINESTRING(55.283386 25.216745, 55.283500 25.216921, 55.283403 25.217077, 55.283307 25.217230, 55.283278 25.217272, 55.283254 25.217291, 55.283175 25.217294, 55.283143 25.217281, 55.283008 25.217086)",
                                "style": "normal"
                            }
                        ],
                        "names": []
                    },
                    "outcoming_path_comment": "100 m straight",
                    "turn_angle": 37,
                    "turn_direction": "slightly_right",
                    "type": "crossroad"
                },
                {
                    "comment": "finish",
                    "icon": "finish",
                    "id": "3288296233964010742",
                    "outcoming_path_comment": "You have arrived!",
                    "type": "end"
                }
            ],
            "reliability": 1.0,
            "route_id": "far-abroad-cr-back-mosesd.m1/carrouting/1688982610.728940",
            "total_distance": 2536,
            "total_duration": 393,
            "type": "carrouting",
            "ui_total_distance": {
                "unit": "km",
                "value": "2.5"
            },
            "ui_total_duration": "6 min",
            "waypoints": [
                {
                    "original_point": {
                        "lat": 25.20393290763231,
                        "lon": 55.2806666303206
                    },
                    "projected_point": {
                        "lat": 25.20393290763231,
                        "lon": 55.2806666303206
                    },
                    "transit": false
                },
                {
                    "original_point": {
                        "lat": 25.21708612524826,
                        "lon": 55.28300808910866
                    },
                    "projected_point": {
                        "lat": 25.21708612524826,
                        "lon": 55.28300808910866
                    },
                    "transit": false
                }
            ]
        },
        {
            "algorithm": "with traffic jams",
            "begin_pedestrian_path": {
                "geometry": {
                    "selection": "LINESTRING(55.280688 25.204065, 55.280666 25.203932)"
                }
            },
            "end_pedestrian_path": {
                "geometry": {
                    "selection": "LINESTRING(55.283007 25.217086, 55.282750 25.217127)"
                }
            },
            "filter_road_types": ["dirt_road"],
            "id": "13183010098651863290",
            "maneuvers": [
                {
                    "comment": "start",
                    "icon": "start",
                    "id": "10331508796823149820",
                    "outcoming_path": {
                        "distance": 147,
                        "duration": 46,
                        "geometry": [
                            {
                                "color": "ignore",
                                "length": 163,
                                "selection": "LINESTRING(55.280666 25.203932, 55.280693 25.203929, 55.280755 25.203939, 55.280806 25.203957, 55.280841 25.203991, 55.280870 25.204037, 55.280951 25.204521, 55.281052 25.205127)",
                                "style": "living_zone"
                            }
                        ],
                        "names": ["29a"]
                    },
                    "outcoming_path_comment": "150 m straight",
                    "type": "begin"
                },
                {
                    "comment": "Right turn onto 29a",
                    "icon": "crossroad_right",
                    "id": "340823194656763",
                    "outcoming_path": {
                        "distance": 72,
                        "duration": 23,
                        "geometry": [
                            {
                                "color": "ignore",
                                "length": 79,
                                "selection": "LINESTRING(55.281052 25.205127, 55.281762 25.205029)",
                                "style": "living_zone"
                            }
                        ],
                        "names": ["29a"]
                    },
                    "outcoming_path_comment": "70 m straight",
                    "turn_angle": 90,
                    "turn_direction": "right",
                    "type": "crossroad"
                },
                {
                    "comment": "Left turn onto 4",
                    "icon": "crossroad_left",
                    "id": "8653290141118839687",
                    "outcoming_path": {
                        "distance": 384,
                        "duration": 52,
                        "geometry": [
                            {
                                "color": "fast",
                                "length": 427,
                                "selection": "LINESTRING(55.281762 25.205029, 55.281770 25.205185, 55.281777 25.205306, 55.281797 25.205510, 55.281824 25.205672, 55.282289 25.208470)",
                                "style": "living_zone"
                            }
                        ],
                        "names": ["4"]
                    },
                    "outcoming_path_comment": "400 m straight",
                    "turn_angle": -96,
                    "turn_direction": "left",
                    "type": "crossroad"
                },
                {
                    "comment": "Left turn onto 23",
                    "icon": "crossroad_left",
                    "id": "1185033637502379190",
                    "outcoming_path": {
                        "distance": 90,
                        "duration": 12,
                        "geometry": [
                            {
                                "color": "fast",
                                "length": 100,
                                "selection": "LINESTRING(55.282289 25.208470, 55.281399 25.208592)",
                                "style": "living_zone"
                            }
                        ],
                        "names": ["23"]
                    },
                    "outcoming_path_comment": "90 m straight",
                    "turn_angle": -90,
                    "turn_direction": "left",
                    "type": "crossroad"
                },
                {
                    "comment": "Roundabout, exit 2 to 23",
                    "icon": "ringroad_forward",
                    "id": "10904419128038325374",
                    "outcoming_path": {
                        "distance": 41,
                        "duration": 7,
                        "geometry": [
                            {
                                "color": "fast",
                                "length": 46,
                                "selection": "LINESTRING(55.281399 25.208592, 55.281347 25.208613, 55.281312 25.208629, 55.281281 25.208654, 55.281232 25.208707, 55.281201 25.208733, 55.281163 25.208749, 55.281122 25.208755, 55.281082 25.208749, 55.281045 25.208733)",
                                "style": "living_zone"
                            }
                        ],
                        "names": ["23"]
                    },
                    "outcoming_path_comment": "40 m straight",
                    "ringroad_exit_number": 2,
                    "turn_angle": 5,
                    "type": "ringroad"
                },
                {
                    "comment": "Exit 2 to 23 Street",
                    "icon": "ringroad_exit",
                    "id": "928100260661014145",
                    "outcoming_path": {
                        "distance": 120,
                        "duration": 17,
                        "geometry": [
                            {
                                "color": "fast",
                                "length": 133,
                                "selection": "LINESTRING(55.281045 25.208733, 55.280984 25.208714, 55.280939 25.208706, 55.280894 25.208705, 55.280795 25.208706, 55.279875 25.208910)",
                                "style": "living_zone"
                            }
                        ],
                        "names": ["23"]
                    },
                    "outcoming_path_comment": "100 m straight",
                    "type": "ringroad_exit"
                },
                {
                    "comment": "Slight right turn onto Al Mustaqbal",
                    "icon": "crossroad_slightly_right",
                    "id": "5189366373565202817",
                    "outcoming_path": {
                        "distance": 825,
                        "duration": 102,
                        "geometry": [
                            {
                                "color": "fast",
                                "length": 90,
                                "selection": "LINESTRING(55.279875 25.208910, 55.279690 25.209079, 55.279636 25.209142, 55.279603 25.209192, 55.279592 25.209209, 55.279557 25.209283, 55.279536 25.209352, 55.279527 25.209423, 55.279527 25.209537)",
                                "style": "living_zone"
                            },
                            {
                                "color": "fast",
                                "length": 835,
                                "selection": "LINESTRING(55.279527 25.209537, 55.279578 25.209717, 55.279634 25.209874, 55.279702 25.210038, 55.279792 25.210205, 55.279929 25.210414, 55.280083 25.210615, 55.280223 25.210766, 55.280395 25.210921, 55.280478 25.210984, 55.280577 25.211060, 55.280663 25.211123, 55.280780 25.211208, 55.280869 25.211262, 55.281028 25.211360, 55.281353 25.211559, 55.281498 25.211648, 55.281651 25.211742, 55.281886 25.211885, 55.282071 25.211999, 55.282201 25.212078, 55.282676 25.212369, 55.282944 25.212533, 55.283135 25.212678, 55.283298 25.212816, 55.283456 25.212973, 55.283597 25.213135, 55.283713 25.213284, 55.284033 25.213731, 55.284454 25.214328, 55.284505 25.214404)",
                                "style": "normal"
                            }
                        ],
                        "names": ["Al Mustaqbal"]
                    },
                    "outcoming_path_comment": "800 m straight",
                    "turn_angle": 33,
                    "turn_direction": "slightly_right",
                    "type": "crossroad"
                },
                {
                    "comment": "Left turn onto Al Boursa",
                    "icon": "crossroad_left",
                    "id": "2210503297432708303",
                    "outcoming_path": {
                        "distance": 161,
                        "duration": 26,
                        "geometry": [
                            {
                                "color": "fast",
                                "length": 180,
                                "selection": "LINESTRING(55.284505 25.214404, 55.284572 25.214505, 55.284405 25.214599, 55.284341 25.214636, 55.284095 25.214774, 55.283305 25.215222)",
                                "style": "normal"
                            }
                        ],
                        "names": ["Al Boursa"]
                    },
                    "outcoming_path_comment": "150 m straight",
                    "turn_angle": -89,
                    "turn_direction": "left",
                    "type": "crossroad"
                },
                {
                    "comment": "Slight right turn",
                    "icon": "crossroad_slightly_right",
                    "id": "13923719606342531047",
                    "outcoming_path": {
                        "distance": 117,
                        "duration": 16,
                        "geometry": [
                            {
                                "color": "fast",
                                "length": 131,
                                "selection": "LINESTRING(55.283305 25.215222, 55.283255 25.215294, 55.283222 25.215348, 55.283198 25.215406, 55.283186 25.215467, 55.283182 25.215520, 55.283188 25.215584, 55.283194 25.215607, 55.283205 25.215646, 55.283246 25.215714, 55.283318 25.215798, 55.283403 25.215884, 55.283514 25.215974, 55.283545 25.215996, 55.283615 25.216049, 55.283674 25.216083)",
                                "style": "living_zone"
                            }
                        ],
                        "names": []
                    },
                    "outcoming_path_comment": "100 m straight",
                    "turn_angle": 34,
                    "turn_direction": "slightly_right",
                    "type": "crossroad"
                },
                {
                    "comment": "Left turn",
                    "icon": "crossroad_left",
                    "id": "7306897229727142263",
                    "outcoming_path": {
                        "distance": 78,
                        "duration": 22,
                        "geometry": [
                            {
                                "color": "fast",
                                "length": 19,
                                "selection": "LINESTRING(55.283674 25.216083, 55.283720 25.216109, 55.283754 25.216125, 55.283714 25.216195)",
                                "style": "living_zone"
                            },
                            {
                                "color": "ignore",
                                "length": 67,
                                "selection": "LINESTRING(55.283714 25.216195, 55.283662 25.216264, 55.283442 25.216622, 55.283430 25.216641, 55.283414 25.216652, 55.283396 25.216654)",
                                "style": "living_zone"
                            }
                        ],
                        "names": []
                    },
                    "outcoming_path_comment": "80 m straight",
                    "turn_angle": -83,
                    "turn_direction": "left",
                    "type": "crossroad"
                },
                {
                    "comment": "Right turn",
                    "icon": "crossroad_right",
                    "id": "16473782468542146056",
                    "outcoming_path": {
                        "distance": 10,
                        "duration": 3,
                        "geometry": [
                            {
                                "color": "ignore",
                                "length": 11,
                                "selection": "LINESTRING(55.283396 25.216654, 55.283397 25.216726, 55.283386 25.216745)",
                                "style": "normal"
                            }
                        ],
                        "names": []
                    },
                    "outcoming_path_comment": "10 m straight",
                    "turn_angle": 61,
                    "turn_direction": "right",
                    "type": "crossroad"
                },
                {
                    "comment": "Slight right turn",
                    "icon": "crossroad_slightly_right",
                    "id": "16341619082045772458",
                    "outcoming_path": {
                        "distance": 106,
                        "duration": 33,
                        "geometry": [
                            {
                                "color": "ignore",
                                "length": 119,
                                "selection": "LINESTRING(55.283386 25.216745, 55.283500 25.216921, 55.283403 25.217077, 55.283307 25.217230, 55.283278 25.217272, 55.283254 25.217291, 55.283175 25.217294, 55.283143 25.217281, 55.283008 25.217086)",
                                "style": "normal"
                            }
                        ],
                        "names": []
                    },
                    "outcoming_path_comment": "100 m straight",
                    "turn_angle": 37,
                    "turn_direction": "slightly_right",
                    "type": "crossroad"
                },
                {
                    "comment": "finish",
                    "icon": "finish",
                    "id": "3288296233964010742",
                    "outcoming_path_comment": "You have arrived!",
                    "type": "end"
                }
            ],
            "reliability": 1.0,
            "route_id": "far-abroad-cr-back-mosesd.m1/carrouting/1688982610.729515",
            "total_distance": 2151,
            "total_duration": 359,
            "type": "carrouting",
            "ui_total_distance": {
                "unit": "km",
                "value": "2.2"
            },
            "ui_total_duration": "5 min",
            "waypoints": [
                {
                    "original_point": {
                        "lat": 25.20393290763231,
                        "lon": 55.2806666303206
                    },
                    "projected_point": {
                        "lat": 25.20393290763231,
                        "lon": 55.2806666303206
                    },
                    "transit": false
                },
                {
                    "original_point": {
                        "lat": 25.21708612524826,
                        "lon": 55.28300808910866
                    },
                    "projected_point": {
                        "lat": 25.21708612524826,
                        "lon": 55.28300808910866
                    },
                    "transit": false
                }
            ]
        }
    ],
    "type": "result"
}