GET /v1/geocode
Geocoding API for address and place search
Request and response
curl "https://api.wayline.cloud/v1/geocode?q=Dhanmondi%2027&near=23.7925,90.4078&limit=1" \
-H "Authorization: Bearer $WAYLINE_API_KEY"const res = await fetch(
"https://api.wayline.cloud/v1/geocode?q=Dhanmondi%2027&near=23.7925,90.4078&limit=1",
{ 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/geocode",
params={"q": "Dhanmondi 27", "near": "23.7925,90.4078", "limit": "1"},
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/geocode?q=Dhanmondi%2027&near=23.7925,90.4078&limit=1", 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/geocode?q=Dhanmondi%2027&near=23.7925,90.4078&limit=1");
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/geocode?q=Dhanmondi%2027&near=23.7925,90.4078&limit=1")
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/geocode?q=Dhanmondi%2027&near=23.7925,90.4078&limit=1"))
.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/geocode?q=Dhanmondi%2027&near=23.7925,90.4078&limit=1'),
headers: {'Authorization': 'Bearer ${Platform.environment['WAYLINE_API_KEY']}'},
);
print(jsonDecode(res.body));
}{
"results": [
{
"name": "Dhanmondi 27",
"formatted_address": "Dhanmondi 27, Dhanmondi, Dhaka 1209, Bangladesh",
"location": {
"lat": 23.7465,
"lng": 90.376
},
"type": "locality",
"address": {
"district": "Dhanmondi",
"city": "Dhaka",
"county": "Dhaka",
"state": "Dhaka Division",
"postcode": "1209",
"country": "Bangladesh",
"country_code": "BD"
},
"source": "osm"
}
],
"admin_areas": {
"division": {
"name": "Dhaka"
},
"district": {
"name": "Dhaka"
},
"upazila": {
"name": "Dhanmondi"
}
},
"units_charged": 1,
"region": "bd"
}What the Geocoding API gives you
Built for search boxes
Results are ranked by relevance and, when you pass near=lat,lng, by proximity to the user, so the right place shows up after a few keystrokes.
Structured addresses
Every result has a formatted_address plus street, locality, district, city, postcode and country fields, and the OpenStreetMap object it came from.
Local names and spelling
Pass lang=bn for Bengali names where OpenStreetMap has them. Place data is merged from OpenStreetMap, GeoNames and Overture Maps to fill rural gaps.
One unit per request
A successful search costs one geocode unit, even when it returns no results. Errors are never billed.
How the Geocoding API works
Wayline runs its own geocoder on open data for each region that offers geocoding. A request searches one region, chosen from the near point or the region parameter, and returns up to 10 candidates. Combine it with the Distance or Distance Matrix API to go from typed addresses to real road distances and drive times in two calls.
Where geocoding is available
Geocoding is region-based, like routing. Bangladesh is covered today, including divisions, districts, upazilas, unions, villages and points of interest. The Coverage page lists every region and the services it offers.
Frequently asked questions
What data does the Geocoding API use?
OpenStreetMap (ODbL), with gaps filled from GeoNames (CC BY 4.0) and Overture Maps Places (CDLA Permissive 2.0). Each result says which dataset it came from. We never use Google or Mapbox data.
Can I use it for autocomplete?
Yes. Send the partial text as q and the user's location as near. Debounce keystrokes (around 200 ms) to keep request counts and cost down.
Which countries are covered?
Geocoding runs per region. Bangladesh is available today; more regions are added as their datasets are prepared. Requests for regions without geocoding return a clear error and are never billed.
How is geocoding billed?
One geocode unit per successful request at the price shown on the pricing page. New accounts get free units that cover every endpoint, geocoding included.
Start building in minutes
Create an account, grab a test key and make your first request in under five minutes.