Documentation
The same API in the cloud or on your server: address search, address from coordinates, route optimisation and vector maps. One HTTP call with your key, no SDK.
Getting started
Calls are the same in both ways of using the service; only the base address changes (BASE in the examples):
| On your server | https://maps.your-domain.com — wherever you publish it (or http://127.0.0.1:8000 on the server itself) |
|---|---|
| Hosted API | the address you receive with your key, ending in /v1 |
The map style, the tiles and /health are always at the server root, in the cloud too (no /v1).
Authentication
Every call carries the key in the X-API-Key header. Without a key, or with an invalid one, the answer is 401.
curl -H "X-API-Key: your_api_key" "$BASE/search?q=Madrid" For the map the key goes in the header too; if your library cannot send headers, the ?key= parameter works.
A key in a web page can be seen by anyone. On your server you have a separate key for the web (API_KEY_WEB) with its own per-minute limit; for bulk work, call the API from your backend.
Search addresses
GET /search — free text to coordinates, with the house number when it exists. Returns a list sorted by relevance (empty when nothing is found).
| Parameter | Description |
|---|---|
q | required: the address or place, as a person would write it ("Calle de Alcalá 42, Madrid") |
my_lat, my_lon | optional: sort the results by distance from that point |
Real response (shortened)
[
{
"address": {
"city": "Madrid",
"housenumber": "43",
"postcode": "28014",
"street": "Calle de Alcalá"
},
"boundingbox": [
"40.419053",
"40.419053",
"-3.696644",
"-3.696644"
],
"class": "place",
"display_name": "Calle de Alcalá 43",
"importance": 9.99999999995449e-06,
"lat": "40.4190527",
"lon": "-3.6966436",
"name": "Calle de Alcalá 43",
"place_id": 16225314,
"type": "house"
},
"…"
] lat and lon come as strings, as in Nominatim: convert them to numbers. address holds the parts of the address (street, number, city, postcode…).
Address of a point
GET /reverse?lat=…&lon=… — the nearest address to some coordinates, within 1 km. Returns a single object with the same fields as search, or 404 when nothing is near.
Optimise routes
POST /route/optimize — takes a list of stops and returns the shortest visiting order for one vehicle, with distance, duration and the line to draw. The first stop is the starting point.
| Parameter | Description |
|---|---|
stops | required: at least 2 stops. Each with lat and lon, or with address (geocoded in the same call) |
departure_time | optional, "HH:MM": adds the estimated arrival time to every stop (eta) |
service_seconds | optional: seconds spent at each stop (parking, delivering), added to the estimated times |
Real response (shortened)
{
"ordered_stops": [
{"lat": 40.415034, "lon": -3.7064705, "address": "Plaza Mayor 1, Madrid", "eta": "09:30"},
{"lat": 40.4153, "lon": -3.6845, "eta": "09:41"},
{"lat": 40.4269828, "lon": -3.6873675, "address": "Calle de Serrano 47, Madrid", "approximate": true, "matched": "Calle de Serrano 46", "eta": "09:48"}
],
"geometry": { "type": "LineString", "coordinates": [[-3.706438, 40.415095], [-3.706535, 40.415125], "…"] },
"distance_meters": 5536.7,
"duration_seconds": 722.9
} geometry is a GeoJSON LineString: draw it as is in MapLibre, Leaflet or OpenLayers. When an address is not found the answer is 422, saying which one.
When the requested house number is not in the data, the stop is snapped to the nearest one on the same street and says so: approximate: true and matched with what was found (in the example, 47 becomes 46). Show it to your users so they can check.
POST /route/optimize/csv — the same by uploading a CSV file (field file): one stop per row, as lat,lon or as an address.
Show the map
The server serves a style for MapLibre GL at /styles/OSM%20OpenMapTiles/style.json; tiles, fonts and icons follow from it. Any library that reads vector tiles works too. See the "Map" example below.
Wherever you show the map or results, "© OpenStreetMap contributors" must be visible: the style already includes it.
Errors
| Code | What it means |
|---|---|
400 | malformed request: a missing parameter or invalid JSON |
401 | the X-API-Key header is missing or the key is not valid |
402 | on your server: licence expired or missing (GET /license says which). In the cloud: monthly quota used up |
404 | reverse geocoding: nothing within 1 km |
422 | an address not found, a point outside your data area, or stops no road connects (an island and the mainland): the message says which |
429 | too many requests per minute with that key: retry after a few seconds |
The body of an error is readable text: show it or log it as is.
Code examples
The same cases in the most common languages and libraries. Replace BASE and the key with yours.
BASE=https://maps.your-domain.com # hosted API: the address you received, ending in /v1
KEY=your_api_key
# Address -> coordinates
curl -H "X-API-Key: $KEY" "$BASE/search?q=Calle%20de%20Alcal%C3%A1%2043%2C%20Madrid"
# Coordinates -> nearest address
curl -H "X-API-Key: $KEY" "$BASE/reverse?lat=40.4192&lon=-3.6971"
# Best visiting order for a round (coordinates or written addresses)
curl -X POST "$BASE/route/optimize" \
-H "X-API-Key: $KEY" -H "Content-Type: application/json" \
-d '{"stops":[
{"address":"Plaza Mayor 1, Madrid"},
{"lat":40.4153,"lon":-3.6845},
{"address":"Calle de Serrano 47, Madrid"}
],
"departure_time":"09:30","service_seconds":180}'
# The same from a CSV file: one stop per row, "lat,lon" or an address
curl -X POST "$BASE/route/optimize/csv" -H "X-API-Key: $KEY" -F [email protected] const BASE = 'https://maps.your-domain.com'; // hosted API: the address you received, ending in /v1
const KEY = 'your_api_key';
// Every call carries the key in the X-API-Key header.
async function api(path, options = {}) {
const res = await fetch(BASE + path, {
...options,
headers: { 'X-API-Key': KEY, ...options.headers },
});
if (!res.ok) throw new Error(`${res.status}: ${await res.text()}`);
return res.json();
}
// Address -> coordinates (lat and lon come as strings, like Nominatim)
const results = await api('/search?q=' + encodeURIComponent('Calle de Alcalá 43, Madrid'));
const first = results[0];
console.log(Number(first.lat), Number(first.lon), first.display_name);
// Coordinates -> nearest address
const place = await api('/reverse?lat=40.4192&lon=-3.6971');
// Best visiting order
const route = await api('/route/optimize', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
stops: [
{ address: 'Plaza Mayor 1, Madrid' },
{ lat: 40.4153, lon: -3.6845 },
{ address: 'Calle de Serrano 47, Madrid' },
],
departure_time: '09:30', // optional: adds an "eta" to every stop
}),
});
console.log(route.distance_meters / 1000, 'km', route.ordered_stops); var BASE = 'https://maps.your-domain.com';
var KEY = 'your_api_key';
// Address -> coordinates
$.ajax({
url: BASE + '/search',
data: { q: 'Calle de Alcalá 43, Madrid' },
headers: { 'X-API-Key': KEY }
}).done(function (results) {
if (results.length) console.log(results[0].lat, results[0].lon, results[0].display_name);
}).fail(function (xhr) {
console.error(xhr.status, xhr.responseText);
});
// Best visiting order: JSON body, so contentType and JSON.stringify
$.ajax({
url: BASE + '/route/optimize',
method: 'POST',
contentType: 'application/json',
headers: { 'X-API-Key': KEY },
data: JSON.stringify({
stops: [
{ address: 'Plaza Mayor 1, Madrid' },
{ lat: 40.4153, lon: -3.6845 },
{ address: 'Calle de Serrano 47, Madrid' }
]
})
}).done(function (route) {
$('#total').text((route.distance_meters / 1000).toFixed(1) + ' km');
}); <!-- AddressSearch.vue: a search box with results as you type -->
<script setup>
import { ref, watch } from 'vue';
const BASE = import.meta.env.VITE_MAPS_URL; // e.g. https://maps.your-domain.com
const KEY = import.meta.env.VITE_MAPS_KEY;
const query = ref('');
const results = ref([]);
const error = ref('');
let timer, controller;
watch(query, (q) => {
clearTimeout(timer);
if (q.trim().length < 3) { results.value = []; return; }
// Wait for a pause in typing, and cancel the previous request.
timer = setTimeout(async () => {
controller?.abort();
controller = new AbortController();
try {
const res = await fetch(`${BASE}/search?q=${encodeURIComponent(q)}`, {
headers: { 'X-API-Key': KEY },
signal: controller.signal,
});
if (!res.ok) throw new Error(await res.text());
results.value = await res.json();
error.value = '';
} catch (e) {
if (e.name !== 'AbortError') error.value = e.message;
}
}, 250);
});
const emit = defineEmits(['select']);
</script>
<template>
<input v-model="query" placeholder="Calle, número, ciudad" />
<p v-if="error">{{ error }}</p>
<ul>
<li v-for="r in results" :key="r.place_id"
@click="emit('select', { lat: +r.lat, lon: +r.lon, label: r.display_name })">
{{ r.display_name }}
</li>
</ul>
</template> // AddressSearch.jsx: a search box with results as you type
import { useEffect, useState } from 'react';
const BASE = import.meta.env.VITE_MAPS_URL; // e.g. https://maps.your-domain.com
const KEY = import.meta.env.VITE_MAPS_KEY;
export function AddressSearch({ onSelect }) {
const [query, setQuery] = useState('');
const [results, setResults] = useState([]);
const [error, setError] = useState('');
useEffect(() => {
if (query.trim().length < 3) { setResults([]); return; }
const controller = new AbortController();
// Wait for a pause in typing; a new keystroke cancels this request.
const timer = setTimeout(async () => {
try {
const res = await fetch(`${BASE}/search?q=${encodeURIComponent(query)}`, {
headers: { 'X-API-Key': KEY },
signal: controller.signal,
});
if (!res.ok) throw new Error(await res.text());
setResults(await res.json());
setError('');
} catch (e) {
if (e.name !== 'AbortError') setError(e.message);
}
}, 250);
return () => { clearTimeout(timer); controller.abort(); };
}, [query]);
return (
<div>
<input value={query} onChange={(e) => setQuery(e.target.value)} placeholder="Calle, número, ciudad" />
{error && <p>{error}</p>}
<ul>
{results.map((r) => (
<li key={r.place_id} onClick={() => onSelect({ lat: +r.lat, lon: +r.lon, label: r.display_name })}>
{r.display_name}
</li>
))}
</ul>
</div>
);
} use Illuminate\Support\Facades\Http;
// config/services.php: 'maps' => ['url' => env('MAPS_URL'), 'key' => env('MAPS_KEY')]
$maps = Http::baseUrl(config('services.maps.url'))
->withHeaders(['X-API-Key' => config('services.maps.key')])
->timeout(10);
// Address -> coordinates
$results = $maps->get('/search', ['q' => 'Calle de Alcalá 43, Madrid'])->throw()->json();
$lat = (float) $results[0]['lat'];
$lon = (float) $results[0]['lon'];
// Best visiting order
$route = $maps->post('/route/optimize', [
'stops' => [
['address' => 'Plaza Mayor 1, Madrid'],
['lat' => 40.4153, 'lon' => -3.6845],
['address' => 'Calle de Serrano 47, Madrid'],
],
])->throw()->json();
$km = $route['distance_meters'] / 1000;
// Results are yours: store them, no limit. import requests
BASE = "https://maps.your-domain.com"
session = requests.Session()
session.headers["X-API-Key"] = "your_api_key"
# Address -> coordinates
results = session.get(f"{BASE}/search", params={"q": "Calle de Alcalá 43, Madrid"}, timeout=10)
results.raise_for_status()
first = results.json()[0]
print(float(first["lat"]), float(first["lon"]), first["display_name"])
# Best visiting order
route = session.post(f"{BASE}/route/optimize", timeout=60, json={
"stops": [
{"address": "Plaza Mayor 1, Madrid"},
{"lat": 40.4153, "lon": -3.6845},
{"address": "Calle de Serrano 47, Madrid"},
],
})
route.raise_for_status()
print(route.json()["distance_meters"] / 1000, "km") <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/maplibre-gl.css">
<script src="https://unpkg.com/[email protected]/dist/maplibre-gl.js"></script>
<div id="map" style="height:420px"></div>
<script>
// The server root, exactly as in GEOCODE_BASE_URL (the style points its tiles
// there): for the hosted API too, without /v1.
const ROOT = 'https://maps.your-domain.com';
const KEY = 'your_api_key';
const map = new maplibregl.Map({
container: 'map',
style: ROOT + '/styles/OSM%20OpenMapTiles/style.json',
center: [-3.7038, 40.4168],
zoom: 12,
// Style, tiles, fonts and icons need the key too: add it to every request to our server.
transformRequest: (url) => url.startsWith(ROOT) ? { url, headers: { 'X-API-Key': KEY } } : { url },
});
// Draw a route returned by /route/optimize
function drawRoute(route) {
map.addSource('route', { type: 'geojson', data: { type: 'Feature', geometry: route.geometry } });
map.addLayer({ id: 'route', type: 'line', source: 'route', paint: { 'line-color': '#0A7DB0', 'line-width': 4 } });
route.ordered_stops.forEach((s, i) => new maplibregl.Marker().setLngLat([s.lon, s.lat]).addTo(map));
}
</script> Try it with Monaco
The free test package carries Monaco: a few MB, it installs in minutes on any Linux server with Docker and works exactly like a whole country. Install it and run these calls from the package folder:
BASE=http://127.0.0.1:8000
KEY=$(grep '^API_KEY_WEB=' .env | cut -d= -f2) # the web key, also in API-KEYS.txt
# 1. Is it up, and is the licence valid?
curl "$BASE/health"
curl "$BASE/license"
# 2. Address -> coordinates: expect lat ≈ 43.73, lon ≈ 7.42
curl -H "X-API-Key: $KEY" "$BASE/search?q=Place%20du%20Casino%2C%20Monaco"
# 3. Coordinates -> nearest address
curl -H "X-API-Key: $KEY" "$BASE/reverse?lat=43.7396&lon=7.4277"
# 4. A round of three stops: expect ordered_stops and a few km
curl -X POST "$BASE/route/optimize" \
-H "X-API-Key: $KEY" -H "Content-Type: application/json" \
-d '{"stops":[
{"lat":43.7396,"lon":7.4277},
{"lat":43.7347,"lon":7.4206},
{"lat":43.7308,"lon":7.4197}
]}'
# 5. The map: open examples/index.html, set the address and the web key Every call should answer with JSON and no error. If so, your server is ready for your country package: only the size of the data changes. These same commands run automatically against the Monaco package before each version of this documentation.
Installing on your server
What you receive is one archive with everything inside: compiled Docker images, the data of your countries already built. Your licence (<code>license.json</code>) is downloaded from your order page and copied into the folder. Nothing to compile or import.
Requirements
- Linux with Docker and Docker Compose v2 (
docker compose versionmust work) andcurl - An SSD or NVMe disk: on a spinning disk the search engine does not start
- Memory: 2 GB for a small area such as Monaco, 8 GB for a country such as Spain; for a continent we size it with you
- Free space: the GB of your data plus about 2 GB
Install
Unpack the archive and run the installer. It loads the images, starts the services and checks health, licence, search, a route and the tiles: every line should read ok. If something fails, fix what it reports and run it again: it resumes where it stopped.
tar xzf <package>.tar.gz
cd <package>
cp ~/license.json . # downloaded from your order page
./install.sh # loads the images, starts the services, checks everything
# or, with a web page and buttons (opens on http://127.0.0.1:8090):
./installer The installer page only listens locally. From another computer: ssh -L 8090:127.0.0.1:8090 user@server and open the same address in your browser.
Your API keys: where to find them
API keys are not sent by email: the first install creates them on your server, prints them when it finishes and writes them in the file API-KEYS.txt of the package folder (the real settings are in .env, a hidden file). API_KEY_WEB is the one for web pages and examples/index.html. Not even we know them. To change one, edit .env and run docker compose up -d api.
API_KEY_WEB=rk_... # for web pages (visible in the browser)
API_KEY_ANDROID=rk_... # for mobile apps
API_KEY_IOS=rk_...
RATE_LIMIT_WEB=600:minute # per key Putting it online
The API listens on 127.0.0.1:8000 only. To use it from other machines, put your usual HTTPS proxy in front of it (nginx, Caddy, Traefik). An nginx example:
server {
listen 443 ssl http2;
server_name maps.your-domain.com;
ssl_certificate /etc/letsencrypt/live/maps.your-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/maps.your-domain.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 120s; # long rounds take a while
}
} Then set the public address in .env (the map style browsers receive points there) and restart the API:
# .env
GEOCODE_BASE_URL=https://maps.your-domain.com
docker compose up -d api Licence and updates
license.json is your licence and is checked offline. In the 30 days before it expires the API adds a warning header; after the grace period it stops answering until renewal. To renew, replace license.json: it is read again within an hour, no restart needed.
With maintenance active you receive updated data every quarter: a new archive of the same kind, installed the same way.
Checking and managing the service
After installing, ./install.sh is not needed again: the service is run with ./mapsinhouse (start, stop, status, keys, free space) and starts by itself when the server reboots. The package page examples/index.html shows the map, search, the address of a point and route optimisation against your own API: open it and enter the address and the web key. From the terminal:
./mapsinhouse status # is it running? licence state, address
./mapsinhouse stop # stop it (the data stays)
./mapsinhouse start # start it again — no need to run ./install.sh
./mapsinhouse restart # after editing .env, e.g. a new key
./mapsinhouse logs # what the API is doing (Ctrl+C to leave)
./mapsinhouse keys # your API keys
./mapsinhouse cleanup # free space: delete images.tar.gz once installed
./mapsinhouse remove # remove the containers (start recreates them, data kept)
./mapsinhouse uninstall # remove everything from Docker (asks first)
./check-maps.sh # deep check: search, reverse, routing, tiles Common problems
| Symptom | Cause and fix |
|---|---|
docker compose not found | Docker Compose v2 is missing: install the docker-compose-plugin package |
| The search engine does not start | the disk is not SSD/NVMe, or there is not enough memory |
Every call answers 401 | the X-API-Key header is missing or the key does not match .env |
Every call answers 402 | licence expired or license.json missing: GET /license says which |
| The map shows no tiles in the browser | GEOCODE_BASE_URL does not match the address you use in the browser |
Versions and changes
This page describes version 1.0 of the API and the package. If your package is older, open its own documentation: it is kept as it was, so you always read the one for what you have installed. Your package version is in .env (ROTTA_VERSION).
v1.0 (2026-10) — current
- First public version: search, address of a point, route optimisation (JSON, CSV, photo), vector map, licence checked offline.
Earlier versions
This is the first version: there are no earlier ones yet.