Answer the question
In order to leave comments, you need to log in
How to get approximate data on the cost of a Yandex trip (or other services)?
Good afternoon, I have the following situation. We develop food delivery on nodejs / react. There is such an idea that couriers will deliver food through Yandex taxi. For example, the order value is 3500 + shipping costs. Prices vary at different times of the day. You need to know this in advance because payment takes place on the site using the Sberbank, in which the delivery point is listed as a regular product . I
imagine the situation as follows
The user enters the address (without it, he cannot add to the basket), and the API is requested for the cost of delivery. The problem is that Yandex Taxi has its own API in the beta version on request. Two weeks passed without a word from them. Maybe there are some other options to get the cost of a taxi. Or maybe other taxi companies offer delivery?
https://taxi.yandex.ru/
Here is a good example, we enter data and get the cost
Thank you
Answer the question
In order to leave comments, you need to log in
It will be enough to get the coordinates of the beginning and end of the trip and send a request to https://taxi.yandex.ru/3.0/routestats
var axios = require('axios');
var data = JSON.stringify({
"route": , // координаты откуда - куда
"skip_estimated_waiting": true,
"supports_forced_surge": false
});
var config = {
method: 'post',
url: 'https://taxi.yandex.ru/3.0/routestats',
headers: {
'Content-Type': 'application/json'
},
data: data
};
axios(config)
.then(function (response) {
console.log(`Маршрут составит ${response.data.distance} и займет ${response.data.time}`);
response.data.service_levels.forEach(function (i) {
console.log(`${i.name} - ${i.price}`);
})
})
.catch(function (error) {
console.log(error);
});
/* Output:
Маршрут составит 7,2 км и займет 28 мин
Эконом - 430 руб.
Комфорт - 610 руб.
Комфорт+ - 790 руб.
Business - 1060 руб.
Детский - 710 руб.
Минивэн - 690 руб.
Доставка - 460 руб.
Курьер - 390 руб.
Грузовой - 1000 руб.
*/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question