Forward geocoding
GET /v1/search turns an address or place name into coordinates and returns every plausible candidate when a query is ambiguous.
Forward geocoding goes from text to a point: you send an address or a place name, BuddyGeo returns the places that match, best first.
Request
curl "https://api.buddygeo.com/v1/search?q=CN%20Tower" \
-H "X-API-Key: YOUR_API_KEY"| Parameter | Required | Description |
|---|---|---|
q | Yes | Address or place name, up to 200 characters. URL-encode it |
lang | No | Language of the results as a BCP 47 tag. Default en. See Languages |
limit | No | Maximum number of candidates, 1 to 10. Default 5 |
country | No | Restrict candidates to one country: a two-letter ISO 3166-1 code such as ca |
Response
The envelope is the same as for reverse geocoding. The difference is result: an array of candidates, each with the same fields as a reverse result, or null when nothing matches. query.limit shows the limit that was applied.
{
"request_id": "req_2a6f81d0c5b4",
"endpoint": "/v1/search",
"status": 200,
"outcome": "success",
"latency_ms": 71,
"credits_charged": 1,
"credits_remaining": 38160,
"query": { "q": "CN Tower", "limit": 5 },
"result": [
{
"place_id": "toronto-cn-tower",
"formatted": "290 Bremner Boulevard, Toronto, ON M5V 3L9, Canada",
"components": {
"name": "CN Tower",
"house_number": "290",
"street": "Bremner Boulevard",
"neighbourhood": "Entertainment District",
"locality": "Toronto",
"region": "Ontario",
"region_code": "ON",
"postcode": "M5V 3L9",
"country": "Canada",
"country_code": "ca"
},
"location": { "lat": 43.642196, "lon": -79.386628 },
"bounding_box": [43.641657, 43.642735, -79.387373, -79.385883],
"match": {
"level": "address",
"detail": "Matched the place name for “CN Tower”.",
"distance_m": 0,
"osm_type": "way",
"osm_id": 461829037,
"category": "tourism",
"type": "attraction"
},
"language": "en",
"available_languages": ["en", "fr"]
}
],
"error": null,
"attribution": "© OpenStreetMap contributors (ODbL)"
}result[n].location is the coordinate to use. match.distance_m is 0 for search results, because there is no submitted point to measure from.
A search that returns one candidate and a search that returns five both cost one credit: the request is charged, not the candidates.
Ambiguous queries
Many names belong to more than one place. q=Springfield returns multiple cities, and q=Paris returns Paris in France, Texas and Ontario. Every candidate's match.detail says so:
{
"place_id": "paris-france",
"formatted": "Paris, Île-de-France, France",
"match": {
"level": "locality",
"detail": "Matched the place name for “Paris”. 3 places match this query; add a city, region or country to narrow it."
}
}Three ways to deal with it:
- Narrow the query. Add a city, region or country to
q, or filter withcountry.q=Paris&country=caleaves only Paris, Ontario. - Let the user choose. Show the candidates and store the one that was picked. The forward playground lists them next to a map.
- Take the first. Candidates are ordered by how well they match, then by the prominence of the place. Only do this when a wrong guess is cheap.
Nothing found
A query that matches nothing returns HTTP 200 with result: null, outcome: "no_match" and credits_charged: 0:
curl "https://api.buddygeo.com/v1/search?q=zzyzx%20quartz%2012345" \
-H "X-API-Key: YOUR_API_KEY"result is null, not an empty array, so check it before reading result[0]. An empty q, a q longer than 200 characters or a malformed country is rejected with 400 invalid_query instead.
From a search result to a reverse lookup
To see what address a found coordinate snaps to, pass result[n].location to /v1/reverse. In the forward playground, Reverse lookup this point does exactly that and carries the coordinates over.
Open in the app
Forward playground
Search for the CN Tower and see the match on the map.
An ambiguous query
Four places called Springfield: pick one.
GET /v1/search in the API reference
Schema, examples and a Try it console.
Related guides
Reverse geocoding
GET /v1/reverse turns a latitude and longitude into the nearest mapped address, with its components, its own coordinate and an explanation of the match.
Languages
Ask for results in a language with the lang parameter, and read result.language to see which language you received.
Rate limits and errors
Every error code the API returns, its HTTP status, whether it was charged and what to do next. Includes the throughput limit and how to retry.
Nominatim migration
Keep your /reverse and /search requests. Change the base URL, add the X-API-Key header, and check the short list of differences.
Authentication
Send your key in the X-API-Key header. Create one key per environment, rotate with an overlap and revoke what you no longer use.
Reverse geocoding
GET /v1/reverse turns a latitude and longitude into the nearest mapped address, with its components, its own coordinate and an explanation of the match.