Quickstart — your first request in 5 minutes
Sign up, create a free test key and calculate real road distance and drive time with cURL, JavaScript, Python, Go, PHP, Ruby, Java or Dart.
This guide takes you from zero to a successful 200 OK response from the Distance API. You need a terminal or any language runtime; no SDK install is required.
Create an account
Sign up with your work email. New accounts receive free request units. API keys unlock after your first card payment on the Billing page.
Create a test key
In the dashboard open API keys → Create key, choose Test, and copy the key. It starts with wl_test_ and is shown only once. Test keys are free, never billed, and have a daily cap.
Store it in an environment variable so it never ends up in your code:
export WAYLINE_API_KEY="wl_test_..."Make your first request
Calculate the road distance and drive time between two points. Coordinates are lat,lng — latitude first, like Google Maps.
curl "https://api.wayline.cloud/v1/distance?origin=37.788,-122.4075&destination=37.8044,-122.2712&units=imperial" \
-H "Authorization: Bearer $WAYLINE_API_KEY"const res = await fetch(
"https://api.wayline.cloud/v1/distance?origin=37.788,-122.4075&destination=37.8044,-122.2712&units=imperial",
{ 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/distance",
params={"origin": "37.788,-122.4075", "destination": "37.8044,-122.2712", "units": "imperial"},
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/distance?origin=37.788,-122.4075&destination=37.8044,-122.2712&units=imperial", 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/distance?origin=37.788,-122.4075&destination=37.8044,-122.2712&units=imperial");
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/distance?origin=37.788,-122.4075&destination=37.8044,-122.2712&units=imperial")
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/distance?origin=37.788,-122.4075&destination=37.8044,-122.2712&units=imperial"))
.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/distance?origin=37.788,-122.4075&destination=37.8044,-122.2712&units=imperial'),
headers: {'Authorization': 'Bearer ${Platform.environment['WAYLINE_API_KEY']}'},
);
print(jsonDecode(res.body));
}Read the response
{
"request_id": "req_01JD8Q4ZK7V3",
"distance_meters": 19870,
"duration_seconds": 1260,
"distance_miles": 12.3,
"distance_text": "12.3 mi",
"duration_text": "21 mins",
"origin": {
"location": [
37.788,
-122.4075
],
"snapped": [
37.7881,
-122.4076
],
"distance_to_road_meters": 4
},
"destination": {
"location": [
37.8044,
-122.2712
],
"snapped": [
37.8045,
-122.2713
],
"distance_to_road_meters": 7
},
"snap_distance_meters": 7,
"region": "us",
"map_version": "20261121-2330",
"units_charged": 1
}distance_meters/distance_miles— driving distance along the road network.duration_seconds— estimated drive time (free-flow; no live traffic).origin.snapped/destination.snapped— where each point was snapped onto the road, anddistance_to_road_metersshows how far it moved.regionandmap_version— which dataset answered, for reproducibility.units_charged— billable units (always1for distance). Test keys are never billed.
Got an error instead? Every error has a code and a docs_url. The most common first-request issues:
| Code | Likely cause |
|---|---|
INVALID_API_KEY | The header is missing or the key was copied incompletely. Use Authorization: Bearer $WAYLINE_API_KEY. |
OUT_OF_COVERAGE | A point is outside every enabled region — or lat and lng are swapped. Check Coverage. |
TEST_KEY_LIMIT_REACHED | The test key's daily cap is used up. Wait for the UTC reset or use a live key. |
Go live
When you are ready for production:
- Add a payment method on the Billing page (usage beyond free units is billed monthly in arrears via Paddle).
- Create a Live key (
wl_live_…) and store it in your secrets manager. - Restrict the key by server IP range or, for browser use, by allowed origin. See Key security.
- Optionally set a monthly spend limit.
- Add retries with backoff for
429and5xx. See Errors & retries.