# USASpending.gov Scraper (`crawlerbros/usaspending-scraper`) Actor

Scrape USASpending.gov, the official open data source for US federal government spending. Covers contracts, grants, loans, and other awards totaling $6+ trillion annually across all federal agencies.

- **URL**: https://apify.com/crawlerbros/usaspending-scraper.md
- **Developed by:** [Crawler Bros](https://apify.com/crawlerbros) (community)
- **Categories:** Developer tools, Automation, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 4 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $3.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## USASpending.gov Scraper

Extract US federal government spending data from [USASpending.gov](https://www.usaspending.gov) — the official transparency platform for tracking $6+ trillion in federal contracts, grants, loans, and financial assistance annually.

### What This Actor Does

This actor accesses the official USASpending.gov public API to retrieve:
- **Federal Awards** — Search contracts, grants, loans, and other awards by keyword, agency, date range, or amount
- **Agency Spending** — List all federal agencies ranked by budgetary authority
- **Award Details** — Get complete details for a specific award by its unique ID
- **State Spending** — Total federal spending breakdown by US state
- **Top Recipients** — Identify the largest recipients of federal spending

No authentication required — USASpending.gov data is public.

### Input Configuration

| Parameter | Type | Description |
|-----------|------|-------------|
| `mode` | String (required) | What data to fetch. Options: `awards`, `agencies`, `byAwardId`, `spendingByState`, `topRecipients` |
| `query` | String | Keyword search for awards or recipients (e.g. `infrastructure`, `cybersecurity`) |
| `awardType` | String | Filter by award type: `contracts`, `grants`, `loans`, `direct_payments`, `other_financial_assistance` |
| `fromDate` | String | Start date filter (YYYY-MM-DD, e.g. `2023-01-01`) |
| `toDate` | String | End date filter (YYYY-MM-DD, e.g. `2023-12-31`) |
| `agencyName` | String | Filter awards by awarding agency name |
| `minAmount` | Integer | Minimum award amount in USD |
| `maxAmount` | Integer | Maximum award amount in USD |
| `awardId` | String | Unique award ID for `byAwardId` mode |
| `maxItems` | Integer | Maximum records to return (1–1,000, default 25) |

#### Award Types

| Type | Description |
|------|-------------|
| `contracts` | BPA calls, purchase orders, delivery orders, definitive contracts |
| `grants` | Block grants, formula grants, project grants, cooperative agreements |
| `loans` | Direct loans and guaranteed/insured loans |
| `direct_payments` | Formula-funded and unrestricted direct payments |
| `other_financial_assistance` | Insurance and other reimbursable assistance |

### Output Fields

#### Awards Mode
| Field | Type | Description |
|-------|------|-------------|
| `awardId` | String | Unique award identifier (e.g. `CONT_AWD_N000...`) |
| `recipientName` | String | Name of the recipient organization |
| `awardType` | String | Contract, grant, loan, etc. |
| `startDate` | String | Award start date (YYYY-MM-DD) |
| `endDate` | String | Award end date (YYYY-MM-DD) |
| `awardAmount` | Number | Total obligation in USD |
| `awardingAgency` | String | Federal agency that awarded the contract/grant |
| `awardingSubAgency` | String | Sub-agency or office |
| `fundingAgency` | String | Agency providing the funding |
| `description` | String | Award description/statement of work |
| `usaspendingUrl` | String | Link to the award on USASpending.gov |

#### Agencies Mode
| Field | Type | Description |
|-------|------|-------------|
| `agencyName` | String | Full agency name |
| `agencyAbbreviation` | String | Agency abbreviation (e.g. DOD, NASA) |
| `budgetaryResources` | Number | Total budget authority in USD |
| `percentOfTotal` | Number | Percentage of total federal budget |
| `obligations` | Number | Total obligations in USD |
| `usaspendingUrl` | String | Agency page on USASpending.gov |

#### State Spending Mode
| Field | Type | Description |
|-------|------|-------------|
| `stateCode` | String | Two-letter state code (e.g. CA, TX) |
| `stateName` | String | Full state name |
| `totalSpending` | Number | Total federal spending in the state (USD) |
| `population` | Integer | State population |
| `perCapitaSpending` | Number | Federal spending per capita (USD) |

### Example Use Cases

#### Find Infrastructure Contracts in 2023
```json
{
  "mode": "awards",
  "query": "infrastructure",
  "awardType": "contracts",
  "fromDate": "2023-01-01",
  "toDate": "2023-12-31",
  "maxItems": 25
}
````

#### Get Top Federal Agencies by Budget

```json
{
  "mode": "agencies",
  "maxItems": 20
}
```

#### Get Award Details by ID

```json
{
  "mode": "byAwardId",
  "awardId": "CONT_AWD_NNM07AB03C_8000_-NONE-_-NONE-"
}
```

#### Federal Spending by State in 2023

```json
{
  "mode": "spendingByState",
  "fromDate": "2023-01-01",
  "toDate": "2023-12-31",
  "awardType": "contracts"
}
```

#### Top Recipients for Defense Spending

```json
{
  "mode": "topRecipients",
  "query": "defense",
  "maxItems": 10
}
```

### Data Source

All data comes from the [USASpending.gov API v2](https://api.usaspending.gov/) — the official US government transparency portal mandated by the Digital Accountability and Transparency Act (DATA Act). Data covers fiscal year 2000 to present.

### Frequently Asked Questions

**Q: Is this data official and reliable?**
A: Yes. USASpending.gov is the official federal spending transparency website maintained by the US Department of the Treasury. Data is submitted directly by federal agencies.

**Q: How current is the data?**
A: Most award data is updated weekly. The platform covers spending from FY2000 to the present.

**Q: What is an Award ID?**
A: Each federal award has a unique identifier. Contract IDs typically look like `CONT_AWD_N00014...` and grants like `ASST_NON_...`. You can find award IDs by searching in `awards` mode first.

**Q: How large are federal awards?**
A: Awards range from small purchases of a few hundred dollars to multi-billion dollar defense contracts. Use `minAmount` and `maxAmount` to filter by size.

**Q: Can I filter by congressional district or city?**
A: The `spendingByState` mode breaks down by US state. For more granular geographic data, use `awards` mode and filter by agency or keyword.

**Q: Is authentication required?**
A: No. The USASpending.gov API is fully public and requires no API key or authentication.

**Q: What's the difference between awards and subawards?**
A: This actor returns prime awards (direct federal awards). Subawards (awards made by prime recipients to other organizations) are not included.

# Actor input Schema

## `mode` (type: `string`):

What type of spending data to fetch.

## `query` (type: `string`):

Search keywords to filter awards or recipients (e.g. 'infrastructure', 'cybersecurity', 'NASA'). Used in modes: awards, topRecipients.

## `awardType` (type: `string`):

Filter awards by type. Leave blank to include all types.

## `fromDate` (type: `string`):

Filter awards with start date on or after this date. Format: YYYY-MM-DD (e.g. 2023-01-01).

## `toDate` (type: `string`):

Filter awards with end date on or before this date. Format: YYYY-MM-DD (e.g. 2023-12-31).

## `agencyName` (type: `string`):

Filter awards by awarding agency name (e.g. 'Department of Defense', 'NASA'). Used in mode=awards.

## `minAmount` (type: `integer`):

Filter awards with total obligation at least this amount in USD.

## `maxAmount` (type: `integer`):

Filter awards with total obligation at most this amount in USD.

## `awardId` (type: `string`):

The unique award identifier from USASpending.gov. Example: CONT\_AWD\_N0001417C0001\_1700\_-NONE-\_-NONE-

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

Maximum number of records to return.

## Actor input object example

```json
{
  "mode": "awards",
  "query": "infrastructure",
  "fromDate": "2023-01-01",
  "toDate": "2023-12-31",
  "maxItems": 5
}
```

# Actor output Schema

## `spendingData` (type: `string`):

Dataset containing all scraped federal spending records.

# 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 = {
    "mode": "awards",
    "query": "infrastructure",
    "fromDate": "2023-01-01",
    "toDate": "2023-12-31",
    "maxItems": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("crawlerbros/usaspending-scraper").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 = {
    "mode": "awards",
    "query": "infrastructure",
    "fromDate": "2023-01-01",
    "toDate": "2023-12-31",
    "maxItems": 5,
}

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

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

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

```

## CLI example

```bash
echo '{
  "mode": "awards",
  "query": "infrastructure",
  "fromDate": "2023-01-01",
  "toDate": "2023-12-31",
  "maxItems": 5
}' |
apify call crawlerbros/usaspending-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=crawlerbros/usaspending-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "USASpending.gov Scraper",
        "description": "Scrape USASpending.gov, the official open data source for US federal government spending. Covers contracts, grants, loans, and other awards totaling $6+ trillion annually across all federal agencies.",
        "version": "1.0",
        "x-build-id": "VlRa8etb5yLIWpWaJ"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/crawlerbros~usaspending-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-crawlerbros-usaspending-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/crawlerbros~usaspending-scraper/runs": {
            "post": {
                "operationId": "runs-sync-crawlerbros-usaspending-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/crawlerbros~usaspending-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-crawlerbros-usaspending-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "mode"
                ],
                "properties": {
                    "mode": {
                        "title": "Mode",
                        "enum": [
                            "awards",
                            "agencies",
                            "byAwardId",
                            "spendingByState",
                            "topRecipients"
                        ],
                        "type": "string",
                        "description": "What type of spending data to fetch.",
                        "default": "awards"
                    },
                    "query": {
                        "title": "Keyword Search",
                        "type": "string",
                        "description": "Search keywords to filter awards or recipients (e.g. 'infrastructure', 'cybersecurity', 'NASA'). Used in modes: awards, topRecipients.",
                        "default": "infrastructure"
                    },
                    "awardType": {
                        "title": "Award Type",
                        "enum": [
                            "contracts",
                            "grants",
                            "loans",
                            "direct_payments",
                            "other_financial_assistance"
                        ],
                        "type": "string",
                        "description": "Filter awards by type. Leave blank to include all types."
                    },
                    "fromDate": {
                        "title": "From Date (YYYY-MM-DD)",
                        "type": "string",
                        "description": "Filter awards with start date on or after this date. Format: YYYY-MM-DD (e.g. 2023-01-01)."
                    },
                    "toDate": {
                        "title": "To Date (YYYY-MM-DD)",
                        "type": "string",
                        "description": "Filter awards with end date on or before this date. Format: YYYY-MM-DD (e.g. 2023-12-31)."
                    },
                    "agencyName": {
                        "title": "Awarding Agency Name",
                        "type": "string",
                        "description": "Filter awards by awarding agency name (e.g. 'Department of Defense', 'NASA'). Used in mode=awards."
                    },
                    "minAmount": {
                        "title": "Minimum Award Amount (USD)",
                        "minimum": 0,
                        "maximum": 1000000000000,
                        "type": "integer",
                        "description": "Filter awards with total obligation at least this amount in USD."
                    },
                    "maxAmount": {
                        "title": "Maximum Award Amount (USD)",
                        "minimum": 0,
                        "maximum": 1000000000000,
                        "type": "integer",
                        "description": "Filter awards with total obligation at most this amount in USD."
                    },
                    "awardId": {
                        "title": "Award ID (mode=byAwardId)",
                        "type": "string",
                        "description": "The unique award identifier from USASpending.gov. Example: CONT_AWD_N0001417C0001_1700_-NONE-_-NONE-"
                    },
                    "maxItems": {
                        "title": "Max Items",
                        "minimum": 1,
                        "maximum": 1000,
                        "type": "integer",
                        "description": "Maximum number of records to return.",
                        "default": 25
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
