Location Autocomplete
POST
/api/v2/autocomplete/location/This endpoint is used by the Location autocomplete filter on the Advanced Search page.
This route sends a request to the backend to retrieve locations matching the specified search text.
Request
curl -X POST 'https://api.usaspending.gov/api/v2/autocomplete/location/' \
-H 'Content-Type: application/json' \
-d '{
"search_text": "Den"
}'Request body
limitnumberNumber of results to return (min: 1, max: 500)
search_textstringRequired
Try it
Runs against the live API. Responses are real data.
POST
/api/v2/autocomplete/location/Response · 200
resultsobject · LocationsRequired7 fieldscountriesarray of CountryMatch1 fieldcountry_namestringRequired
statesarray of StateMatch2 fieldsstate_namestringRequiredcountry_namestringRequired
citiesarray of CityMatch3 fieldscity_namestringRequiredstate_namestringRequiredNullableThis is
NULLfor foreign cities.country_namestringRequired
countiesarray of CountyMatch4 fieldscounty_namestringRequiredcounty_fipsstringRequiredThe 5 digit FIPS code (2 digit state FIPS code + 3 digit county FIPS code)
state_namestringRequiredcountry_namestringRequired
zip_codesarray of ZipCodeMatch3 fieldszip_codenumberRequiredThe 5 digit zip code
state_namestringRequiredcountry_namestringRequired
districts_originalarray of OriginalCongressionalDistrictMatch3 fieldsoriginal_cdstringRequiredstate_namestringRequiredcountry_namestringRequired
districts_currentarray of CurrentCongressionalDistrictMatch3 fieldscurrent_cdstringRequiredstate_namestringRequiredcountry_namestringRequired
messagesarray of stringRequired
{
"results": {
"countries": [
{
"country_name": "Denmark"
},
{
"country_name": "Sweden"
}
],
"cities": [
{
"city_name": "Denver",
"state_name": "Colorado",
"country_name": "United States"
},
{
"city_name": "Gadsden",
"state_name": "Alabama",
"country_name": "United States"
},
{
"city_name": "Camden",
"state_name": "Arkansas",
"country_name": "United States"
}
]
},
"messages": [
""
]
}Recent changes
- DEV-15418: Update API contracts for dredd failures
- DEV-15418: Set max value of 'limit' to 500
- DEV-13551: Adding county fips to location results
- DEV-12478: Return top results for each location type
- DEV-12144: Update API contract formatting
Generated from contracts/v2/autocomplete/location.md in the USAspending API repo.