# USAspending.gov Federal Agency Spending Scraper (`plainkitbin/pd-gov-contracts`) Actor

Extract US federal spending, agency budgets, and procurement records from USAspending.gov API as structured JSON dataset rows. Not affiliated with USAspending.gov API.

- **URL**: https://apify.com/plainkitbin/pd-gov-contracts.md
- **Developed by:** [PlainKit bin](https://apify.com/plainkitbin) (community)
- **Categories:** Business, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.09 / 1,000 usaspending records

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

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.gov Federal Agency Spending Scraper

### Introduction

The USAspending.gov Federal Agency Spending Scraper delivers clean tabular federal spending data from api.usaspending.gov directly to your data pipelines. Procurement analysts, government contracting researchers, public policy researchers, civic developers, and automated software agents require dependable access to US federal contract outlays, agency obligations, and budgetary numbers without navigating complex bulk archives or fragmented interfaces. Each run queries the USAspending.gov API to fetch structured records detailing agency identifiers, toptier codes, agency abbreviations, obligated amounts, budget authority numbers, outlay amounts, fiscal year tracking, and links to congressional justifications.

This Actor is an independent utility and is not affiliated with USAspending.gov API.

### Tutorial

Getting started with the USAspending API Scraper is straightforward:

1. Specify an optional search keyword such as an agency name, acronym, or code (for example `HHS`, `Treasury`, or `Defense`).
2. Choose a sorting metric such as `obligated_amount`, `budget_authority_amount`, `outlay_amount`, or `percentage_of_total_budget_authority`.
3. Set the sort direction to `desc` (descending) or `asc` (ascending) according to your research objectives.
4. Set the maximum number of items to retrieve (`max_items`, from 1 to 1000).
5. Run the Actor on the Apify platform or trigger it via API, automated workflows, or scheduled tasks.
6. Export the resulting dataset in your preferred format (JSON, CSV, Excel, or Parquet).

### Pricing

This Actor operates on the Apify Pay-Per-Event model. You are charged only for successfully delivered dataset records:

- Event name: `gov-contract`
- Pricing tier breakdown:
  - FREE subscription tier: $0.003 per delivered row
  - BRONZE subscription tier: $0.0027 per delivered row
  - SILVER subscription tier: $0.0024 per delivered row
  - GOLD subscription tier: $0.00209 per delivered row
  - PLATINUM subscription tier: $0.00209 per delivered row
  - DIAMOND subscription tier: $0.002 per delivered row

Each agency record is pushed first to the output dataset and charged immediately after a successful push. A refused charge stops execution and that record remains delivered and uncharged. A reached spending limit halts processing after that record is charged. Failed requests or connection errors produce zero charges and push no data. If the platform restarts or resumes a run, restart safety ensures that previously delivered records are recognized and never pushed or charged twice.

### Input and output examples

#### Input Parameters

| Field | Type | Description | Default | Prefill |
| --- | --- | --- | --- | --- |
| `search` | String | Filter by agency name, abbreviation, or slug keyword (case-insensitive). | `""` | `""` |
| `sort` | String (select) | Metric used to sort spending records (`obligated_amount`, `budget_authority_amount`, etc.). | `obligated_amount` | `obligated_amount` |
| `order` | String (select) | Sorting direction: descending (`desc`) or ascending (`asc`). | `desc` | `desc` |
| `max_items` | Integer (1-1000) | Maximum total number of agency spending records to output. | `10` | `5` |

#### Sample Input

```json
{
  "search": "Health",
  "sort": "obligated_amount",
  "order": "desc",
  "max_items": 5
}
```

#### Sample Output Record

Each delivered record adheres to the following unified schema:

```json
{
  "abbreviation": "HHS",
  "active_fq": "4",
  "active_fy": "2026",
  "agency_id": 806,
  "agency_name": "Department of Health and Human Services",
  "agency_slug": "department-of-health-and-human-services",
  "budget_authority_amount": 3524332883053.65,
  "congressional_justification_url": "https://www.hhs.gov/cj",
  "current_total_budget_authority_amount": 14142952299307.62,
  "obligated_amount": 3178504574728.37,
  "outlay_amount": 2954915382244.14,
  "percentage_of_total_budget_authority": 0.24919357772465844,
  "toptier_code": "075"
}
```

### Actor recommendations

For teams monitoring public government spending, integrating multiple specialized scrapers provides comprehensive transparency:

- Pair with AusTender Contracts Scraper for Australian public procurement oversight.
- Connect with SEC Filings Scraper to cross-reference corporate government contractors with public disclosures.
- Feed structured datasets into analytics pipelines and AI agents for automated procurement intelligence and compliance reporting.

### FAQ and support

- **Where does this data originate?**
  Data is retrieved from the public USAspending.gov API endpoints operated by the US Department of the Treasury.
- **Is an API key required?**
  No API key or user authentication is required. The Actor connects directly to public endpoints with bounded polite rates.
- **How are rate limits managed?**
  Requests are throttled with polite spacing and bounded exponential backoff retries. If the upstream API returns HTTP 401, 403, or 429, the run finishes gracefully with a single uncharged status notice.
- **How do I get assistance?**
  For questions, feature requests, or technical support, please contact support@example.com or submit feedback through the Apify platform console.

# Actor input Schema

## `search` (type: `string`):

Filter by agency name, abbreviation, or slug keyword (case-insensitive substring).

## `sort` (type: `string`):

Metric used to sort spending records.

## `order` (type: `string`):

Sorting direction: descending (desc) or ascending (asc).

## `max_items` (type: `integer`):

Maximum total number of agency spending records to output (1-1000).

## Actor input object example

```json
{
  "search": "",
  "sort": "obligated_amount",
  "order": "desc",
  "max_items": 5
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset items produced 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 = {
    "search": "",
    "sort": "obligated_amount",
    "order": "desc",
    "max_items": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("plainkitbin/pd-gov-contracts").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 = {
    "search": "",
    "sort": "obligated_amount",
    "order": "desc",
    "max_items": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("plainkitbin/pd-gov-contracts").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 '{
  "search": "",
  "sort": "obligated_amount",
  "order": "desc",
  "max_items": 5
}' |
apify call plainkitbin/pd-gov-contracts --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,plainkitbin/pd-gov-contracts"
        }
    }
}
```

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/DUaoVpq1UadHYYifr/builds/j8kXj8THFlRYCXSb4/openapi.json
