Driving distance, travel time and the route line between places. Built on OSRM, with a safe fallback so your app never gets stuck.
osrm_live_… and is shown only once, so keep it safe.Authorization header with every request.curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://www.api.fastride.pk/v1/route?from=31.5204,74.3587&to=33.6844,73.0479"
Answer:
{ "distance_km": 294.48, "duration_min": 298.2, "geometry": null, "source": "osrm" }
Base URL: https://www.api.fastride.pk/v1 · Everything is https, JSON in and out, lat,lng order for the coordinates you send.
Every request needs your API key. Use either header (the first is preferred):
Authorization: Bearer osrm_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
X-Api-Key: osrm_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
GET or POST /v1/route
The driving distance and time between two places, or through several places in order (pickup → stop → drop-off).
| Parameter | Required | Description |
|---|---|---|
from | yes* | Start as lat,lng, e.g. 31.5204,74.3587 |
to | yes* | End as lat,lng |
points | yes* | Instead of from/to: 2 to 10 points, lat,lng separated by semicolons: 31.52,74.35;32.1,73.9;33.68,73.04 |
geometry | no | 1 to also get the line to draw on a map (GeoJSON). Default 0. |
* send either from and to, or points. With POST you can send JSON instead:
POST /v1/route
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
{ "points": [[31.5204, 74.3587], [32.1, 73.9], [33.6844, 73.0479]], "geometry": true }
GET /v1/health – is the routing server up?
{ "status": "ok", "osrm": "up", "time": "2026-11-16T10:00:00+00:00" }
If osrm is down, route requests still work but answer with a straight-line estimate ("source": "estimate").
GET /v1/usage – your limits and what is left. These calls count as requests too.
{
"user": "Acme Delivery",
"limits": { "per_minute": 60, "per_day": 5000, "per_month": 100000 },
"used": { "last_minute": 3, "today": 120, "this_month": 4310 },
"remaining": { "per_minute": 57, "today": 4880, "this_month": 95690 }
}
0 in a limit means unlimited (and remaining is then null).
| Field | Type | Meaning |
|---|---|---|
distance_km | number | Road distance in kilometres (2 decimals). |
duration_min | number | Expected driving time in minutes. OSRM knows no live traffic, so its time is increased by a traffic factor (default 1.25). |
geometry | object | null | With geometry=1: a GeoJSON LineString. Its coordinates are [lng, lat] (GeoJSON order), unlike the lat,lng you send. |
source | string | osrm = a real road route. estimate = the routing server did not answer, so the straight-line distance × 1.35 at 25 km/h was used. Treat estimates as approximate. |
Every response has these headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-Quota-Daily-Remaining, X-Quota-Monthly-Remaining.
Errors are JSON with a machine-readable code:
{ "error": { "code": "rate_limited", "message": "Too many requests: your limit is 60 per minute. ..." } }
| HTTP | code | What to do |
|---|---|---|
| 401 | missing_key | Send your key in the Authorization header. |
| 401 | invalid_key / revoked_key | The key is wrong or was revoked. Ask for a new one. |
| 403 | account_suspended | Your account is suspended. Contact the administrator. |
| 404 | unknown_action | Use route, health or usage. |
| 422 | bad_points / bad_coordinate | Check the coordinates: lat,lng, latitude −90…90, longitude −180…180, between 2 and 10 points. |
| 429 | rate_limited | Too many requests this minute. Wait for Retry-After seconds. |
| 429 | daily_quota_exceeded / monthly_quota_exceeded | Your quota is used up. It resets at midnight (daily) or on the 1st (monthly). |
Each account has three limits, set by the administrator: requests per minute, per day and per month. Only successful requests (status below 400) count. Check /usage or the response headers to see where you stand. All keys of one account share the same limits.
Need more? Ask the administrator to raise your limits.
# distance and time
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://www.api.fastride.pk/v1/route?from=31.5204,74.3587&to=33.6844,73.0479"
# with the line to draw on a map
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://www.api.fastride.pk/v1/route?from=31.5204,74.3587&to=33.6844,73.0479&geometry=1"
# through three places
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://www.api.fastride.pk/v1/route?points=31.52,74.35;32.1,73.9;33.68,73.04"const res = await fetch('https://www.api.fastride.pk/v1/route?from=31.5204,74.3587&to=33.6844,73.0479&geometry=1', {
headers: { Authorization: 'Bearer ' + process.env.OSRM_API_KEY }, // call from your server, not from a public web page
});
if (!res.ok) throw new Error((await res.json()).error.message);
const route = await res.json();
console.log(route.distance_km, 'km', route.duration_min, 'min', route.source);import os, requests
r = requests.get("https://www.api.fastride.pk/v1/route",
params={"from": "31.5204,74.3587", "to": "33.6844,73.0479", "geometry": 1},
headers={"Authorization": "Bearer " + os.environ["OSRM_API_KEY"]}, timeout=15)
r.raise_for_status()
route = r.json()
print(route["distance_km"], "km", route["duration_min"], "min", route["source"])$ch = curl_init('https://www.api.fastride.pk/v1/route?from=31.5204,74.3587&to=33.6844,73.0479');
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 15,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('OSRM_API_KEY')]]);
$route = json_decode(curl_exec($ch), true);
echo $route['distance_km'] . ' km, ' . $route['duration_min'] . ' min';
// Laravel: Http::withToken(env('OSRM_API_KEY'))->get('https://www.api.fastride.pk/v1/route', ['from' => '31.5204,74.3587', 'to' => '33.6844,73.0479'])->json();final res = await http.get(
Uri.parse('https://www.api.fastride.pk/v1/route?from=31.5204,74.3587&to=33.6844,73.0479&geometry=1'),
headers: {'Authorization': 'Bearer $apiKey'},
);
final route = jsonDecode(res.body);
final km = route['distance_km'];
// route['geometry']['coordinates'] is a list of [lng, lat] pairs for a polylineThe answer appears here.
source. If it is estimate, show the number as approximate or retry a little later.Retry-After seconds, never by retrying in a tight loop.geometry=1 makes the answer larger).Questions, more quota or a new key? Write to support@example.com. Please include your account email and, for a problem, the time of the request and the error code.
Machine-readable description: openapi.json (OpenAPI 3)