# SAM.gov & USAspending Federal Contracts & Grants Scraper (`autotroph/us-federal-procurement-normalizer`) Actor

Scrape US federal contracts, IDVs & grants from USAspending.gov with SAM.gov UEI profiles, set-asides (8(a), SDVOSB, HUBZone), NAICS/PSC/CFDA codes, IDV child-order rollups, ceilings, outlays & sub-awards. Built for GovCon lead gen & Apify MCP.

- **URL**: https://apify.com/autotroph/us-federal-procurement-normalizer.md
- **Developed by:** [Shuma Fujino](https://apify.com/autotroph) (community)
- **Categories:** Lead generation, Business, MCP servers
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 1,000 normalized us federal awards

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## US Federal Procurement & Contract Awards Normalizer (USAspending.gov + SAM.gov)

Extract clean, reconciled, **integrity-verified US federal contract awards, IDVs (Indefinite Delivery Vehicles), and federal grants** directly from **official, zero-proxy US Treasury USAspending.gov v2 REST APIs** enriched with **SAM.gov UEI entity profiles, socioeconomic designations, NAICS/PSC/CFDA hierarchies, IDV child-order rollups, and prime-to-subcontractor graphs** — built for GovCon business development, capture intelligence, defense & federal analytics, grant tracking, and **AI Agents via Apify MCP**.

### Why This Actor Beats Naive USAspending & SAM.gov Scrapers

| Capability | Naive Flat Search / HTML Scrapers | US Federal Procurement & Contract Awards Normalizer |
|---|---|---|
| **Data Source & Cost** | Scrapes JS-heavy SAM.gov UI or brittle portals (WAF blocks, proxy costs, missing API keys) | Uses **official zero-proxy US Treasury USAspending.gov v2 REST APIs** with multi-endpoint graph enrichment |
| **NAICS, PSC & CFDA Resolution** | Flat `spending_by_award` returns `NAICS Code: null` and `PSC Code: null` on nearly all awards, and omits grant CFDA listings | Resolves full 6-digit **NAICS** (+ 2-digit sector), 4-char **PSC**, and **CFDA / Assistance Listing** codes & descriptions across contracts, IDVs, and grants |
| **IDV Child-Order Rollups** | Flat search emits `$0.0` obligations and `End Date: null` on Indefinite Delivery Vehicles (IDVs) | Queries `/api/v2/idvs/amounts/{id}/` to reconcile `effective_obligation_usd`, `idv_child_award_count`, grandchild totals, and IDV ceilings |
| **SAM.gov UEI & Socioeconomic Profile** | Missing corporate parent UEI, trailing-12M vendor volume, and SAM.gov set-aside/socioeconomic tags | Enriches `/api/v2/recipient/{hash}/` with validated 12-char **SAM.gov UEI**, parent UEI, direct `sam_gov_entity_url`, and normalized flags (`small_business`, `8(a)`, `woman_owned`, `veteran_owned`, `sdvosb`, `hubzone`, `minority_owned`) |
| **Financial & Ceiling Reconciliation** | Returns a single raw `Award Amount` without outlays, ceilings, or grant matching funds | Reconciles `total_obligation_usd`, `base_exercised_options_usd`, `award_ceiling_usd`, `remaining_ceiling_usd`, `total_outlay_usd`, `outlay_ratio_pct`, and `non_federal_funding_usd` |
| **FPDS Competition & Sub-Award Graph** | Misses solicitation numbers, set-asides, offer counts, and subcontractor flows | Extracts `solicitation_identifier` (+ direct `sam_gov_solicitation_url`), `extent_competed`, `set_aside_type`, `offers_received`, `contract_pricing_type`, and top 5 sub-awards |
| **Cryptic FPDS & PoP Cleanup** | Leaves cryptic `IGF::OT::IGF` descriptions and `null` Place of Performance on IDVs | Rewrites cryptic FPDS placeholders into readable NAICS/PSC summaries and applies deterministic SAM.gov HQ location fallback (`place_of_performance_source`) with formatted congressional districts (`KY-03`) |
| **Deterministic Integrity Verification** | Silent schema drift, malformed UEIs, and broken financial math | Built-in per-award accounting & schema verifier (`integrity_valid`, `integrity_errors`) — **100% pass across 24 real federal contracts, IDVs & grants** (vs. `13.8%` for naive flat search) |

### Verified Output Schema Example (`HT940216C0001`)

```json
{
  "generated_unique_award_id": "CONT_AWD_HT940216C0001_9700_-NONE-_-NONE-",
  "award_id": "HT940216C0001",
  "award_category": "contract",
  "award_type_code": "D",
  "award_type_description": "DEFINITIVE CONTRACT",
  "description": "IGF::OT::IGF",
  "normalized_summary": "Direct Health and Medical Insurance Carriers — Medical - General Health Care — DEFINITIVE CONTRACT",
  "is_cryptic_fpds_description": true,
  "recipient_name": "HUMANA GOVERNMENT BUSINESS INC",
  "recipient_uei": "ZE6ZM6NKSV43",
  "recipient_uei_valid": true,
  "naics_code": "524114",
  "naics_description": "Direct Health and Medical Insurance Carriers",
  "psc_code": "Q201",
  "total_obligation_usd": 51269205263.03,
  "effective_obligation_usd": 51269205263.03,
  "base_exercised_options_usd": 52641654181.19,
  "award_ceiling_usd": 56620536577.19,
  "remaining_ceiling_usd": 5351331314.16,
  "solicitation_identifier": "HT940215R0002",
  "extent_competed": "A",
  "set_aside_type": "NONE",
  "offers_received": 4,
  "awarding_agency_name": "Department of Defense",
  "awarding_sub_agency_name": "Defense Health Agency",
  "place_of_performance_country": "USA",
  "place_of_performance_state": "KY",
  "place_of_performance_congressional_district": "KY-03",
  "place_of_performance_source": "award_pop",
  "subaward_count": 151,
  "total_subaward_amount_usd": 1917332761.94,
  "usaspending_url": "https://www.usaspending.gov/award/CONT_AWD_HT940216C0001_9700_-NONE-_-NONE-",
  "sam_gov_entity_url": "https://sam.gov/search/?index=ei&q=ZE6ZM6NKSV43",
  "sam_gov_solicitation_url": "https://sam.gov/search/?index=opp&q=HT940215R0002",
  "integrity_valid": true,
  "integrity_errors": []
}
```

### Input Configuration

- **`awardCategories`**: Any combination of `["contracts", "idvs", "grants"]` (default: all three, round-robin balanced).
- **`keywords`**: Optional search terms matched against award descriptions (e.g., `["cybersecurity", "cloud"]`).
- **`naicsCodes` / `pscCodes`**: Optional 2–6 digit NAICS or 4-char PSC code filters (e.g., `["541512"]`, `["D302"]`).
- **`recipientSearchTerms`**: Optional vendor names or 12-char SAM.gov UEIs (e.g., `["BOOZ ALLEN", "ZE6ZM6NKSV43"]`).
- **`awardIds`**: Optional exact PIID, FAIN, or `generated_unique_award_id` values for direct lookup.
- **`awardingAgencies` / `placeOfPerformanceStates`**: Filter by federal agency name or 2-letter US state code (`VA`, `MD`, `DC`, `TX`).
- **`startDate` / `endDate` / `minAwardAmount` / `maxItems`**: Date window, minimum obligated USD, and output cap (1–500).
- **`includeRecipientProfile` / `includeSubawards` / `strictValidation`**: Toggle SAM.gov recipient profile enrichment, top-5 sub-awards, and strict accounting-verifier filtering.

### Transparent Pay-Per-Event (PPE) Pricing

- **`apify-actor-start`**: `$0.005` per run start
- **`award-normalized`**: `$0.004` per normalized federal award (`$4.00 / 1,000 awards`, including multi-endpoint award detail, IDV child-order rollup, SAM.gov UEI/socioeconomic profile, sub-awards, and accounting verification)
- **Zero proxy surcharge**: Powered strictly by official public US Treasury `api.usaspending.gov` REST endpoints.

### Local Standalone Test (No Apify Credentials Needed)

```bash
python -m src.main --local-test --categories contracts,idvs,grants --max-items 3
```

# Actor input Schema

## `awardCategories` (type: `array`):

Award categories to search: any combination of 'contracts', 'idvs', and 'grants' (defaults to \['contracts', 'idvs', 'grants']).

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

Optional search keywords matched against federal award descriptions (e.g., \['cybersecurity', 'cloud', 'AI']).

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

Optional 2- to 6-digit NAICS industry codes (e.g., \['541512', '541511', '541715']).

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

Optional 4-character Product/Service Codes (e.g., \['D302', 'R499', 'Q201']).

## `recipientSearchTerms` (type: `array`):

Optional recipient company names or 12-character SAM.gov UEIs (e.g., \['BOOZ ALLEN', 'ZE6ZM6NKSV43']).

## `awardIds` (type: `array`):

Optional exact PIID, FAIN, or USAspending generated_unique_award_id values for direct normalization.

## `awardingAgencies` (type: `array`):

Optional toptier federal agency names (e.g., \['Department of Defense', 'Department of Health and Human Services', 'National Aeronautics and Space Administration']).

## `placeOfPerformanceStates` (type: `array`):

Optional 2-letter US state/territory codes (e.g., \['VA', 'MD', 'DC', 'TX']).

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

Start of action/performance window (ISO YYYY-MM-DD, e.g., '2025-10-01' for FY2026).

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

End of action/performance window (ISO YYYY-MM-DD, e.g., '2026-09-30').

## `minAwardAmount` (type: `integer`):

Optional minimum obligated dollar amount filter (0 disables lower bound).

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

Maximum number of normalized federal awards to emit (1 to 500).

## `includeRecipientProfile` (type: `boolean`):

Fetch USAspending/SAM.gov recipient profile for socioeconomic flags, corporate parent UEI, and trailing-12M awards.

## `includeSubawards` (type: `boolean`):

Fetch top 5 prime-to-subcontractor sub-awards when subaward_count > 0.

## `strictValidation` (type: `boolean`):

When true, records failing deterministic accounting/schema integrity checks are skipped instead of billed/pushed.

## Actor input object example

```json
{
  "awardCategories": [
    "contracts",
    "idvs",
    "grants"
  ],
  "keywords": [],
  "naicsCodes": [],
  "pscCodes": [],
  "recipientSearchTerms": [],
  "awardIds": [],
  "awardingAgencies": [],
  "placeOfPerformanceStates": [],
  "startDate": "2025-10-01",
  "endDate": "2026-09-30",
  "minAwardAmount": 0,
  "maxItems": 10,
  "includeRecipientProfile": true,
  "includeSubawards": true,
  "strictValidation": false
}
```

# Actor output Schema

## `awards` (type: `string`):

No description

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("autotroph/us-federal-procurement-normalizer").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("autotroph/us-federal-procurement-normalizer").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 '{}' |
apify call autotroph/us-federal-procurement-normalizer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,autotroph/us-federal-procurement-normalizer"
        }
    }
}
```

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/NOwmDhY4W404Wx9Ss/builds/EcKXoiQDmdHW5tYGd/openapi.json
