Spending by Geography
/api/v2/search/spending_by_geography/This endpoint supports the advanced search page and allow for complex filtering for specific subsets of spending data.
This endpoint takes award filters, and returns aggregated obligation amounts in different geographic areas.
Request
curl -X POST 'https://api.usaspending.gov/api/v2/search/spending_by_geography/' \
-H 'Content-Type: application/json' \
-d '{
"filters": {
"keywords": [
"Filter is required"
]
},
"scope": "place_of_performance",
"geo_layer": "state"
}'Request body
The filters object is shared by every search endpoint. The filter object explains each filter with examples.
filtersobject · AdvancedFilterObjectRequired25 fieldskeywordsarray of stringdescriptionstringtime_periodarray of TimePeriodObjectThis TimePeriodObject can fall into different categories based on the request.
-
if
spending_levelissubawardsorsubawardsis trueSee the Subaward Search category defined in SubawardSearchTimePeriodObject
-
otherwise
See the Transaction Search category defined in TransactionSearchTimePeriodObject
-
place_of_performance_scopeenum (array)["The **default** value below only applies to `geo_layer` values of `county`","`district` and `state`."]domesticforeign
place_of_performance_locationsarray of LocationObjectThese fields are defined in the StandardLocationObject
agenciesarray of AgencyObject4 fieldstypeenum (string)Requiredawardingfunding
tierenum (string)Requiredtoptiersubtier
namestringRequiredtoptier_namestringOnly applicable when
tierissubtier. Ignored whentieristoptier. Provides a means by which to scope subtiers with common names to a specific toptier. For example, several agencies have an "Office of Inspector General". If not provided, subtiers may span more than one toptier.
recipient_search_textarray of stringrecipient_scopeenum (array)["The **default** value below only applies to `geo_layer` values of `county`","`district` and `state`."]domesticforeign
recipient_locationsarray of LocationObjectThese fields are defined in the StandardLocationObject
recipient_type_namesarray of stringaward_type_codesarrayList of filterable award types
award_idsarray of stringAward IDs surrounded by double quotes (e.g.
"SPE30018FLJFN") will perform exact matches as opposed to the default, fuzzier full text matches. Useful for Award IDs that contain spaces or other word delimiters.award_amountsarray of AwardAmounts2 fieldslower_boundnumberupper_boundnumber
program_numbersarray of stringnaics_codesobject · NAICSCodeObject2 fieldsrequirearray of stringexcludearray of string
tas_codesarray of TASCodeObject2 fieldsrequirearray of stringexcludearray of string
psc_codesenum (PSCCodeObject)Supports new PSCCodeObject or legacy array of codes.
contract_pricing_type_codesarray of stringset_aside_type_codesarray of stringextent_competed_type_codesarray of stringtreasury_account_componentsarray of TreasuryAccountComponentsObject7 fieldsatastringNullableAllocation Transfer Agency Identifier - three characters
aidstringRequiredAgency Identifier - three characters
bpoastringNullableBeginning Period of Availability - four digits
epoastringNullableEnding Period of Availability - four digits
astringNullableAvailability Type Code - X or null
mainstringRequiredMain Account Code - four digits
substringNullableSub-Account Code - three digits
object_classarray of stringprogram_activityarray of numberprogram_activitiesarray of ProgramActivityObjectA filter option that supports filtering by a program activity name or code. Please note that if this filter is used at least one of the members of the object, ProgramActivityObject, need to be provided.
def_codesarray of DEFCIf the
def_codesprovided are in the COVID-19 or IIJA group, the query will only return results of transactions where theaction_dateis on or after the enactment date of the public law associated with that disaster code.
subawardsbooleanTrue when you want to group by Subawards instead of Awards. Defaulted to False.
spending_levelenum (string)Group the spending by level. This also determines what data source is used for the totals.
transactionsawardssubawards
scopeenum (string)RequiredWhen fetching transactions, use the primary place of performance or recipient location
place_of_performancerecipient_location
geo_layerenum (string)RequiredSet the type of areas in the response
statecountydistrictcountry
geo_layer_filtersarray of stringList of U.S. state codes, U.S. county codes, U.S. Congressional districts, or ISO 3166-1 alpha-3 country codes to show results for.
Try it
Runs against the live API. Responses are real data.
/api/v2/search/spending_by_geography/Response · 200
scopestringgeo_layerstringspending_levelenum (string)RequiredSpending level value that was provided in the request.
transactionsawardssubawards
resultsarray of GeographyTypeResult6 fieldsaggregated_amountnumberRequireddisplay_namestringRequiredshape_codestringRequiredpopulationnumberRequiredNullableper_capitanumberRequiredNullabletotal_outlaysnumber
messagesarray of stringAn array of warnings or instructional directives to aid consumers of this endpoint with development and debugging.
{
"scope": "place_of_performance",
"geo_layer": "state",
"spending_level": "transactions",
"results": [
{
"shape_code": "ND",
"aggregated_amount": 4771026.93,
"display_name": "North Dakota",
"population": 762062,
"per_capita": 6.26
},
{
"shape_code": "NV",
"aggregated_amount": 26928552.59,
"display_name": "Nevada",
"population": 3080156,
"per_capita": 8.74
},
{
"shape_code": "OH",
"aggregated_amount": 187505278.16,
"display_name": "Ohio",
"population": 11689100,
"per_capita": 16.04
}
],
"messages": [
"For searches, time period start and end dates are currently limited to an earliest date of 2007-10-01. For data going back to 2000-10-01, use either the Custom Award Download feature on the website or one of our download or bulk_download API endpoints as listed on https://api.usaspending.gov/docs/endpoints.",
"The 'subawards' field will be deprecated in the future. Set 'spending_level' to 'subawards' instead. See documentation for more information."
]
}Recent changes
- DEV-10281: Add object_class back for unmentioned contracts in slack thread
- DEV-10821: Remove object_class from search endpoint api contracts
- DEV-11551: Update API Contracts
- Mentioned in the January 2, 2025 release notes
- DEV-11400: Update api contracts for search_by_geography
Generated from contracts/v2/search/spending_by_geography.md in the USAspending API repo.