# USAspending Federal Awards (`nichedata-lab/usaspending-awards`) Actor

Search US federal contracts and awards from the official USAspending API and save flat rows to a dataset. A Standby MCP server lets agents search awards, open one award, and total spending by agency or recipient.

- **URL**: https://apify.com/nichedata-lab/usaspending-awards.md
- **Developed by:** [nichedata-lab](https://apify.com/nichedata-lab) (community)
- **Categories:** Business, AI, MCP servers
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 award results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## USAspending Federal Awards

Search United States federal contracts and other awards from the [official USAspending API](https://api.usaspending.gov/docs/endpoints) and save one flat row per award to an Apify dataset. The same Actor is an [MCP server](https://docs.apify.com/sdk/python/docs/guides/mcp-servers) in Standby mode, so an agent can search awards, open one award, total spending by awarding agency, or total spending by recipient.

This Actor calls `https://api.usaspending.gov/` only. It does not open usaspending.gov pages. The site's robots.txt disallows query URLs, and the API needs no key.

### Use cases

- Pull a short list of contracts that mention a product, technology, or program, with agency, amount, NAICS, PSC, and place of performance.
- Limit that list to one awarding agency, one recipient name or UEI, a NAICS or PSC code, a state or ZIP, a date window, or an amount range.
- Give an assistant a live way to answer "who is receiving these awards?" and "which agencies are obligating the money?" without downloading the full USAspending archive.

### How to run it

The prefilled input is a working search: keyword `cybersecurity`, contract types A–D (BPA call, purchase order, delivery order, definitive contract), action dates from 2025-10-01 through 2026-09-30, and 10 awards, largest amount first. Start the Actor with that input to get rows.

Filters are combined. Leave a field empty to ignore it.

| Input | What it does |
| --- | --- |
| Keywords | Text matched by the USAspending award search. |
| Award types | Contract, IDV, legacy assistance (02–11), and current assistance (F001–F010) codes from the search API. |
| Awarding agency / Funding agency | Exact top-tier agency name, for example `Department of Homeland Security`. |
| Recipient | One recipient name or UEI. |
| NAICS codes | Code or prefix. `541512` is computer systems design services. |
| PSC codes | Product and Service Code, for example `J069`. |
| Start date / End date | Action date (`date_type: action_date`), which is the award's latest transaction date. The search API's earliest date is 2007-10-01. |
| Minimum / maximum award amount | Dollar bounds sent to the search API as `lower_bound` and `upper_bound`. |
| Place of performance | Country (`USA` or `FOREIGN`), 2-letter state, city, and 5-digit ZIP. A state, city, or ZIP without a country uses `USA`. |
| Maximum awards | 1 to 200. Default 10. |
| Sort by / Sort order | Award amount, start date, end date, or last modified date. |

Example input for definitive contracts awarded by the Department of Homeland Security:

```json
{
  "keywords": ["software"],
  "awardTypeCodes": ["D"],
  "awardingAgency": "Department of Homeland Security",
  "startDate": "2025-10-01",
  "endDate": "2026-09-30",
  "maxItems": 3
}
```

Example input for computer-systems contracts performed in Virginia, between $100,000 and $5,000,000:

```json
{
  "keywords": [],
  "awardTypeCodes": ["A", "B", "C", "D"],
  "naicsCodes": ["541512"],
  "popState": "VA",
  "minAmount": 100000,
  "maxAmount": 5000000,
  "startDate": "2026-01-01",
  "endDate": "2026-06-30",
  "maxItems": 3
}
```

### Output

Each dataset item is a flat award. Amounts are US dollars as reported by the API. `generatedAwardId` is the id used by the award-detail endpoint and by the MCP `get_award` tool. `usaspendingUrl` links to the public award page.

```json
{
  "awardId": "FA862118F6251",
  "generatedAwardId": "CONT_AWD_FA862118F6251_9700_FA862115D6276_9700",
  "recipientName": "LOCKHEED MARTIN CORPORATION",
  "recipientUei": "KDT2YLB34NT6",
  "awardAmount": 666315748.84,
  "awardingAgency": "Department of Defense",
  "awardingSubAgency": "Department of the Air Force",
  "startDate": "2018-02-08",
  "endDate": "2027-01-31",
  "naicsCode": "336413",
  "pscCode": "J069",
  "popCity": "ORLANDO",
  "popState": "FL",
  "description": "AFSOC ACTS AWARD OF CONTRACT FOR CLS, ENGINEERING, INSTRUCTION, CYBERSECURITY, DMO",
  "usaspendingUrl": "https://www.usaspending.gov/award/CONT_AWD_FA862118F6251_9700_FA862115D6276_9700",
  "dnbNotice": "Recipient name and location may include Dun & Bradstreet Open Data. Attribute: Dun & Bradstreet, Inc. DUNS numbers, parent-company identifiers, and street addresses are omitted."
}
```

The dataset view **Overview** shows the award id, recipient, UEI, amount, agencies, dates, NAICS, PSC, place-of-performance state, description, and link.

The Actor does not return subawards, transaction history, or the bulk-download archive. For a full extract, use USAspending's own download endpoints.

### MCP server

In Standby mode the Actor serves the MCP endpoint at `/mcp` (Streamable HTTP). `webServerMcpPath` is `/mcp`. A client connects to the Actor's Standby URL with an Apify API token:

```json
{
  "mcpServers": {
    "usaspending-awards": {
      "url": "https://<username>--usaspending-awards.apify.actor/mcp",
      "headers": {
        "Authorization": "Bearer <APIFY_API_TOKEN>"
      }
    }
  }
}
```

`GET /` answers the platform readiness probe.

| Tool | What it returns |
| --- | --- |
| `search_awards` | Up to 25 flat award rows. Same filters as the Actor. Defaults to contracts in fiscal year 2026. |
| `get_award` | One award. Pass `generatedAwardId` from a search row, for example `CONT_AWD_...`. |
| `spending_by_agency` | Award-level obligation totals by awarding agency. |
| `spending_by_recipient` | Award-level obligation totals by recipient name and UEI. The DUNS `code` field is removed. |

A resource at `resource://usaspending/about` repeats the source and Dun & Bradstreet rules. Reading it is not a charged tool call.

### Pay per event

Dataset runs charge `actor-start` once and `result-item` once per saved row, after that row is stored. A row that fails to store is not a `result-item` charge. Each MCP tool call charges `mcp-tool-call`. The call is charged after the arguments are validated and before the API request. If the run budget is already exhausted, the Actor stops instead of saving another row or running the tool.

Proposed prices are in [PRICING.md](PRICING.md). They are not written into the Actor configuration, so pushing this source does not publish a price. Set the three event names in Apify Console when you enable pay-per-event.

On a multi-tenant Standby run, tool calls pass the `X-Actor-Request-ID` header as the charge `request_id`, which is how the platform bills the caller of a shared run.

### Limits

- Maximum 200 dataset rows per run, and 25 rows or groups per MCP tool call.
- The client sends one request at a time. It does not use proxies, and it ignores `HTTP_PROXY` / `HTTPS_PROXY`.
- A 429 or 5xx response is retried up to 4 attempts with exponential backoff. A numeric `Retry-After` header is honored. Other 4xx responses are not retried.
- The search API rejects dates before 2007-10-01. Older awards are available from USAspending's download tools, which this Actor does not call.
- Agency names must match the published top-tier name. A misspelled name returns no rows.
- Award amounts, dates, and descriptions are whatever the API returns. USAspending republishes agency submissions from FPDS, FABS, and SAM.gov, and those systems have their own reporting gaps.

### Data source and licensing

USAspending.gov is the official public source for US federal spending data, operated for the US Department of the Treasury, Bureau of the Fiscal Service. Its [About](https://www.usaspending.gov/about) page says the data may be copied, adapted, redistributed, and used for commercial or non-commercial purposes, subject to the Dun & Bradstreet limitation linked from the homepage. The API itself does not require an account ([endpoint list](https://api.usaspending.gov/docs/endpoints)).

Treasury's [About the Data](https://www.usaspending.gov/data/about-the-data-download.pdf) says award recipients are identified by a Unique Entity Identifier (UEI), and that information about awards to individuals is aggregated or redacted so personally identifiable information is not published. This Actor returns the UEI and drops executive-officer name slots, which can otherwise contain personal names.

Suggested citation for an award page: include the award title, "USAspending.gov", the award URL, and the date you accessed it. See the citations on the About page.

### Dun & Bradstreet fields

Verified from USAspending's own pages, not from a guess about which column came from which vendor:

- [Limitation on Permissible Use of Dun & Bradstreet, Inc. Data](https://www.usaspending.gov/db_info) says the site includes data supplied by D\&B, "which includes each entity's DUNS Number and its associated business information." It defines **D\&B Open Data** as Business Name, Street Address, City Name, State/Province Name, Country Name, County Code, State/Province Code, State/Province Abbreviation, and ZIP/Postal Code.
- That page requires written attribution to D\&B when you use D\&B Open Data. It says you may not access, use, or disseminate D\&B Open Data in bulk, meaning an amount you could use as an original source or as a substitute for the D\&B product. It says D\&B data other than those Open Data elements may not be used for commercial, resale, or marketing purposes. It prohibits systematic harvesting of the **website** (bots or spiders). It says the data is provided "as is," that it is D\&B intellectual property, and that the federal government assumes no liability for it once it is downloaded. Questions about the scope of that license go to the contact published on that page.
- The [Analyst's Guide](https://www.usaspending.gov/federal-spending-guide) says recipient identifier fields include name, UEI, DUNS, and the matching parent fields, and that the federal government stopped using DUNS as the entity identifier in April 2022 in favor of the UEI. Parent fields are how related recipients are grouped.
- The API contract for spending-by-recipient says the result field `code` is the recipient's DUNS number.

How this Actor handles that:

- It never requests `Recipient DUNS Number`, and if a payload still contains a DUNS, parent recipient name, parent recipient UEI, or parent DUNS, those values are not copied to the output.
- Spending-by-recipient rows keep name, UEI, USAspending recipient id, and amount. The DUNS `code` is dropped. An agency `code` such as `DOD` is an agency abbreviation, not a DUNS, and is kept.
- Street address lines are not copied. Street address is on the Open Data list, and the D\&B terms do not allow bulk redistribution of Open Data as a substitute for a D\&B file.
- Recipient name, city, state, country, and ZIP can be D\&B Open Data. They are included because an award row is hard to read without them. Every award row and recipient total includes `dnbNotice`, which attributes Dun & Bradstreet, Inc. A run stops at 200 rows so this Actor is not a bulk recipient directory.
- The parent **award** (the ordering vehicle's PIID) is kept on award detail. That is another federal award id, not the recipient's corporate parent.
- UEI is kept. Treasury describes it as the government entity identifier.

If you redistribute rows that include recipient name or location, keep the attribution to Dun & Bradstreet, Inc. Do not use the output as a DUNS file, a corporate-family file, or a street-address directory.

### Local development

Python 3.11 or newer. From this directory:

```bash
python -m venv .venv
.venv/bin/pip install -r requirements.txt -r requirements-dev.txt
.venv/bin/pytest
```

`pytest` runs the unit tests and the live tests. The live tests call the public API, run this Actor through the Python SDK's local storage with the default input and three other filter sets, and call each MCP tool. No Apify token is required.

To run the dataset Actor yourself, write the input to the local key-value store and disable the storage purge so that file is still there when the run starts:

```bash
mkdir -p storage/key_value_stores/default
cp examples/default-input.json storage/key_value_stores/default/INPUT.json
APIFY_PURGE_ON_START=false ACTOR_TEST_PAY_PER_EVENT=true python -m usaspending_actor
```

Rows are written under `storage/datasets/default/`. With `ACTOR_TEST_PAY_PER_EVENT=true`, charges are logged under `storage/datasets/charging-log/` and nothing is billed.

Cloud build, `apify push`, Standby hosting, and Console monetization need an Apify account token. This package does not call `apify push`.

### FAQ

**Do I need a USAspending API key?** No. The public API does not require one.

**Why are there no DUNS numbers?** USAspending's D\&B terms restrict DUNS numbers and other non-Open-Data D\&B business information. Use the UEI, which is the identifier Treasury tells readers to use.

**Why is the row cap 200?** The search is meant for a focused export. The cap also keeps a single run from becoming a bulk dump of recipient names and locations, which the D\&B Open Data terms restrict.

**Why did my agency filter return nothing?** The awarding and funding filters use the exact top-tier name from USAspending, such as `Department of Defense` or `General Services Administration`.

**Can I get grants instead of contracts?** Yes. Set `awardTypeCodes` to legacy codes such as `04` or current codes such as `F001`. The default is contracts because that is the prefilled search.

**Does the date filter mean the award was signed in that range?** It filters `action_date`, the latest transaction date. The base start date on the row can be earlier than `startDate`.

# Actor input Schema

## `keywords` (type: `array`):

Words matched against award descriptions and related text. All keywords are sent together. Leave empty to skip keyword filtering.

## `awardTypeCodes` (type: `array`):

USAspending award type codes. The default is contract awards A–D. IDV codes are vehicles such as GWACs and BPAs. Codes 02–11 are legacy assistance types. Codes F001–F010 are the current assistance types the search API also accepts.

## `awardingAgency` (type: `string`):

Exact top-tier awarding agency name as published by USAspending, for example Department of Homeland Security. Leave empty to include every agency.

## `fundingAgency` (type: `string`):

Exact top-tier funding agency name. Leave empty to include every funding agency.

## `recipient` (type: `string`):

One recipient name or UEI. USAspending matches this text against the recipient name and UEI. A legacy DUNS number also matches on the API, but this Actor never returns DUNS numbers.

## `naicsCodes` (type: `array`):

NAICS codes or prefixes. A row matches when its NAICS code starts with one of these values. Example: 541512 for computer systems design services.

## `pscCodes` (type: `array`):

Product and Service Codes. Example: J069.

## `startDate` (type: `string`):

First action date to include, YYYY-MM-DD. The search API's earliest date is 2007-10-01. The date is the latest transaction date on the award (action_date).

## `endDate` (type: `string`):

Last action date to include, YYYY-MM-DD.

## `minAmount` (type: `number`):

Smallest award amount, in US dollars. Leave empty for no minimum.

## `maxAmount` (type: `number`):

Largest award amount, in US dollars. Leave empty for no maximum.

## `popCountry` (type: `string`):

3-letter country code. Use USA, or FOREIGN for every non-US place. If you set a state, city, or ZIP and leave this empty, the Actor uses USA.

## `popState` (type: `string`):

2-letter US state or territory code, for example VA.

## `popCity` (type: `string`):

City name. Without a state, this matches that city name in every state.

## `popZip` (type: `string`):

5-digit US ZIP code.

## `maxItems` (type: `integer`):

How many award rows to save. The Actor requests one page at a time and stops at this number. Minimum 1, maximum 200.

## `sortBy` (type: `string`):

Field used to order the awards before the maximum is applied.

## `sortOrder` (type: `string`):

desc puts the largest or newest values first, depending on the sort field.

## Actor input object example

```json
{
  "keywords": [
    "cybersecurity"
  ],
  "awardTypeCodes": [
    "A",
    "B",
    "C",
    "D"
  ],
  "awardingAgency": "",
  "fundingAgency": "",
  "recipient": "",
  "startDate": "2025-10-01",
  "endDate": "2026-09-30",
  "maxItems": 10,
  "sortBy": "awardAmount",
  "sortOrder": "desc"
}
```

# Actor output Schema

## `overview` (type: `string`):

Flat award rows saved by this run.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "keywords": [
        "cybersecurity"
    ],
    "awardTypeCodes": [
        "A",
        "B",
        "C",
        "D"
    ],
    "awardingAgency": "",
    "fundingAgency": "",
    "recipient": "",
    "startDate": "2025-10-01",
    "endDate": "2026-09-30",
    "maxItems": 10,
    "sortBy": "awardAmount",
    "sortOrder": "desc"
};

// Run the Actor and wait for it to finish
const run = await client.actor("nichedata-lab/usaspending-awards").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "keywords": ["cybersecurity"],
    "awardTypeCodes": [
        "A",
        "B",
        "C",
        "D",
    ],
    "awardingAgency": "",
    "fundingAgency": "",
    "recipient": "",
    "startDate": "2025-10-01",
    "endDate": "2026-09-30",
    "maxItems": 10,
    "sortBy": "awardAmount",
    "sortOrder": "desc",
}

# Run the Actor and wait for it to finish
run = client.actor("nichedata-lab/usaspending-awards").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "keywords": [
    "cybersecurity"
  ],
  "awardTypeCodes": [
    "A",
    "B",
    "C",
    "D"
  ],
  "awardingAgency": "",
  "fundingAgency": "",
  "recipient": "",
  "startDate": "2025-10-01",
  "endDate": "2026-09-30",
  "maxItems": 10,
  "sortBy": "awardAmount",
  "sortOrder": "desc"
}' |
apify call nichedata-lab/usaspending-awards --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,nichedata-lab/usaspending-awards"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/wfcKQHRXpl8ygR3Ne/builds/1k2yoggxAuwezOehI/openapi.json
