GET /v1/nearest
Snap to Roads API for the nearest drivable road
Request and response
curl "https://api.wayline.cloud/v1/nearest?point=37.7694,-122.4862" \
-H "Authorization: Bearer $WAYLINE_API_KEY"const res = await fetch(
"https://api.wayline.cloud/v1/nearest?point=37.7694,-122.4862",
{ headers: { Authorization: `Bearer ${process.env.WAYLINE_API_KEY}` } },
);
if (!res.ok) throw new Error(`Wayline ${res.status}: ${await res.text()}`);
const data = await res.json();
console.log(data);import os, requests
res = requests.get(
"https://api.wayline.cloud/v1/nearest",
params={"point": "37.7694,-122.4862"},
headers={"Authorization": f"Bearer {os.environ['WAYLINE_API_KEY']}"},
timeout=10,
)
res.raise_for_status()
print(res.json())package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.wayline.cloud/v1/nearest?point=37.7694,-122.4862", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("WAYLINE_API_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(body))
}<?php
$ch = curl_init("https://api.wayline.cloud/v1/nearest?point=37.7694,-122.4862");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WAYLINE_API_KEY")],
CURLOPT_TIMEOUT => 10,
]);
$data = json_decode(curl_exec($ch), true);
print_r($data);require "net/http"
require "json"
uri = URI("https://api.wayline.cloud/v1/nearest?point=37.7694,-122.4862")
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV.fetch("WAYLINE_API_KEY")}"
res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts JSON.parse(res.body)import java.net.URI;
import java.net.http.*;
public class Main {
public static void main(String[] args) throws Exception {
var req = HttpRequest.newBuilder(URI.create("https://api.wayline.cloud/v1/nearest?point=37.7694,-122.4862"))
.header("Authorization", "Bearer " + System.getenv("WAYLINE_API_KEY"))
.GET().build();
var res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(res.statusCode() + " " + res.body());
}
}import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
Future<void> main() async {
final res = await http.get(
Uri.parse('https://api.wayline.cloud/v1/nearest?point=37.7694,-122.4862'),
headers: {'Authorization': 'Bearer ${Platform.environment['WAYLINE_API_KEY']}'},
);
print(jsonDecode(res.body));
}{
"request_id": "req_01JD8Q8K5Y2D",
"waypoints": [
{
"location": [
37.770599999999995,
-122.4871
],
"name": "",
"distance_meters": 38
}
],
"region": "us",
"map_version": "20261121-2330",
"units_charged": 1
}What the Snap to Roads API gives you
Up to five candidates
Use count to return several nearby road points, ranked by distance.
Distance to road
distance_meters tells you how far the input was from the road — a great signal for GPS quality.
Road names
When OpenStreetMap has a name for the segment, it is returned with the snapped point.
One unit per request
Simple, predictable pricing for high-volume cleanup jobs.
Common uses
Validate pickup pins before dispatch, move parcel lockers or delivery points onto the street network, and flag check-ins that were recorded far from any road.
Frequently asked questions
Is the distance a straight line or a real road distance?
Always real road distance. Every result is computed along the OpenStreetMap road network with a driving profile, never as a straight-line (haversine) estimate.
Which areas do you cover?
Coverage is region-based. The Coverage page lists every enabled region with its map data date. Points outside an enabled region return an OUT_OF_COVERAGE error and are never billed.
Does this snap a whole GPS trace?
Not today. The endpoint snaps individual points. Full trace map-matching is on the roadmap.
Start building in minutes
Create an account, grab a test key and make your first request in under five minutes.