Spending By Category
/api/v2/search/spending_by_category/This endpoint supports the advanced search page and allow for complex filtering for specific subsets of spending data.
This endpoint returns a list of the top results of specific categories sorted by the total amounts in descending order.
Request
curl -X POST 'https://api.usaspending.gov/api/v2/search/spending_by_category/' \
-H 'Content-Type: application/json' \
-d '{
"category": "awarding_agency",
"filters": {
"keywords": [
"Filter is required"
]
}
}'Request body
The filters object is shared by every search endpoint. The filter object explains each filter with examples.
categoryenum (string)Requiredawarding_agencyawarding_subagencycfdacountrycountydefcdistrictfederal_accountfunding_agencyfunding_subagencynaicsobject_classprogram_activitypscrecipient_dunsrecipient_parent_dunsstate_territorytas
filtersobject · AdvancedFilterObjectRequired24 fieldsThe filters to find with said category
keywordsarray of stringdescriptionstringtime_periodarray of TimePeriodObjectSee TimePeriodObject for the TimePeriodObject definition by individual category.
place_of_performance_scopeenum (string)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 (string)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 numberdef_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.
limitnumberThe number of results to include per page
pagenumberThe page of results to return based on the limit
spending_levelenum (string)Group the spending by level. This also determines what data source is used for the totals.
transactionsawardssubawardsaward_financialOnly supported by the defc category; filters to an award(s) and uses obligation and outlays from the linked File C records
subawardsbooleanDetermines whether Prime Awards or Sub Awards are searched. This field will be depreciated soon.
Try it
Runs against the live API. Responses are real data.
/api/v2/search/spending_by_category/Response · 200
categorystringRequiredspending_levelenum (string)RequiredSpending level value that was provided in the request.
transactionsawardssubawards
resultsarray of CategoryResultRequired6 fieldsidnumberRequiredThe id is the database key.
recipient_idstringNullableA unique identifier for the recipient which includes the recipient hash and level.
namestringRequiredNullablecodestringRequiredNullablecodeis a user-displayable code (such as a program activity or NAICS code, but not a database ID). When no such code is relevant, return anull.amountnumberRequiredtotal_outlaysnumberRequiredNullable
limitnumberRequiredpage_metadataobject · PageMetadataObject2 fieldspagenumberRequiredhasNextbooleanRequired
messagesarray of stringAn array of warnings or instructional directives to aid consumers of this endpoint with development and debugging.
{
"category": "",
"spending_level": "transactions",
"results": [
{
"id": 0,
"name": null,
"code": null,
"amount": 0,
"total_outlays": null
}
],
"limit": 0,
"page_metadata": {
"page": 0,
"hasNext": false
},
"messages": []
}Recent changes
- DEV-11901: Update api contracts
- DEV-10281: Add object_class back for unmentioned contracts in slack thread
- DEV-10821: Remove object_class from search endpoint api contracts
- DEV-11552: Update spending_by_category API contract
- DEV-11398: Updating contracts to remove spaces
Generated from contracts/v2/search/spending_by_category.md in the USAspending API repo.