Logo
Published on

Navigating Federal Spending Data with the USAspending API

Authors
  • avatar
    Name
    GovCon
    Twitter

Navigating Federal Spending Data with the USAspending API

For organizations and individuals interested in tracking federal spending, the USAspending API offers a comprehensive and accessible way to retrieve detailed data. This guide will explore the key functionalities of the USAspending API, how to get started, and practical examples to help you leverage this powerful tool.

Overview of the USAspending API

The USAspending API provides programmatic access to federal spending data. It supports various endpoints, each designed to return specific types of information. Key features of this API include:

  • GET and POST Requests: Supports both GET requests for specific records and POST requests for advanced filtering.
  • Detailed Spending Data: Access to detailed financial information, including obligations, awards, and budgetary resources.
  • No Authorization Required: The API does not currently require any authorization for access.

Getting Started with the USAspending API

Understanding Endpoints

Endpoints are the specific paths used to request data from the API. Each endpoint corresponds to a particular type of data, such as agency details, award information, or spending summaries.

Common Request Methods

  • GET Requests: Used to retrieve specific records with known identifiers.
  • POST Requests: Used for more advanced filtering and retrieving data based on complex queries.

Example Endpoints

Here are some commonly used endpoints and their descriptions:

EndpointMethodsDescription
/api/v2/agency/<TOPTIER_AGENCY_CODE>/GETReturns agency overview information for USAspending.gov's Agency Details page for agencies that have ever awarded
/api/v2/agency/<TOPTIER_AGENCY_CODE>/awards/GETReturns agency summary information, specifically the number of transactions and award obligations for the sub-agency section of USAspending.gov's Agency Details page
/api/v2/agency/<TOPTIER_AGENCY_CODE>/awards/new/count/GETReturns a count of New Awards for the agency in a single fiscal year
/api/v2/agency/awards/count/GETReturns a count of Awards types for agencies in a single fiscal year
/api/v2/agency/<TOPTIER_AGENCY_CODE>/budget_function/GETReturns a list of Budget Functions and Budget Subfunctions for the agency in a single fiscal year
/api/v2/agency/<TOPTIER_AGENCY_CODE>/budget_function/count/GETReturns the count of Budget Functions for the agency in a single fiscal year
/api/v2/agency/<TOPTIER_AGENCY_CODE>/budgetary_resources/GETReturns budgetary resources and obligations for the agency and fiscal year requested
/api/v2/agency/<TOPTIER_AGENCY_CODE>/federal_account/GETReturns a list of Federal Accounts and Treasury Accounts for the agency in a single fiscal year
/api/v2/agency/<TOPTIER_AGENCY_CODE>/federal_account/count/GETReturns the count of Federal Accounts and Treasury Accounts for the agency in a single fiscal year
/api/v2/agency/<TOPTIER_AGENCY_CODE>/object_class/GETReturns a list of Object Classes for the agency in a single fiscal year
/api/v2/agency/<TOPTIER_AGENCY_CODE>/object_class/count/GETReturns the count of Object Classes for the agency in a single fiscal year
/api/v2/agency/<TOPTIER_AGENCY_CODE>/obligations_by_award_category/GETReturns a breakdown of obligations by award category within a single fiscal year
/api/v2/agency/<TOPTIER_AGENCY_CODE>/program_activity/GETReturns a list of Program Activity categories for the agency in a single fiscal year
/api/v2/agency/<TOPTIER_AGENCY_CODE>/program_activity/count/GETReturns the count of Program Activity categories for the agency in a single fiscal year
/api/v2/agency/<TOPTIER_AGENCY_CODE>/sub_agency/GETReturns a list of sub-agencies and offices with obligated amounts, transaction counts, and new award counts for the agency in a single fiscal year
/api/v2/agency/<TOPTIER_AGENCY_CODE>/sub_agency/count/GETReturns the number of sub-agencies and offices for the agency in a single fiscal year
/api/v2/agency/<TOPTIER_AGENCY_CODE>/sub_components/<BUREAU_SLUG>/GETReturns a list of federal accounts by bureau for the agency in a single fiscal year
/api/v2/agency/<TOPTIER_AGENCY_CODE>/sub_components/GETReturns a list of bureaus for the agency in a single fiscal year
/api/v2/agency/treasury_account/<TREASURY_ACCOUNT_SYMBOL>/object_class/GETReturns a list of Object Classes for the specified Treasury Account Symbol (tas)
/api/v2/agency/treasury_account/<TREASURY_ACCOUNT_SYMBOL>/program_activity/GETReturns a list of Program Activities for the specified Treasury Account Symbol (tas)
/api/v2/autocomplete/accounts/a/POSTReturns Treasury Account Symbol Availability Type Code (A) filtered by other components provided in the request filter
/api/v2/autocomplete/accounts/aid/POSTReturns Treasury Account Symbol/Federal Account Agency Identifier (AID) filtered by other components provided in the request filter
/api/v2/autocomplete/accounts/ata/POSTReturns Treasury Account Symbol Allocation Transfer Agency Identifier (ATA) filtered by other components provided in the request filter
/api/v2/autocomplete/accounts/bpoa/POSTReturns Treasury Account Symbol Beginning Period of Availability (BPOA) filtered by other components provided in the request filter
/api/v2/autocomplete/accounts/epoa/POSTReturns Treasury Account Symbol Ending Period of Availability (EPOA) filtered by other components provided in the request filter
/api/v2/autocomplete/accounts/main/POSTReturns Treasury Account Symbol/Federal Account Main Account Code (MAIN) filtered by other components provided in the request filter
/api/v2/autocomplete/accounts/sub/POSTReturns Treasury Account Symbol Sub-Account Code (SUB) filtered by other components provided in the request filter
/api/v2/autocomplete/awarding_agency/POSTReturns awarding agencies matching the specified search text
/api/v2/autocomplete/awarding_agency_office/POSTReturns awarding agencies and offices matching the specified search text
/api/v2/autocomplete/funding_agency_office/POSTReturns funding agencies and offices matching the specified search text
/api/v2/autocomplete/cfda/POSTReturns CFDA programs matching the specified search text
/api/v2/autocomplete/city/POSTReturns city names matching the search text, sorted by relevance
/api/v2/autocomplete/recipient/POSTReturns recipient names and UEI based on search text
/api/v2/autocomplete/funding_agency/POSTReturns funding agencies matching the specified search text
/api/v2/autocomplete/glossary/POSTReturns glossary terms matching provided search text
/api/v2/autocomplete/naics/POSTReturns NAICS objects matching the specified search text
/api/v2/autocomplete/psc/POSTReturns product or service (PSC) codes and their descriptions based on a search string. This may be the 4-character PSC code or a description string.
/api/v2/autocomplete/location/POSTReturns locations based on search text
/api/v2/award_spending/recipient/GETReturns all award spending by recipient for a given fiscal year and agency id
/api/v2/awards/<AWARD_ID>/GETReturns details about specific award
/api/v2/awards/accounts/POSTReturns a list of federal accounts for the indicated award
/api/v2/awards/count/federal_account/<AWARD_ID>/GETReturns the number of federal accounts associated with the award
/api/v2/awards/count/subaward/<AWARD_ID>/GETReturns the number of subawards associated with the award
/api/v2/awards/count/subaward/<AWARD_ID>/GETReturns the number of subawards associated with the award
/api/v2/awards/count/transaction/<AWARD_ID>/GETReturns the number of transactions associated with the award
/api/v2/awards/funding/POSTReturns federal account, awarding agencies, funding agencies, and transaction obligated amount information for a requested award
/api/v2/awards/funding_rollup/POSTReturns aggregated count of awarding agencies, federal accounts, and total transaction obligated amount for an award
/api/v2/awards/last_updated/GETReturns date of last update
/api/v2/budget_functions/list_budget_functions/GETReturns all Budget Functions associated with a TAS, ordered by Budget Function code
/api/v2/budget_functions/list_budget_subfunctions/POSTReturns all Budget Functions associated with a TAS, ordered by Budget Function code
/api/v2/bulk_download/awards/POSTGenerates zip file for download of award data in CSV format
/api/v2/bulk_download/list_agencies/POSTLists all the agencies and the subagencies or federal accounts associated under specific agencies
/api/v2/bulk_download/list_monthly_files/POSTLists the monthly files associated with the requested params
/api/v2/bulk_download/status/GETReturns the current status of a download job that that has been requested with the v2/bulk_download/awards/ or v2/bulk_download/transaction/ endpoint that same day.
/api/v2/disaster/agency/count/POSTReturns the count of Agencies which received disaster/emergency funding
/api/v2/disaster/agency/loans/POSTReturns insights on the Agencies awarding loans from disaster/emergency funding
/api/v2/disaster/agency/spending/POSTReturns insights on the Agencies which received disaster/emergency funding
/api/v2/disaster/award/amount/POSTReturns account data obligation and outlay spending aggregations of all (File D) Awards which received disaster/emergency funding
/api/v2/disaster/award/count/POSTReturns the count of account data obligation and outlay spending aggregations of all (File D) Awards which received disaster/emergency funding
/api/v2/disaster/cfda/count/POSTDimension Count of Disaster/Emergency funding data
/api/v2/disaster/cfda/loans/POSTRecords of loan Disaster/Emergency funding data by dimension
/api/v2/disaster/cfda/spending/POSTRecords of spending Disaster/Emergency funding data by dimension
/api/v2/disaster/def_code/count/POSTDimension Count of Disaster/Emergency funding data
/api/v2/disaster/federal_account/count/POSTDimension Count of Disaster/Emergency funding data
/api/v2/disaster/federal_account/loans/POSTRecords of loan Disaster/Emergency funding data by dimension
/api/v2/disaster/federal_account/spending/POSTRecords of spending Disaster/Emergency funding data by dimension
/api/v2/disaster/object_class/count/POSTDimension Count of Disaster/Emergency funding data
/api/v2/disaster/object_class/loans/POSTRecords of loan Disaster/Emergency funding data by dimension
/api/v2/disaster/object_class/spending/POSTRecords of spending Disaster/Emergency funding data by dimension
/api/v2/disaster/overview/GETOverview of Disaster/Emergency funding and spending
/api/v2/disaster/recipient/count/POSTDimension Count of Disaster/Emergency funding data
/api/v2/disaster/recipient/loans/POSTRecords of loan Disaster/Emergency funding data by dimension
/api/v2/disaster/recipient/spending/POSTRecords of spending Disaster/Emergency funding data by dimension
/api/v2/disaster/spending_by_geography/POSTGeographic award spending of Disaster/Emergency funding
/api/v2/download/accounts/POSTGenerates zip file for download of account data in CSV format
/api/v2/download/assistance/POSTReturns a zipped file containing Assistance data
/api/v2/download/awards/POSTGenerates zip file for download of award data in CSV format
/api/v2/download/contract/POSTReturns a zipped file containing Contract data
/api/v2/download/count/POSTReturns the number of transactions that would be included in a download request for the given filter set
/api/v2/download/disaster/POSTReturns a zipped file containing Account and Award data for the Disaster Funding
/api/v2/download/disaster/recipients/POSTReturns a zipped file containing Disaster Recipient Funding data
/api/v2/download/idv/POSTReturns a zipped file containing IDV data
/api/v2/download/status/GETgets the current status of a download job that that has been requested with the v2/download/awards/ or v2/download/transaction/ endpoint that same day
/api/v2/download/transactions/POSTGenerates zip file for download of award data in CSV format
/api/v2/federal_accounts/<ACCOUNT_CODE>/GETReturns a federal account based on its federal account code
/api/v2/federal_accounts/<ACCOUNT_CODE>/available_object_classes/GETReturns financial spending data by object class based on account's internal ID
/api/v2/federal_accounts/<ACCOUNT_CODE>/fiscal_year_snapshot/<YEAR>/GETReturns budget information for a federal account for the year provided based on account's internal ID
/api/v2/federal_accounts/<ACCOUNT_CODE>/fiscal_year_snapshot/GETReturns budget information for a federal account for the most recent year based on account's internal ID
/api/v2/federal_accounts/POSTReturns financial spending data by object class
/api/v2/federal_obligations/GETReturns a paginated list of obligations for the provided agency for the provided year
/api/v2/financial_balances/agencies/GETReturns financial balances by agency and the latest quarter for the given fiscal year
/api/v2/financial_spending/major_object_class/GETReturns financial spending data by object class for the latest quarter based on the given fiscal year
/api/v2/financial_spending/object_class/GETReturns financial spending data by object class for the latest quarter based on the given fiscal year
/api/v2/idvs/accounts/POSTReturns a list of federal accounts for the indicated IDV
/api/v2/idvs/activity/POSTReturns information about child awards and grandchild awards for a given IDV (Indefinite Delivery Vehicle)
/api/v2/idvs/amounts/<AWARD_ID>/GETReturns the direct children of an IDV
/api/v2/idvs/awards/POSTReturns IDVs or contracts related to the requested Indefinite Delivery Vehicle award (IDV)
/api/v2/idvs/count/federal_account/<AWARD_ID>/GETReturns the number of federal accounts associated with children and grandchild awards of an IDV
/api/v2/idvs/funding/POSTReturns File C funding records associated with an IDV
/api/v2/idvs/funding_rollup/POSTReturns aggregated count of awarding agencies, federal accounts, and total transaction obligated amount for all contracts under an IDV
/api/v2/recipient/POSTReturns a list of recipients in USAspending DB
/api/v2/recipient/children/<DUNS_OR_UEI>/GETReturns recipient details based on DUNS or UEI number
/api/v2/recipient/count/POSTReturns the count of recipients for the given filters
/api/v2/recipient/duns/<HASH_VALUE>/GETReturns a high-level overview of a specific recipient, given its id
/api/v2/recipient/duns/POSTReturns a list of recipients in USAspending DB
/api/v2/recipient/<HASH_VALUE>/GETReturns an individual recipient in USAspending DB
/api/v2/recipient/state/<FIPS>/GETReturns basic information about the specified state
/api/v2/recipient/state/GETReturns basic information about the specified state
/api/v2/recipient/state/awards/<FIPS>/GETReturns award breakdown based on FIPS
/api/v2/reporting/agencies/<TOPTIER_CODE>/differences/GETReturns About the Data information about differences in account balance and spending obligations for a specific agency/year/period
/api/v2/reporting/agencies/<TOPTIER_CODE>/discrepancies/GETReturns TAS discrepancies of the specified agency's submission data for a specific FY/FP
/api/v2/references/agency/<AGENCY_ID>/GETReturns basic information about a federal agency
/api/v2/references/award_types/GETReturns a map of award types by award grouping.
/api/v2/references/cfda/totals//GETProvides total values for provided CFDA
/api/v2/references/cfda/totals/GETProvides total values for all CFDAs
/api/v2/references/data_dictionary/GETReturns a JSON structure of the Schema Teams Rosetta Crosswalk Data Dictionary
/api/v2/references/def_codes/GETReturns an object of Disaster Emergency Fund (DEF) Codes
(DEFC) and titles
/api/v2/references/filter/POSTAccepts an Advanced Search filter object and returns a hash which can be used as a lookup key by /api/v2/references/hash/
/api/v2/references/filter_tree/psc/<GROUP>/<PSC>/<PSC>/GETReturns a list of PSC under the provided path
/api/v2/references/filter_tree/psc/<GROUP>/<PSC>/GETReturns a list of PSC under the provided path
/api/v2/references/filter_tree/psc/<GROUP>/GETReturns a list of PSC under the provided path
/api/v2/references/filter_tree/psc/GETReturns a list of PSC groupings
/api/v2/references/filter_tree/tas/<AGENCY>/<FEDERAL_ACCOUNT>/GETReturns a list of Treasury Account Symbols associated with the specified federal account
/api/v2/references/filter_tree/tas/<AGENCY>/GETReturns a list of federal accounts associated with the specified agency
/api/v2/references/filter_tree/tas/GETReturns a list of toptier agencies that have at least one TAS affiliated with them
/api/v2/references/glossary/GETReturns a list of glossary terms and definitions
/api/v2/references/hash/POSTAccepts a hash generated by /api/v2/references/filter/ and returns an Advanced Search filter object
/api/v2/references/naics/<NAICS_CODE>/GETReturns the requested NAICS and immediate children, as well as related, relevant data.
/api/v2/references/naics/GETReturns all Tier 1 (2-digit) NAICS and related, relevant data.
/api/v2/references/submission_periods/GETReturns a list of all available submission periods with essential information about start and end dates.
/api/v2/references/toptier_agencies/GETReturns all toptier agencies and related, relevant data.
/api/v2/references/total_budgetary_resources/GETReturns a list of total budgetary resources totalled by fiscal year and period.
/api/v2/reporting/agencies/<TOPTIER_CODE>/overview/GETReturns a list of submission data for the provided agency.
/api/v2/reporting/agencies/overview/GETReturns About the Data information about all agencies with submissions in a provided fiscal year and period
/api/v2/reporting/agencies/publish_dates/GETReturns submission publication and certification information about all agencies with submissions in a provided fiscal year and period
/api/v2/reporting/agencies/<TOPTIER_CODE>/<FISCAL_YEAR>/<FISCAL_PERIOD>/submission_history/GETReturns a list of submission publication dates and certified dates for the provided agency for the provided fiscal year and period.
/api/v2/reporting/agencies/<TOPTIER_CODE>/<FISCAL_YEAR>/<FISCAL_PERIOD>/unlinked_awards/<TYPE>/GETReturns counts of an agency's linked and unlinked awards for a given period.
/api/v2/search/new_awards_over_time/POSTReturns a list of time periods with the new awards in the appropriate period within the provided time range
/api/v2/search/spending_by_award/POSTReturns the fields of the filtered awards
/api/v2/search/spending_by_award_count/POSTReturns the number of awards in each award type (Contracts, IDV, Loans, Direct Payments, Grants, and Other)
/api/v2/search/spending_by_category/POSTReturns data that is grouped in preset units to support the various data visualizations on USAspending.gov's Advanced Search page
/api/v2/search/spending_by_category/awarding_agency/POSTReturns data that is grouped in preset units to support the Spending by Awarding Agency data visualizations on USAspending.gov's Advanced Search page
/api/v2/search/spending_by_category/awarding_subagency/POSTReturns data that is grouped in preset units to support the Spending by Awarding Subagency data visualizations on USAspending.gov's Advanced Search page
/api/v2/search/spending_by_category/cfda/POSTReturns data that is grouped in preset units to support the Spending by CFDA data visualizations on USAspending.gov's Advanced Search page
/api/v2/search/spending_by_category/country/POSTReturns data that is grouped in preset units to support the Spending by Country data visualizations on USAspending.gov's Recipient Profile page
/api/v2/search/spending_by_category/county/POSTReturns data that is grouped in preset units to support the Spending by County data visualizations on USAspending.gov's State Profile page
/api/v2/search/spending_by_category/district/POSTReturns data that is grouped in preset units to support the Spending by Congressional District data visualizations on USAspending.gov's State Profile page
/api/v2/search/spending_by_category/federal_account/POSTReturns data that is grouped in preset units to support the Spending by Federal Account data visualizations on USAspending.gov's Recipient Profile page
/api/v2/search/spending_by_category/funding_agency/POSTReturns data that is grouped in preset units to support the Spending by Funding Agency data visualizations on USAspending.gov's Advanced Search page
/api/v2/search/spending_by_category/funding_subagency/POSTReturns data that is grouped in preset units to support the Spending by Funding Subagency data visualizations on USAspending.gov's Advanced Search page
/api/v2/search/spending_by_category/naics/POSTReturns data that is grouped in preset units to support the Spending by NAICS data visualizations on USAspending.gov's Advanced Search page
/api/v2/search/spending_by_category/psc/POSTReturns data that is grouped in preset units to support the Spending by PSC data visualizations on USAspending.gov's Advanced Search page
/api/v2/search/spending_by_category/recipient/POSTReturns data that is grouped in preset units to support the Spending by Recipient data visualizations on USAspending.gov's Advanced Search page
/api/v2/search/spending_by_category/recipient_duns/POSTReturns data that is grouped in preset units to support the Spending by Recipient DUNS data visualizations on USAspending.gov's Advanced Search page
/api/v2/search/spending_by_category/state_territory/POSTReturns data that is grouped in preset units to support the Spending by State Territory data visualizations on USAspending.gov's Recipient Profile page
/api/v2/search/spending_by_geography/POSTReturns Spending by state code, county code, or congressional district code
/api/v2/search/spending_by_transaction/POSTReturns awards where a certain subset of fields match against search term
/api/v2/search/spending_by_transaction_count/POSTReturns counts of awards where a certain subset of fields match against search term
/api/v2/search/spending_by_transaction_grouped/POSTReturns transactions where a certain subset of fields match against search terms and results are grouped by their prime award.
/api/v2/search/spending_over_time/POSTReturns transaction aggregated amounts for Spending Over Time data visualizations on USAspending.gov
/api/v2/search/transaction_spending_summary/POSTReturns the number of transactions and the sum of federal action obligations for prime awards given a set of award of filters
/api/v2/spending/POSTReturns spending data information through various types and filters
/api/v2/subawards/POSTReturns subawards either related, optionally, to a specific parent award, or for all parent awards if desired
/api/v2/transactions/POSTReturns transactions related to a specific parent award

