C# SDK engine

Google Maps Directions

Google Maps route directions by address, data id or coordinates.

engine: google_maps_directions constant: XylopSearchEngines.GoogleMapsDirections GET /search
C# пример

Вызов через XylopSearchClient

using Xylop.Api.Client;

var client = new XylopSearchClient(new HttpClient(), "YOUR_API_KEY");

using var response = await client.SearchJsonAsync(
    XylopSearchEngines.GoogleMapsDirections,
    new Dictionary<string, string?>
    {
        ["start_addr"] = "Austin, TX",
        ["end_addr"] = "San Antonio, TX",
        ["start_coords"] = "30.2672,-97.7431",
        ["end_coords"] = "29.4241,-98.4936",
        ["travel_mode"] = "0",
    });

Для типизированного режима используйте `SearchAsync<TResponse>` и response-модель из `Xylop.Logic.SerpApiResponses.*`, которая входит в пакет C# SDK.

Endpoint

HTTP контракт

URL
https://api.xylop.ru/search
Engine
google_maps_directions
API key
Передается SDK автоматически из настроек клиента.
Входные параметры

Параметры запроса

Параметр Тип Обязателен Значение Описание
api_key SDK string Да Ключ Xylop API. В C# SDK задается один раз в XylopSearchClientOptions.ApiKey или в конструкторе клиента.
engine SDK string Да google_maps_directions Google Maps Directions engine.
start_addr string Нет Austin, TX Start address.
end_addr string Нет San Antonio, TX End address.
start_coords string Нет 30.2672,-97.7431 Start coordinates.
end_coords string Нет 29.4241,-98.4936 End coordinates.
travel_mode number Нет 0 Travel mode code.
Выходные параметры

Поля ответа

Поле Тип Источник Описание
search_metadata object пример ответа Метаданные запроса: статус, идентификатор, время выполнения и служебная информация провайдера.
directions array пример ответа Типизированное поле ответа для этого engine; структура зависит от upstream-провайдера и параметров запроса.
JSON

Пример ответа

{
  "search_metadata": {
    "status": "Success",
    "google_maps_directions_url": "https://www.google.com/maps/dir/..."
  },
  "directions": [
    {
      "title": "Fastest route",
      "distance": "80 mi",
      "duration": "1 hr 20 min"
    }
  ]
}