Skip to content
Docs navigation

Geocoding

Smarter Weather covers the 50 US states and DC only. Coverage details

Convert between coordinates and place names in the 50 US states and DC. Use reverse geocoding to resolve coordinates, forward search to look up cities and ZIP codes, and autosuggest for real-time search interfaces.

Operations

Reverse geocode

Convert latitude/longitude coordinates to a place name (city, state, county, timezone). Useful for resolving GPS readings before a weather request.

Autosuggest

Location autocomplete from partial user input. Returns ranked suggestions for search bars and location pickers.

Forward search

Look up coordinates by city/state or US ZIP code. Returns the canonical location plus metadata.

When to use which

  • Building a location picker? Use autosuggest as the user types and forward search when they pick a result or paste a ZIP code.
  • Have device coordinates? Run them through reverse geocode to get a human-readable label before calling the weather endpoint.
  • Geocoding a list of places? There is no bulk endpoint. Call forward search one place at a time (it takes a city with an optional state, or a ZIP code). For other free text, such as a street address or an airport, fall back to autosuggest with include=address,poi (an x-stability: experimental parameter). Where address and POI results are not enabled for your key, it returns places and ZIP codes only, with a not_enabled warning; that is a stable state of the key, so do not retry it. Cache each result and pace the calls to your key's rate limit (wait out Retry-After on a 429).
curl "https://api.smarterweather.com/v1/geocode/search?city=Boston&state=MA" \
  -H "Authorization: Bearer ${SMARTERWEATHER_API_KEY:?set SMARTERWEATHER_API_KEY first, see developers.smarterweather.com/quickstart}"
// save as sample.mjs; run: node --env-file=.env sample.mjs (Node 20.6+, ESM top-level await)
const res = await fetch(
  "https://api.smarterweather.com/v1/geocode/search?city=Boston&state=MA",
  { headers: { Authorization: `Bearer ${process.env.SMARTERWEATHER_API_KEY}` } },
);
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const data = await res.json();
console.log(JSON.stringify(data, null, 2));
# pip install requests python-dotenv
import os, sys, requests
from dotenv import load_dotenv

load_dotenv(".env")  # ./.env in the current directory; variables already set are kept

r = requests.get(
    "https://api.smarterweather.com/v1/geocode/search",
    params={"city":"Boston","state":"MA"},
    headers={"Authorization": f"Bearer {os.environ['SMARTERWEATHER_API_KEY']}"},
)
if not r.ok:
    sys.exit(f"{r.status_code} {r.text}")
data = r.json()
print(data)
package main

import (
	"fmt"
	"io"
	"log"
	"net/http"
	"os"
)

func main() {
	req, err := http.NewRequest("GET", "https://api.smarterweather.com/v1/geocode/search?city=Boston&state=MA", nil)
	if err != nil {
		log.Fatal(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("SMARTERWEATHER_API_KEY"))
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()
	body, err := io.ReadAll(res.Body)
	if err != nil {
		log.Fatal(err)
	}
	if res.StatusCode < 200 || res.StatusCode > 299 {
		log.Fatalf("%s %s", res.Status, body)
	}
	fmt.Println(string(body))
}

Samples read your key from SMARTERWEATHER_API_KEY. Set it up in the Quickstart.

Geocoding reference

Rendered live from the canonical OpenAPI document. This is the canonical reference for the geocoding resource.

Paste a test key (sw_test_*) from your dashboard into Test Request. Test keys are never billed; their calls still count toward the key's rate limits and daily cap. Calls with your own live key count toward your plan.

Loading the API reference… The spec is also in openapi.yaml.