Custom Account Data
/api/v2/download/accounts/These endpoints are used to power USAspending.gov's download center.
Generate files and return metadata using filters on custom account
Request
curl -X POST 'https://api.usaspending.gov/api/v2/download/accounts/' \
-H 'Content-Type: application/json' \
-d '{
"account_level": "treasury_account",
"file_format": "csv",
"filters": {
"fy": "2018",
"quarter": "1",
"submission_types": [
"account_balances",
"award_financial"
],
"def_codes": [
"L",
"M",
"O"
]
}
}'Request body
The filters object is shared by every search endpoint. The filter object explains each filter with examples.
account_levelenum (string)RequiredThe account level is used to filter for a specific type of file.
federal_accounttreasury_account
file_formatenum (string)The format of the file(s) in the zip file containing the data.
csvtsvpstxt
filtersobject · AdvancedFilterObjectRequired10 fieldsThe filters used to filter the data
agencystringThe agency on which to filter. This field expects either an internal toptier agency identifier, also known as the
toptier_agency_id, or an agencyabbreviation(DOJ,NRC, etc.). If the string submitted contains only numbers, it will search for a matchingtoptier_agency_id. Otherwise, it will search for a matchingabbreviation.budget_functionstringThe budget function code on which to filter.
budget_subfunctionstringThe budget subfunction code on whicn to filter
federal_accountstringThis field is an internal id.
submission_typeenum (string)Either
submission_typeorsubmission_typesis required.account_balancesobject_class_program_activityaward_financial
submission_typesarrayEither
submission_typeorsubmission_typesis required.- (enum[string])
account_balancesobject_class_program_activityaward_financial
- (enum[string])
fystringRequiredThe fiscal year to filter by in the format
YYYYquarterenum (string)Either
quarterorperiodis required. Do not supply both. Note that both monthly and quarterly submissions will be included in the resulting download file even if onlyquarteris provided.1234
periodenum (string)Either
quarterorperiodis required. Do not supply both. Agencies cannot submit data for period 1 so it is disallowed as a query filter. Note that both monthly and quarterly submissions will be included in the resulting download file even if onlyperiodis provided.23456789101112
def_codesarray of stringThe Disaster Emergency Fund Code (def_codes) filter is optional. If no def_codes are provided the request will return records associated with all def_codes. If an array of valid members is provided the request will return records associated with only the def_codes provided.
- A list of current DEFC can be found here.
columnsarray of stringThe columns specified to be included in the download.
Try it
Runs against the live API. Responses are real data.
/api/v2/download/accounts/Response · 200
status_urlstringRequiredThe endpoint used to get the status of a download.
file_namestringRequiredIs the name of the zipfile containing CSVs that will be generated (file_name is timestamp followed by
_transactionsor_awards).file_urlstringRequiredThe URL for the file.
download_requestobjectRequiredThe JSON object used when processing the download.
{
"status_url": "http://localhost:8000/api/v2/download/status?file_name=FY2018Q1_All_TAS_AccountBalances_2020-01-13_H21M00S18407575.zip",
"file_name": "FY2018Q1_All_TAS_AccountData_2020-01-13_H21M00S18407575.zip",
"file_url": "/csv_downloads/FY2018Q1_All_TAS_AccountData_2020-01-13_H21M00S18407575.zip",
"download_request": {
"account_level": "treasury_account",
"agency": "all",
"columns": [],
"download_types": [
"account_balances",
"award_financial"
],
"file_format": "csv",
"filters": {
"fy": 2018,
"quarter": 1,
"def_codes": [
"L",
"M",
"O"
]
},
"request_type": "account"
}
}Recent changes
- DEV-13328: Add columns to custom download account api contract
- DEV-12574: Updating download accounts api contract
- Mentioned in the October 05, 2020 release notes
Generated from contracts/v2/download/accounts.md in the USAspending API repo.