Answer the question
In order to leave comments, you need to log in
How to get the city id using the GET /regions method via the Yandex API?
Good evening. The Yandex API has a method for getting the city id by the passed city name ( GET /regions ). The task is simply to form a GET request of the format:
curl -i -H 'Content-Type: application/xml' 'https://api.partner.market.yandex.ru/v2/regions.xml?name=Ивановка'
Authorization: OAuth oauth_token="авторизационный_токен", oauth_client_id="идентификатор_приложения"
let webApiUrl = 'https://api.partner.market.yandex.ru/v2/regions.xml?name=Москва;
const resgetRegion = await axios.get(webApiUrl, { headers: {"Authorization" : 'OAuth oauth_token=XxX, oauth_client_id=XxX'} });
Answer the question
In order to leave comments, you need to log in
Since this is a complex request, the browser sends a preliminary request
curl -i 'https://api.partner.market.yandex.ru/v2/regions.json?name=Moskow' \
-H 'Content-Type: application/json' \
-H 'Authorization: OAuth oauth_token="__ТОКЕН__", oauth_client_id="__ИД__"'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question