Skip to Content
BuddyGeoDocs

Quickstart

Create a key, turn an address into coordinates with your first search, look up the address for a coordinate, and find both requests and their credits in your dashboard.

This guide sends two requests with one key. The first searches for a place, the CN Tower in Toronto, and returns its coordinates. The second goes the other way: it sends a coordinate near the tower, 43.6426, -79.3871, and gets back the nearest address. You then find both requests in the dashboard. Allow a few minutes and two credits.

Send your first requests

Create a workspace and a key

Sign up, name your workspace, then create a key under API keys. Use a label that says where the key will run, for example "Production API" or "Local development".

The secret is shown only once, right after you create the key, so copy it then. After that, the dashboard shows only a masked form such as bg_live_7f3a…c91d.

Search for an address or place

Put the text in q and the key in the X-API-Key header. URL-encode the query: CN Tower, Toronto becomes CN%20Tower%2C%20Toronto.

curl "https://api.buddygeo.com/v1/search?q=CN%20Tower%2C%20Toronto" \
  -H "X-API-Key: YOUR_API_KEY"

If you'd rather not use a terminal, open the same search in the forward playground or send it from the API reference.

Read the search response

Every request returns the same envelope. outcome and credits_charged say what happened and what it cost. The request_id is also sent in the X-Request-Id response header. For a search, result is an array of candidates, best match first:

{
  "request_id": "req_cj89vnhvmyzl",
  "endpoint": "/v1/search",
  "status": 200,
  "outcome": "success",
  "latency_ms": 83,
  "credits_charged": 1,
  "credits_remaining": 38160,
  "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, Toronto”.",
        "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)",
  "query": { "q": "CN Tower, Toronto", "limit": 5 }
}

Check these fields from the start:

  • result[0].location is the coordinate you came for. result[0].formatted is the full address of the match as one line, and components gives each part separately.
  • match.level says how precise the match is, from address down to locality. A bare city name such as q=Toronto returns the city itself (Toronto, Ontario, Canada at 43.6532, -79.3832, level locality).
  • Every candidate costs the same: one credit per successful search, whatever the number of candidates. q=Springfield returns four cities in Illinois, Missouri, Massachusetts and Oregon, and credits_charged is still 1. Each candidate's match.detail says "4 places match this query; add a city, region or country to narrow it." You can cap the list with limit (1 to 10, default 5).
  • result is null (not an empty array) when nothing matches, for example a query that is only a country, a region or a short number. That is a normal 200 response with outcome: "no_match" and credits_charged: 0.

Look up the address for a coordinate

The second request is a reverse lookup. Pass latitude and longitude as lat and lon, with the same key:

curl "https://api.buddygeo.com/v1/reverse?lat=43.6426&lon=-79.3871" \
  -H "X-API-Key: YOUR_API_KEY"

You can also open it in the reverse playground.

Read the reverse response

The envelope is the same, but result is a single address, not an array:

{
  "request_id": "req_443tx7tuyeps",
  "endpoint": "/v1/reverse",
  "status": 200,
  "outcome": "success",
  "latency_ms": 63,
  "credits_charged": 1,
  "credits_remaining": 38159,
  "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": "Nearest mapped address to the submitted point, 59 m away.",
      "distance_m": 59,
      "osm_type": "way",
      "osm_id": 461829037,
      "category": "tourism",
      "type": "attraction"
    },
    "language": "en",
    "available_languages": ["en", "fr"]
  },
  "error": null,
  "attribution": "© OpenStreetMap contributors (ODbL)",
  "query": { "lat": 43.6426, "lon": -79.3871 }
}
  • result.location is the coordinate of the returned address, not the point you submitted. result.match.distance_m is the distance between the two, here 59 m.
  • result is null when nothing is mapped near the point. That is also a 200 response with outcome: "no_match" and credits_charged: 0.
  • When something goes wrong, for either endpoint, error.next_step tells you in one sentence what to do. See Rate limits and errors.

Find both requests and their credits in your dashboard

Requests sent with a workspace key appear under Request logs, and you can search them by request_id. Each successful request takes one credit, which shows under Usage by endpoint and key. After these two requests you will see one /v1/search and one /v1/reverse, two credits in total.

You can also run signed-in lookups directly from the forward playground and reverse playground: pick one of your workspace keys under API key to bill and log the lookup, or use the unauthenticated public preview without spending workspace credits.

Next steps

On this page