USAspending API: federal spending data in code
USAspending.gov publishes what the US federal government has awarded: contracts, grants, loans and other assistance. Its API is free and public and needs no key. One POST request to the award search endpoint returns awarded contracts or grants that match a keyword, agency, recipient or date window. This guide shows a working request in Python, the things that most often break a first script, and how awarded spending differs from open bids.
This guide is independent and is not an official USAspending.gov resource.
You need: Python 3 and an internet connection. There's no account or key to set up.
How do I search federal spending with the USAspending API?
Send a POST to https://api.usaspending.gov/api/v2/search/spending_by_award/ with your filters, the fields you want back and a page size. This example asks for contracts that mention "semiconductor" with activity in the 30 days to 15 November 2026, largest first:
import json, urllib.request
body = {
"filters": {
"keywords": ["semiconductor"],
"award_type_codes": ["A", "B", "C", "D"], # the contracts group
"time_period": [{"start_date": "2026-10-16", "end_date": "2026-11-15"}],
},
"fields": ["Award ID", "Recipient Name", "Award Amount", "Awarding Agency", "Start Date"],
"limit": 5,
"sort": "Award Amount",
"order": "desc",
}
req = urllib.request.Request(
"https://api.usaspending.gov/api/v2/search/spending_by_award/",
data=json.dumps(body).encode(),
headers={"Content-Type": "application/json"},
)
with urllib.request.urlopen(req, timeout=90) as r:
data = json.load(r)
for a in data["results"]:
print(a["Award ID"], a["Recipient Name"], a["Award Amount"], a["Awarding Agency"], a["Start Date"])
print("More pages:", data["page_metadata"]["hasNext"])
On 15 November 2026 the first two lines it printed were:
2031ZA23C00036 SPECTRA SYSTEMS CORPORATION 1995916.0 Department of the Treasury 2023-05-31
80NSSC27P0146 MICRON SEMICONDUCTOR LIMITED 287205.0 National Aeronautics and Space Administration 2026-10-27
Codes A to D are the four contract types (BPA call, purchase order, delivery order and definitive contract). To see how many awards match before you fetch them, send the same filters without award_type_codes to /api/v2/search/spending_by_award_count/. For this search it counted 12 contracts, 2 grants, 1 loan and 1 other award.
What trips people up?
- One award type group per request. Mixing a contract code (
A) with a grant code (02) returns HTTP 422 with the message "'award_type_codes' must only contain types from one group." Run one search per group (contracts, IDVs, grants, loans, direct payments, other) and merge the results. - The date window is the latest activity, not the award date.
time_periodmatches on the latest transaction by default, so an old award with a recent change still appears. The Spectra Systems contract above started on 31 May 2023 and was last modified on 13 November 2026. Add"date_type": "new_awards_only"to the time period to keep only new awards: the semiconductor count then fell from 12 contracts to 6. - Agency names must be written out in full. The agency filter matches USAspending's own names. For awards in the same 30 days, "National Aeronautics and Space Administration" counted 884 contracts, while "NASA" counted 0, with no error. Look names up first with
/api/v2/autocomplete/awarding_agency/, which maps NASA to its full name. - Searches start on 1 October 2007. A start date of 1 January 2007 returns HTTP 422: "start_date cannot be earlier than '2007-10-01'". For older awards, the API points you to the Custom Award Download on the website or the download endpoints.
- Placeholder names for people. Awards to individuals are often published under placeholder recipient names. Between 1 January and 15 November 2026, a recipient search for "REDACTED DUE TO PII" counted 1,541,864 direct payments, 52,829 loans, 11,388 grants and 56,296 other awards. "INDIVIDUAL RECIPIENT" counted 682 grants. Filter these out if you want organisations only.
- Pages of 100.
limitcan't go above 100 (101 returns HTTP 422). Ask for"page": 2,3and so on whilepage_metadata.hasNextis true. - UEI, not DUNS. Recipients are identified by the SAM.gov Unique Entity ID (UEI). Ask for the
Recipient UEIfield if you want to join awards to other data.
Is USAspending the same as SAM.gov or Grants.gov?
No. USAspending shows money that has already been awarded. Contract opportunities that are still open are on SAM.gov, and open grant opportunities are on Grants.gov. See our SAM.gov API guide and Grants.gov API guide for those. A common pattern is to watch open bids in one source and check who won similar work before in USAspending.
We built this
Disclosure: Your Evenings built and sells this. It's independent and isn't affiliated with or endorsed by the U.S. Department of the Treasury or the Bureau of the Fiscal Service. The USAspending Federal Spending API on Apify Store runs these searches for you and returns one clean row per award.
- Filters: keyword, recipient name or UEI, awarding agency (an abbreviation such as NASA or the full name), NAICS or PSC code, place-of-performance state, date window and minimum amount.
- Contracts and grants in one run. It runs one search per group and merges the results, newest last-modified date first.
- Organisation recipients only. Individual, sole-proprietor and redacted personal recipients are skipped, never charged and counted in a free status row.
- Every row has the amount, awarding and funding agency, dates, NAICS or assistance listing, place of performance and the official USAspending award link.
- Monitor mode. A scheduled run returns only new awards, or awards whose amount or last-modified date has changed.
Pricing: $0.002 per award returned, plus $0.01 per monitor run that returns new or changed awards and a small Actor start fee. Higher Apify plans pay less. A run that returns 25 awards costs 25 × $0.002 = $0.05, plus the start fee.
FAQ
Do I need an API key for the USAspending API? No. The USAspending.gov API is public and works without a key or an account.
How far back does the USAspending API go? Award searches start on 1 October 2007. An earlier start date returns an error. For older awards, use the Custom Award Download on USAspending.gov or its download endpoints.
Why does my USAspending search return old awards? The date filter matches the latest transaction by default, so an older award with a recent change is included. Set date_type to new_awards_only to keep only new awards.
Why does my agency filter return nothing? The agency filter needs USAspending's full agency name, such as National Aeronautics and Space Administration rather than NASA. An abbreviation returns no results and no error.
Is USAspending the same as SAM.gov? No. USAspending shows money already awarded. Open contract opportunities are on SAM.gov and open grant opportunities are on Grants.gov.
Product names and logos belong to their owners. Your Evenings is not affiliated with or endorsed by them. Award data from USAspending.gov (U.S. Department of the Treasury, Bureau of the Fiscal Service). Your Evenings is not affiliated with or endorsed by the U.S. Department of the Treasury or the Bureau of the Fiscal Service.
