A 2GIS API workflow: search, business card, reviews
One path through the 2GIS API starts with post-2gis-search:
- Send a text in
body.queryand a region inbody.city, then pick the rows you care about. - Take the
org_idof a row: it is the value thatpost-2gis-detailandpost-2gis-reviewstake inbody.org_id. - Call the business card only for branches where the attributes, the description or the nearest metro stations matter, since a search row already contains contacts, hours, the rating and the review count.
- Read reviews only where
review_countshows there is something to read.
Choose the region before you search
A search sent without body.city and without body.ll does not fail; it quietly runs in Moscow, which is easy to miss when the results look plausible. For any other place, look the region up with post-2gis-cities, narrowing the list with body.country set to a code such as kz, and store what you need.
Pass the region's code or its region_id in body.city. The Russian name works as well, but when you request region names in English or Arabic through body.locale, keep the code or the id, because the name body.city takes is the Russian one.
Browse by category with the rubric tree
Browsing by category takes three calls:
- Call
post-2gis-rubricswithoutbody.parent_idto get the top groups of a region, about 28 of them. - Pass one group's
rubric_idasbody.parent_idto get the rubrics inside that group, each withbranch_countandorg_countfor the region you asked about. - Send the chosen
rubric_idtopost-2gis-searchinbody.rubric_id; it works on its own or together withbody.query, which narrows the category by text.
Rubric 162, for example, stands for coffee shops in Russia. Rubric ids also appear on search rows in rubrics, so a business you found by name tells you which rubric to use for similar places.
Ask for the rubrics of the same region you are going to search, so that the counts describe that place. To keep only places open at a given moment, add body.open_at with a weekday from mon to sun and a local time joined by a comma, such as fri,23:30; it narrows a rubric search in the same way as a text search.
Searching around a point
body.ll takes a point written as longitude, a comma and latitude, such as 37.6173,55.7558. Writing latitude first still produces a valid-looking string that points somewhere else, so check the order whenever you copy coordinates from another tool. Because the point locates the search, body.city can be left out when body.ll is sent.
Add body.radius in metres, from 1 up to 40000, to keep only the branches inside that circle, and set body.sort to distance to list the nearest first; both need body.ll. Each row returns its own latitude and longitude, so you can compute and show the distance from the point yourself.
Paging through search results
Search uses numbered pages: body.page counts from 1 and body.page_size sets the rows per page, 12 unless you choose up to 50. Raise body.page until a page comes back empty, which happens once the number passes the last page, and keep the query, the filters and the sort identical from page to page. Page numbers stop at 1000, so one search is paged through at most 1000 pages of up to 50 rows each.
For a larger set, split the work into narrower searches by rubric, by filter or in smaller circles around points; a branch returned by more than one of them carries the same org_id, so drop repeats by that id. Reviews work differently: a call to post-2gis-reviews with body.cursor left empty returns one page of reviews, up to 50 set in body.limit.
Field names and languages that trip up 2GIS API calls
The request body also accepts several alternative names:
- the page size of a search is
body.page_size, andlimitis also accepted there - the branch id goes in
body.org_id, andidorbranch_idalso work - the text goes in
body.query, andqortextalso work - the region goes in
body.city, andregionalso works - the point goes in
body.ll, andpointalso works
Language is a separate choice: body.locale sets the language of names and rubric labels on search, the business card and rubrics, and of region names on the cities list, using codes such as en_AE, ar_AE, ru_KZ, kk_KZ or uz_UZ. When it is left out, the first three use the region's own locale and the cities list uses Russian.
2GIS in brief
Besides Russia, 2GIS operates in countries such as Kazakhstan, Uzbekistan, Kyrgyzstan, Azerbaijan and the United Arab Emirates. Reviews on 2GIS are written by signed-in users, who rate a company from one to five stars next to their text.
Listed companies can manage their own card through a business account, where they update opening hours, contacts and photos and answer the reviews customers leave. Directory data grouped by category and area serves market work such as studying competitors, choosing a location for a new business and spotting underserved niches, and urban planners use counts of businesses by category to judge how well an area is served by social and household services.
[
{
"body": {
"city": "moscow",
"query": "кофейня",
"sort": "rating",
"page_size": 20
}
},
{
"body": {
"org_id": "70000001113359188",
"locale": "ru_RU"
}
},
{
"body": {
"org_id": "70000001113359188",
"limit": 20,
"sort": "newest"
}
}
]{
"body": {
"query": "coffee",
"ll": "37.6173,55.7558",
"radius": 1000,
"sort": "distance"
}
}[
{
"body": {
"city": "moscow"
}
},
{
"body": {
"city": "moscow",
"parent_id": "5419"
}
},
{
"body": {
"city": "moscow",
"rubric_id": "162",
"open_at": "fri,23:30"
}
}
]Server-side request template
This server-side template shows authentication and request identity using the first operation of this API. Choose the operation for your use case and check its current availability and price on the API page. After a timeout, resend the unchanged request with the same Idempotency-Key.
The gateway request is always POST.
Use a JSON object with the documented path, query, headers and body locations; omit unused locations. input.headers is JSON data for the operation, not browser request headers. Do not put credentials here. Keep body arrays, scalar values and null as documented; omission is different from null.
# Server-side only. Set KAKIAPI_API_KEY in your secret manager.
# Every gateway operation is called with POST.
# Only operations shown as enabled on the API page can be called.
# Generate once per intent; retain the same value on status checks.
REQUEST_ID="$(uuidgen)"
curl --request POST 'https://kakiapi.com/api/v1/twogis/post-2gis-cities' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"country":"kz"}}'Integration checklist
- The API key is stored in a server-side secret manager and never sent to a browser.
- Each request carries its own Idempotency-Key, kept until the request has a final answer.
- The integration reads ok and error.code and handles each error code as the error table describes.
- An uncertain POST is inspected using its original identity, never blindly repeated with a new one.
- The operation’s current availability and price have been checked on its API page.
2GIS Business Listings and Reviews API overview and prices · Read the API reference · Try it in the playground