- Home
- Docs
- API reference
- Search places and addresses by text
API reference
Search places and addresses by text
Free-text place and address search within one coverage region, ranked by relevance and, when `near` is given, by proximity. Suitable for autocomplete as the user types. Billed as one `geocode` unit per successful request.
Endpoint
GET
Bearer Authhttps://api.wayline.cloud/v1/geocodeRequires an API key (authentication). Product overview: Geocoding API. Billing: see units & pricing.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
qrequired | query | string | Search text, up to 200 characters (e.g. Dhanmondi 27, Square Hospital). |
near | query | PointString | Bias results toward this lat,lng (e.g. the user's location); also selects the region. |
region | query | string | Region code to search in. Optional when near is given or only one region offers geocoding. |
limit | query | integer | Number of results (1 to 10).Default: 5 |
lang | query | string | Result language. en (default) or bn (Bengali, where OpenStreetMap has Bengali names).One of: en, bnDefault: en |
types | query | string | Comma-separated place types to return, e.g. street,locality,district,city to skip
shops and other points of interest. Allowed: house (buildings and points of
interest), street, locality, district, city, county, state, country, other.
|
Example
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"
}Response
200 — Geocoding results.
| Field | Type | Description |
|---|---|---|
resultsrequired | Place[] | |
results[].name | string | |
results[].formatted_addressrequired | string | |
results[].locationrequired | Point | Flexible coordinate input accepted as string, object, or array. |
results[].typerequired | string | One of: house, street, locality, district, city, county, state, country, other |
results[].category | string | OpenStreetMap key:value, e.g. amenity:hospital. |
results[].addressrequired | PlaceAddress | Structured address. Components without data are omitted. |
results[].address.house_number | string | |
results[].address.street | string | |
results[].address.locality | string | Neighbourhood or mahalla. |
results[].address.district | string | City area, e.g. Dhanmondi. |
results[].address.city | string | |
results[].address.county | string | In Bangladesh: zila (district). |
results[].address.state | string | In Bangladesh: division. |
results[].address.postcode | string | |
results[].address.country | string | |
results[].address.country_code | string | ISO 3166-1 alpha-2, upper case. |
results[].distance_meters | integer | Straight-line distance from the query point (reverse geocoding only). |
results[].bounding_box | number[] | [min_lat, min_lng, max_lat, max_lng] for areas and long features. |
results[].admin_areas | AdminAreas | Administrative areas containing a point, keyed by level, largest first. In
Bangladesh: division, district, upazila, union. OpenStreetMap boundaries
are used first; gaps are filled from official BBS data (see source). A level is
null only when neither source covers the point.
|
results[].source | string | Dataset of the place: OpenStreetMap (ODbL), GeoNames (CC BY 4.0) or Overture Maps Places (CDLA Permissive 2.0). osm is set only for osm.One of: osm, geonames, overture |
results[].osm | object | Source OpenStreetMap object. Omitted for results without one (e.g. postcode areas). |
admin_areas | AdminAreas | Administrative areas containing a point, keyed by level, largest first. In
Bangladesh: division, district, upazila, union. OpenStreetMap boundaries
are used first; gaps are filled from official BBS data (see source). A level is
null only when neither source covers the point.
|
summary | ReverseSummary | Display-ready description of a reverse-geocoded point. Empty fields are omitted. |
summary.labelrequired | string | |
summary.nearrequired | boolean | The closest match is within near_meters (default 150) of the point. |
summary.distance_metersrequired | integer | null | Straight-line meters from the point to the matched place; null when nothing matched. |
summary.name | string | POI or building name of the match. |
summary.house_number | string | |
summary.road | string | |
summary.neighbourhood | string | |
summary.suburb | string | |
summary.city | string | |
summary.union | string | |
summary.upazila | string | Upazila or thana containing the point. |
summary.district | string | |
summary.division | string | |
summary.postcode | string | |
summary.country | string | |
units_chargedrequired | integer | |
regionrequired | string |
Response headers
X-Request-Id— Unique identifier for tracking and debugging this request.X-RateLimit-Limit— Maximum permitted requests in current window.X-RateLimit-Remaining— Remaining request quota in current window.X-RateLimit-Reset— Seconds until the rate limit window resets.X-Units-Charged— Billable request units consumed by this request.X-Cache— Cache lookup status (`HIT` or `MISS`).X-Region— Region code serving this routing request (e.g. `bd`).
Errors
| Status | When |
|---|---|
400 | Bad request (invalid coordinates, out of coverage, too many elements, etc.). |
401 | Missing or invalid API key, or expired key. |
402 | Free quota exhausted, no payment method, account suspended, or the monthly spend limit you set was reached. Never billed. Raise or remove the limit in the dashboard (Billing) and retry; nothing else changes. |
403 | Account disabled, key IP restriction failed, origin not allowed, or scope not permitted. |
429 | Rate limit exceeded or test key daily quota reached. |
500 | Internal server error. |
503 | Upstream routing service temporarily unavailable. |
Error bodies contain a code such as OUT_OF_COVERAGE — see the error reference.
Try it
Interactive API Console
Sends a real request from your browser using a test key (free, never billed). The key stays in this browser tab only.
No key yet? Create a free test key.