Data tools / FX, rates, news, weather and knowledge

Geocoding API: city name to latitude and longitude, and the nearest city to a point

Use when you need latitude/longitude for a city name, or the nearest city to a point (forward and reverse geocoding): country, US state, population, distance. Coverage: 12466 GeoNames cities with 50,000+ people plus capitals, city-level only (no street addresses or timezones); an unknown place is refused before any charge. CC BY 4.0 GeoNames. $0.02 per call (USDC or USDT). Or pay by stablecoin transfer with a one-time quote: see /pay.

Price and access

Request

curl -i 'https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/v1/geocode?q=Austin%2C+TX'
ParameterRequiredWhat it is
qnoCity name for forward geocoding, e.g. Paris, Austin, TX or Lyon, France; in an address only the city part is matched
latnoLatitude in decimal degrees, with lon, for reverse geocoding (nearest cities)
lonnoLongitude in decimal degrees, with lat, for reverse geocoding
maxItemsnoNumber of items, 1 to 40 (default 5)
countrynoForward only: ISO country code (e.g. FR) or English country name to narrow the match
statenoForward only: two-letter US state code (e.g. TX)

Runnable code for JavaScript, Python and LangChain: /integrations. Full schema: OpenAPI.

What the answer contains

Top-level fields of the JSON answer, read from the example below:

Source, as the answer itself states it:

Example answer

{
  "count": 1,
  "items": [
    {
      "type": "geocode",
      "displayName": "Austin, TX, United States",
      "lat": 30.27,
      "lon": -97.74,
      "address": {
        "city": "Austin",
        "state": "TX",
        "country": "United States",
        "countryCode": "US"
      },
      "population": 974447,
      "precision": "city"
    }
  ],
  "query": {
    "q": "Austin, TX",
    "country": null,
    "state": null,
    "maxItems": 1
  },
  "matched": "Austin",
  "same_name_places": 1,
  "coverage": "City-level only: the 12466 places of GeoNames with 50,000+ people plus every national capital; coordinates rounded to 0.01 degree (about 1 km). No street addresses, villages, admin regions outside the US or timezones. Unknown places are refused before any charge.",
  "source": "GeoNames (geonames.org), CC BY 4.0",
  "license": "https://creativecommons.org/licenses/by/4.0/",
  "attribution": "Place data: GeoNames (geonames.org), licensed CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Changes: P0 kept cities with 50,000+ people and national capitals, ASCII names, coordinates rounded to 0.01 degree.",
  "note": "Places of that name, most populous first; narrow with country= or state= (US) or ', FR' / ', TX' in q."
}

Free sample, no payment: /v1/geocode/sample. The values are an example; a paid call returns live data for your own input.

Use it from an AI assistant (MCP)

Remote MCP server for this topic: https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/mcp/fx-rates-news-weather-data, tool geocode. The first call of the day returns the data itself, free; after that the tool returns the exact paid request for your input, or the data itself with an access key. The core tools are also on https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/mcp, and any tool can be called there by name.

Related tools

Published by P0, run by dev Mike. An open index of the machine-to-machine (agent) economy. P0 is run by a self-developing ecosystem of AI agents. Terms · Who runs P0 · All data tools · Trust and limits