searcharea API
searcharea API can be used to run geospatial queries against a database of GeoJSON documents that describe places in the United States. A place can defined as either an incorporated city or town or as a statistical entity like a Census Designated Place or a County Census Division.
There are two endpoints for the API: get-place
and get-surrounding-places
. The API will return a GEOID for both search types, and this can be used specifically in the get-surrounding-places
endpoint to return a list of the places surrounding that GEOID within a specified distance. The GEOID is a 7 or 10 digit (depending on the type of place) string that can be attached to database records to facilitate area searching.
searcharea API was created to support search functionality for eCommerce type applications. The geospatial searching is approximate and is not intended for navigation or other geospatial querying that would require precision.
URL structure
https://searcharea.info/api/<endpoint>?<query-string>
Parameters
Endpoint (GET): get-place
Query string parameters:
place
(required)
state
(required):
Can be full name or two-letter abbreviation.
verbose
(optional):
Enumerated string. A "true" value will return more information about the place: place name, and state name. If not included, the request will only return a GEOID.
Endpoint (GET): get-surrounding-places
Query string parameters (One of either geoid or state and place must be included):
place
(optional):
If present, state must also be included.
state
(optional):
If present, place must also be included. Can be full name or two-letter abbreviation.
geoid
(optional):
String of either 7 or 10 digits. Cannot be present with state or place.
radius
(required):
String, integer or floating point.
unit
(required):
Enumerated string. Values are either "mi" (miles) or "km" (kilometers).
verbose
(optional):
Enumerated string. A "true" value will return more information about the place: place name, state name, and distance from the search place in whichever unit was entered. If not included, the request will only return a GEOID.
Place or state names that have any kind of word delimiter (e.g. New Hampshire) must be entered with dashes in the URL. There are some place names that have dashes (e.g. Manchester-by-the-Sea, MA) or even a combination of spaces and dashes (e.g. Texas City-League City, TX), but regardless, any type of delimiter must be replaced with a dash. Note that examples of places that include both spaces and dashes are likely to be statistical in purpose and are less likely to be used for a location search.
Multiple places
In the event a request returns multiple places with the same name, the verbose flag can be used to return additional information to help distinguish between places. LSAD (legal/statistical area description) is an official name for a place, and this can help distinguish between duplicates. For example, Vermont has two places named Rutland, but they have different LSAD names: one is Rutland Town and the other is Rutland City. Returning the LSAD name can help, but be aware that there are some places that have completely identical names, like Springfield New Jersey (both have the LSAD name of Springfield Township). To help further with cases like this, coordinates for the centroid of a place are also returned, though this will required examination with other geospatial tools.