---
title: "ONM API"
description: "Travel time and distance from one origin to many destinations, so you can see which is closest by road."
canonical_url: "http://0.0.0.0:6006/onm"
markdown_url: "http://0.0.0.0:6006/onm.md"
last_updated: "2026-11-17"
x_farming_labs_generated_preamble: true
---

# ONM API
URL: /onm
LLM index: /llms.txt
Description: Travel time and distance from one origin to many destinations, so you can see which is closest by road.

# ONM API

ONM (one to many) measures the trip from a single origin to several destinations at once. For each destination you get the road distance and travel time, so you can pick the closest one by road rather than by straight-line distance. To draw the route to the one you pick, call the [Direction API](/direction).

## When to use it

<Cards>
  <Card icon={<TargetIcon />} title="Nearest place">
    Find the closest hospital, branch or fuel station a user can actually drive to.
  </Card>
  <Card icon={<PaperPlaneIcon />} title="Dispatch">
    Compare the trip from a depot to each waiting order.
  </Card>
  <Card icon={<MixerHorizontalIcon />} title="Ranking options">
    Sort a list of places by how long they take to reach, not by how far away they look.
  </Card>
  <Card icon={<BarChartIcon />} title="Cost estimates">
    Compare fuel or fares from one starting point to several drop-offs.
  </Card>
</Cards>

For distances between every pair of points, not just from one origin, use the [Matrix API](/matrix).

## Request

```bash
GET https://mapapi.gebeta.app/api/route/onm?origin={lat,lng}&json=[{lat,lng},{lat,lng}]&apiKey={your-api-key}
```

| Parameter | Type     | Required | Description                                              |
| --------- | -------- | -------- | -------------------------------------------------------- |
| `origin`  | `string` | Yes      | Where every route starts, as `{lat,lng}`.                |
| `json`    | `string` | Yes      | The destinations, as `[{lat,lng},{lat,lng},…]`. Up to 5. |
| `apiKey`  | `string` | Yes      | Your Gebeta Maps API key.                                |

## Example

<Tabs items={["cURL", "JavaScript", "Python", "Go", "PHP", "Ruby", "Rust", "Dart"]}>
<Tab value="cURL">

```bash
curl "https://mapapi.gebeta.app/api/route/onm?origin={9.0105,38.7613}&json=[{8.989022,38.79036},{9.03045,38.76530}]&apiKey={your-api-key}"
```

</Tab>
<Tab value="JavaScript">

```javascript
const origin = "{9.0105,38.7613}";
const destinations = "{8.989022,38.79036},{9.03045,38.76530}";
const url = `https://mapapi.gebeta.app/api/route/onm?origin=${origin}&json=[${destinations}]&apiKey=${apiKey}`;

const response = await fetch(url);
const { origin_to_destination: trips } = await response.json();
console.log(trips.map((trip) => trip.time));
```

</Tab>
<Tab value="Python">

```python
import requests

origin = "{9.0105,38.7613}"
destinations = "{8.989022,38.79036},{9.03045,38.76530}"
url = f"https://mapapi.gebeta.app/api/route/onm?origin={origin}&json=[{destinations}]&apiKey={api_key}"

trips = requests.get(url).json()["origin_to_destination"]
print([trip["time"] for trip in trips])
```

</Tab>
<Tab value="Go">

```go
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
)

func main() {
	apiKey := "{your-api-key}"
	origin := "{9.0105,38.7613}"
	destinations := "{8.989022,38.79036},{9.03045,38.76530}"
	url := fmt.Sprintf("https://mapapi.gebeta.app/api/route/onm?origin=%s&json=[%s]&apiKey=%s", origin, destinations, apiKey)

	resp, err := http.Get(url)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	var result map[string]any
	json.NewDecoder(resp.Body).Decode(&result)
	fmt.Println(result["origin_to_destination"])
}
```

</Tab>
<Tab value="PHP">

```php
<?php
$apiKey = "{your-api-key}";
$origin = "{9.0105,38.7613}";
$destinations = "{8.989022,38.79036},{9.03045,38.76530}";
$url = "https://mapapi.gebeta.app/api/route/onm?origin=$origin&json=[$destinations]&apiKey=$apiKey";

