Geocode

Forward-geocode a place name or US ZIP.

Changed on

Returns location candidates matching either a 5-digit US zipcode or a city (with optional state disambiguator). Exactly one of city or zipcode must be supplied.

A city search returns at most 10 place rows plus up to 64 county rows (a county-equivalent whose legal name is city, most populous first), so a county name many states share ("Washington County") returns every one.

A city written as a weather-station id in capitals, either an ICAO id (KSLC, PANC) or a 3-character FAA id with its state (SLC + UT), that no place or county matches by name also returns station rows from the METAR station catalog: first, after only a place whose name holds every word of city ("Kailua-Kona" for KONA).

Caching

Successful responses carry Cache-Control: private, max-age=3600. The underlying place-name <-> ZIP mapping is stable on the order of months. A response built while a lookup behind it was degraded (a timezone or station-catalog read, or a boundaries probe) carries Cache-Control: no-store instead; repeat the request later for the complete answer.

private lets your own client reuse the response for the full max-age while keeping shared caches (CDNs, proxies) out, since each request on a partner key is metered and rate-limited individually. First-party callers get public, max-age=3600.

Auth

Standard sw-api Bearer auth applies.

get/v1/geocode/search

Request

  • Base URL
    https://api.smarterweather.com
  • Auth
    HTTP bearer

Query parameters

city, string

City name to resolve. Mutually exclusive with zipcode. Permits the same character set as autosuggest.input.

state, string

Optional 2-letter US state code or full state name to disambiguate the city query. Ignored when zipcode is set.

zipcode, string

5-digit US ZIP code. Mutually exclusive with city.

include, 'boundaries'

boundaries adds each result's containing-boundary ids (boundaries), read at its point. A result whose read failed has none, and the response is then Cache-Control: no-store.

Response

Match results. Empty results array when no candidates match the query.

GeocodeResultsResponse required

Envelope returned by GET /v1/geocode/autosuggest and GET /v1/geocode/search. results is always present. meta is a stable, documented, optional field: autosuggest includes it only when the results are incomplete, and clients should treat any meta.warnings entry as incomplete results. Additional undocumented sibling fields may appear without a sw-api release (e.g. server-side annotations); ignore them.

An empty array is returned when no candidates match.

results, GeocodeAutosuggestResult[] required

Match candidates, ordered by match score (best first).

meta, Meta

Autosuggest only. Present only when the results are incomplete; meta.warnings[] names each section that did not finish. Absent on complete responses and on search.

Example response

{
  "results": [
    {
      "name": "Chicago",
      "state": "IL",
      "state_name": "Illinois",
      "county": "Cook",
      "zip": "60601",
      "lat": 41.8781,
      "lon": -87.6298,
      "population": 2746388,
      "timezone": "America/Chicago",
      "type": "place",
      "place_id": "1714000",
      "id": "addr:123-main-st-naperville-il",
      "title": "123 Main St",
      "subtitle": "Naperville, IL"
    }
  ],
  "meta": {
    "schema_version": "1.0.0",
    "freshness": [
      {
        "source": "rtma",
        "product_id": "rtma_conus_2p5km"
      }
    ],
    "warnings": [
      {
        "code": "partial_fetch",
        "section": "alerts",
        "product_id": "airquality_combined",
        "fields": [
          "aqi",
          "aqi_category",
          "pm25",
          "ozone",
          "pm10"
        ]
      }
    ]
  }
}

Changes

    • info

      added the optional property allOf[#/components/schemas/Problem]/alternatives to the response with the status

    • info

      added the optional property alternatives to the response with the status

    • info

      added the optional property alternatives to the response with the status

    7 more changes in this revision