Example Requests

Example 1: Basic GET Request

To retrieve information about a specific agency using its top-tier agency code, use the following GET request:

Request URL:

https://api.usaspending.gov/api/v2/agency/123/

Response (JSON Output):

{
  "agency_code": 123,
  "agency_name": "Department of Example",
  "agency_overview": "Overview information about the agency.",
  ...
}

Example 2: Advanced POST Request

To perform a more complex search for spending by award using various filters, use the following POST request:

Request URL:

https://api.usaspending.gov/api/v2/search/spending_by_award/

Request Body:

{
  "filters": {
       "award_type_codes": ["A", "B"],
       "agencies": [
            {
                 "type": "awarding",
                 "tier": "toptier",
                 "name": "Example Agency"
            }
       ],
       "recipient_locations": [650597],
       "place_of_performance_scope": "domestic",
       "award_amounts": [
              {
                  "lower_bound": 1000000.00,
                  "upper_bound": 5000000.00

              }
       ]
  },
  "fields": ["Award ID", "Recipient Name", "Award Amount"],
  "sort": "Award Amount",
  "order": "desc"
}

Response (JSON Output):

{
  "results": [
    {
      "Award ID": "12345",
      "Recipient Name": "Example Recipient",
      "Award Amount": 3000000.00
    },
    ...
  ]
}

Conclusion

The USAspending API is a valuable resource for accessing detailed federal spending data. By understanding the various endpoints and how to structure your requests, you can efficiently retrieve the information you need. Whether you are conducting research, analyzing government spending, or preparing for a procurement opportunity, the USAspending API provides the tools to support your efforts.

Stay tuned to our blog for more insights and guides on leveraging technology to streamline your business processes!