$result = json_decode(file_get_contents($url), true);
print_r(array_column($result["origin_to_destination"], "time"));
```

</Tab>
<Tab value="Ruby">

```ruby
require "net/http"
require "json"

api_key = "{your-api-key}"
origin = "{9.0105,38.7613}"
destinations = "{8.989022,38.79036},{9.03045,38.76530}"
url = URI("https://mapapi.gebeta.app/api/route/onm?origin=#{origin}&json=[#{destinations}]&apiKey=#{api_key}")

trips = JSON.parse(Net::HTTP.get(url))["origin_to_destination"]
puts trips.map { |trip| trip["time"] }
```

</Tab>
<Tab value="Rust">

```rust
use serde_json::Value;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let api_key = "{your-api-key}";
    let origin = "{9.0105,38.7613}";
    let destinations = "{8.989022,38.79036},{9.03045,38.76530}";
    let url = format!(
        "https://mapapi.gebeta.app/api/route/onm?origin={origin}&json=[{destinations}]&apiKey={api_key}"
    );

    let result: Value = reqwest::blocking::get(url)?.json()?;
    println!("{}", result["origin_to_destination"]);
    Ok(())
}
```

</Tab>
<Tab value="Dart">

```dart
import 'dart:convert';
import 'package:http/http.dart' as http;

Future<void> main() async {
  const apiKey = '{your-api-key}';
  const origin = '{9.0105,38.7613}';
  const destinations = '{8.989022,38.79036},{9.03045,38.76530}';
  final url = Uri.parse(
    'https://mapapi.gebeta.app/api/route/onm?origin=$origin&json=[$destinations]&apiKey=$apiKey',
  );

  final result = jsonDecode((await http.get(url)).body);
  print(result['origin_to_destination']);
}
```

</Tab>
</Tabs>

## Response

`origin_to_destination` has one entry per destination. `to` is the destination's position in the `json` list you sent.

```json
{
  "origins": [{ "lat": 9.052066, "lon": 38.710815, "radius": null }],
  "destinations": [
    { "lat": 9.04128, "lon": 38.721692, "radius": null },
    { "lat": 9.048567, "lon": 38.73236, "radius": null }
  ],
  "origin_to_destination": [
    { "from": 0, "to": 0, "distance": 4.008, "time": 611 },
    { "from": 0, "to": 1, "distance": 4.164, "time": 719 }
  ]
}
```

| Field                              | Description                                                         |
| ---------------------------------- | ------------------------------------------------------------------- |
| `origins`                          | The origin, snapped to the nearest road, as `lat` and `lon`.        |
| `destinations`                     | The destinations, snapped the same way, in the order you sent them. |
| `origin_to_destination[].to`       | Position of the destination in the list you sent.                   |
| `origin_to_destination[].distance` | Road distance in kilometers.                                        |
| `origin_to_destination[].time`     | Travel time in seconds.                                             |

In this example, the first destination is the closer one by road: 611 seconds (about 10 minutes) against 719.

## Errors

| Status | Message                          | What to do                                                           |
| ------ | -------------------------------- | -------------------------------------------------------------------- |
| `401`  | `Not Authorized - No Token`      | Add your API key as the `apiKey` parameter.                          |
| `401`  | `Not Authorized - Invalid Token` | The key is wrong or expired. Copy a current key from your dashboard. |
| `404`  | `NoRoute`                        | A destination can't be reached by road from the origin.              |
| `422`  | `InvalidInput`                   | Check that `origin` is `{lat,lng}` and `json` is `[{lat,lng},…]`.    |

```json
{
  "error": {
    "additional": null,
    "code": "A_ERR00004",
    "message": "Invalid access token!",
    "status": 401
  }
}
```

## Limits

- **Destinations:** Up to 5 per request.
- **Rate:** 50 requests per second per API key. Requests above that are rejected, so throttle or batch them.
- **Countries:** The origin and all destinations must be in the same country.

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
Docs-scoped sitemap: [/docs/sitemap.md](/docs/sitemap.md).
Well-known sitemap: [/.well-known/sitemap.md](/.well-known/sitemap.md).
