USAspending API ReferenceIndependent
Try the API

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

  • limitnumber

    Number of results to return (min: 1, max: 500)

    Default 10

  • search_textstringRequired

Try it

Runs against the live API. Responses are real data.

POST/api/v2/autocomplete/location/

Response · 200

  • resultsobject · LocationsRequired7 fields
    • countriesarray of CountryMatch1 field
      • country_namestringRequired
    • statesarray of StateMatch2 fields
      • state_namestringRequired
      • country_namestringRequired
    • citiesarray of CityMatch3 fields
      • city_namestringRequired
      • state_namestringRequiredNullable

        This is NULL for foreign cities.

      • country_namestringRequired
    • countiesarray of CountyMatch4 fields
      • county_namestringRequired
      • county_fipsstringRequired

        The 5 digit FIPS code (2 digit state FIPS code + 3 digit county FIPS code)

      • state_namestringRequired
      • country_namestringRequired
    • zip_codesarray of ZipCodeMatch3 fields
      • zip_codenumberRequired

        The 5 digit zip code

      • state_namestringRequired
      • country_namestringRequired
    • districts_originalarray of OriginalCongressionalDistrictMatch3 fields
      • original_cdstringRequired
      • state_namestringRequired
      • country_namestringRequired
    • districts_currentarray of CurrentCongressionalDistrictMatch3 fields
      • current_cdstringRequired
      • state_namestringRequired
      • country_namestringRequired
  • messagesarray of stringRequired
Example response
{
  "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

Generated from contracts/v2/autocomplete/location.md in the USAspending API repo.

Loading…