# US Federal Contracts Scraper (SAM + awards, hard cap) (`scrapemole/us-gov-contracts-scraper`) Actor

Join public U.S. federal contract opportunities from SAM.gov with USAspending.gov award history: agency, NAICS/PSC, set-aside, deadlines, value and incumbent company names. User-supplied SAM API key; awards work with no key. Hard maxItems cap. No personal contacts. Pay per record.

- **URL**: https://apify.com/scrapemole/us-gov-contracts-scraper.md
- **Developed by:** [ScrapeMole](https://apify.com/scrapemole) (community)
- **Categories:** Lead generation, Automation, 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 $1.60 / 1,000 contract record delivereds

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

## US Federal Contracts: SAM.gov opportunities + USAspending awards

Get **public U.S. federal contract data in one LLM-ready row**: the notice (when you add a free SAM.gov API key), the awarding agency, NAICS and PSC codes, set-aside, deadlines, value, and **matched past awards with incumbent company names**. Award history comes from the official **USAspending.gov API and needs no key**. No login to SAM for awards. Export to JSON, CSV, Excel or Google Sheets, or call it from your app, n8n, Make, Zapier or an AI agent.

Built for GovCon sales, bid writers and agents that need a reliable contracts feed — and for anyone already calling a SAM-only Actor who would rather keep the same input and also see who won last time.

### What you get

One dataset row per opportunity (SAM path) or per award (no-key path):

| Field | Meaning |
|---|---|
| `recordType` | `opportunity` or `award` |
| `title`, `description` | Public title and description (emails and phone numbers redacted) |
| `agency`, `subAgency`, `office` | Awarding organisation |
| `naics`, `psc` | Industry and product/service codes |
| `setAside` | Set-aside, when the source publishes it |
| `postedDate`, `responseDeadline`, `startDate`, `endDate` | Dates |
| `value` | Award or estimated amount in USD |
| `incumbents` | Company names only (recipient and parent on matched awards) |
| `awards` | Nested past awards: PIID, company, amount, dates, NAICS/PSC, USAspending URL |
| `noticeUrl`, `awardUrl` | Links to SAM.gov and USAspending.gov |
| `solicitationNumber`, `piid`, `noticeId` | Identifiers for joins |

Error rows (`status: "error"` with `errorCode` / `errorMessage`) are **free**. You are not charged for empty searches or invalid filters.

This Actor does **not** output contracting-officer names, emails, phone numbers, corporate-officer lists, or street addresses. Incumbents are **company-level** names only. That is intentional.

### Switching from another SAM Actor

Already calling **fortuitous_pirate/sam-gov-scraper** or **jungle_synthesizer/samgov-scraper**? Change the Actor ID to `scrapemole/us-gov-contracts-scraper` and **keep your search input**. Add `samApiKey` if you want live opportunities; without it you still get USAspending awards.

| Coming from | Their input that works here unchanged |
|---|---|
| **fortuitous_pirate/sam-gov-scraper** (40 users/30d, 0 reviews, 10.5% fail, $3/1K as of 14 Nov 2026) | `keywords` / `keywordList`, `keywordMode`, `naicsCodes`, `pscCodes`, `setAsideTypes`, `opportunityTypes`, `agencies`, `states`, `activeOnly`, `status`, `postedWithinDays`, `postedFrom`, `postedTo`, `solicitationNumbers`, `noticeIds`, `maxOpportunities` |
| **jungle_synthesizer/samgov-scraper** (13 users/30d, 1.0★, 32.9% fail as of 14 Nov 2026) | `keyword`, `naicsCodes`, `opportunityType`, `setAsideType`, `postedFrom`, `postedTo`, `activeOnly`, `agency`, `state`, `maxItems` |

Monitor webhooks, attachment file downloads, and jungle_synthesizer’s exclusions / wage / assistance `dataType` values are accepted so saved inputs still validate, and **ignored**. This Actor does not download files or store the `sp_contact` field.

Without a SAM key, the no-key path is a feature, not a failure: `RUN_SUMMARY.sam.skipped` is `true` and award rows are still delivered.

```json
{
  "keywords": ["cybersecurity"],
  "naicsCodes": ["541512"],
  "maxItems": 50,
  "includeAwards": true
}
```

With a free SAM.gov key (Account Details on SAM.gov):

```json
{
  "keyword": "janitorial",
  "naicsCodes": ["561720"],
  "setAsideType": "SBA",
  "postedWithinDays": 30,
  "maxItems": 50,
  "samApiKey": "YOUR_SAM_PUBLIC_API_KEY"
}
```

### Built for AI agents

Rows are flat JSON with stable field names, ISO dates, numeric `value`, and nested `awards` / `incumbents` already joined — no HTML to parse and no personal contacts to filter later. A hard `maxItems` cap is reserved before charge, so a tool-calling agent cannot overrun a budget. Error rows are free and machine-readable (`errorCode`). `RUN_SUMMARY` says whether SAM was skipped for lack of a key. The Actor is pay-per-record, has no start fee beyond Apify’s $0.00005 platform event, and does not escalate to paid residential proxies.

### How it works

- **USAspending.gov** (always, when `includeAwards` is on): official `/api/v2/search/spending_by_award` plus award detail for NAICS, PSC, set-aside and solicitation id. No API key.
- **SAM.gov** (optional): official Opportunities v2 search. **You supply your own free public API key** as the secret input `samApiKey`. If the key is missing or rejected, the Actor logs that clearly and falls back to awards.
- Matched awards are attached to each opportunity by solicitation number when possible, otherwise by NAICS and agency.
- A hard **`maxItems`** cap is reserved across the run. The Actor also stops about 60 seconds before the run timeout and keeps the records it already has.
- Apify Proxy uses datacenter / AUTO only. Official APIs do not need residential IPs, and we will not switch to them.

### Input

| Field | Notes |
|---|---|
| `keywords` | One or more search phrases. `keyword`, `keywordList`, `query` and `q` also work. |
| `naicsCodes` / `pscCodes` | Industry and product/service codes. |
| `agencies` / `states` | Awarding agency name, place-of-performance state. |
| `setAsideTypes` / `opportunityTypes` | SAM filters when a key is set. |
| `postedFrom` / `postedTo` / `postedWithinDays` | Dates: `YYYY-MM-DD`, `today`, or `7 days`. Default window is 365 days. |
| `maxItems` | Hard run cap. Default 100. `maxOpportunities` and `limit` also work. |
| `samApiKey` | Secret. Free key from SAM.gov Account Details. Leave empty for the awards-only path. |
| `includeAwards` | Default true. Required (default) when no SAM key is set. |
| `maxAwardsPerNotice` | Cap on nested awards per opportunity. Default 5. |

### Pricing

**$3.00 per 1,000 records** on the Free plan (PPE `$0.003` per delivered opportunity or award row). Nested awards on an opportunity row are not billed separately. Higher Apify plan tiers pay less. The platform start event is $0.00005. Error rows are never charged.

### Limits and honesty

- Live **opportunities** require a free SAM.gov public API key that you create in your own account. We cannot invent one for you, and we never log or store it in the dataset.
- SAM’s official API allows at most a **one-year** posted-date window per request; longer ranges are split automatically.
- “Incumbent” is a best-effort match from public USAspending awards (solicitation number, then NAICS + agency). It is not a legal determination of the current contractor.
- USAspending list search often omits NAICS/PSC; we fetch the official award detail to fill them. If a detail call fails, the list row is still delivered.
- This Actor only uses **public official APIs**. It does not collect personal contacts.

### Example output (award, no-key path)

```json
{
  "status": "ok",
  "recordType": "award",
  "source": "usaspending",
  "title": "Enterprise IT-related services and technical solutions that span cybersecurity and IT management.",
  "agency": "General Services Administration",
  "subAgency": "Federal Acquisition Service",
  "naics": [{ "code": "541512", "description": "Computer Systems Design Services" }],
  "psc": [{ "code": "D318", "description": "IT SOLUTIONS" }],
  "setAside": null,
  "solicitationNumber": "47QFCA20R0015",
  "piid": "47QFCA20F0049",
  "value": 396604521.78,
  "currency": "USD",
  "startDate": "2020-09-25",
  "endDate": "2025-10-24",
  "recipientName": "GENERAL DYNAMICS INFORMATION TECHNOLOGY, INC.",
  "incumbents": ["GENERAL DYNAMICS INFORMATION TECHNOLOGY, INC.", "GENERAL DYNAMICS CORP"],
  "awardUrl": "https://www.usaspending.gov/award/CONT_AWD_47QFCA20F0049_4732_47QTCK18D0003_4732",
  "placeOfPerformance": { "city": "DORAL", "state": "FL", "country": "UNITED STATES", "zip": null },
  "scrapedAt": "2026-11-14T00:00:00.000Z"
}
```

### More from ScrapeMole

ScrapeMole builds focused, reliable scrapers for public data: pay per result, no start fees, clear error rows that are never charged, and a `RUN_SUMMARY` on every run.

- [YouTube Transcript Scraper](https://apify.com/scrapemole/youtube-transcript-scraper)
- [Google Trends Scraper](https://apify.com/scrapemole/google-trends-scraper)
- [YouTube Scraper](https://apify.com/scrapemole/youtube-video-channel-scraper)
- [YouTube Comments Scraper](https://apify.com/scrapemole/youtube-comments-scraper)
- [Telegram Channel Scraper](https://apify.com/scrapemole/telegram-channel-scraper)
- [Amazon Product & Search Scraper](https://apify.com/scrapemole/amazon-product-scraper)
- [Google Jobs Scraper](https://apify.com/scrapemole/google-jobs-scraper)
- [YouTube Shorts Scraper](https://apify.com/scrapemole/youtube-shorts-scraper)
- [YouTube Channel Scraper](https://apify.com/scrapemole/youtube-channel-scraper)
- [ATS Jobs & Hiring-Intent Scraper: Greenhouse, Lever, Ashby](https://apify.com/scrapemole/ats-jobs-scraper)
- [Google Play & App Store Reviews Scraper](https://apify.com/scrapemole/app-reviews-scraper)

Building an AI agent with its own wallet? The YouTube and Google Trends data is also sold per call over [x402](https://www.x402.org) (USDC on Base, no account): see [scrapemole.pages.dev](https://scrapemole.pages.dev) or [all ScrapeMole scrapers](https://scrapemole.pages.dev/scrapers/). Questions or a missing field? Open an issue on this Actor. ScrapeMole is the maker of this Actor.

# Actor input Schema

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

Search terms for contract descriptions and titles, e.g. cybersecurity or janitorial. Each item is its own search, then results are merged. A single string, keyword, query, q or a newline-separated Keywords box also work.

## `keyword` (type: `string`):

Single search term. Accepted so jungle_synthesizer inputs run unchanged.

## `keywordList` (type: `array`):

Bulk keyword array. Accepted so fortuitous_pirate inputs run unchanged.

## `keywordMode` (type: `string`):

ANY (default) = any word, ALL = every word, EXACT = the exact phrase. Used when searching USAspending and as the SAM title query.

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

Industry codes, e.g. 541511 (programming), 541512 (systems design), 561720 (janitorial). Prefixes are kept as entered. naics also works.

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

Product or Service Codes, e.g. DA10, D318, R425. psc also works.

## `setAsideTypes` (type: `array`):

Opportunity set-aside codes: SBA, 8A, HZC, SDVOSBC, WOSB, EDWOSB, and the other SAM.gov codes. setAsideType (single value) also works. Applied on SAM when a key is set; kept on award details when USAspending publishes them.

## `opportunityTypes` (type: `array`):

SAM notice types: o (Solicitation), k (Combined Synopsis/Solicitation), p (Presolicitation), r (Sources Sought), s (Special Notice), a (Award Notice), u (Justification), g (Sale of Surplus), i (Intent to Bundle). opportunityType also works. Only used on the SAM path.

## `agencies` (type: `array`):

Awarding department or agency names, e.g. Department of Veterans Affairs or GSA. agency (single string) also works.

## `states` (type: `array`):

Two-letter state codes (CA, TX, VA, DC). state also works.

## `solicitationNumbers` (type: `array`):

Look up specific solicitations (e.g. N4008426R1026). On the SAM path this uses solnum; on the awards path it is used as a keyword / solicitation identifier.

## `noticeIds` (type: `array`):

32-character SAM notice IDs or https://sam.gov/opp/<id>/view URLs. Requires a SAM API key.

## `postedWithinDays` (type: `integer`):

Only records posted or updated in this many days. Ignored when Posted From is set. For the no-key awards path this bounds the USAspending time window.

## `postedFrom` (type: `string`):

YYYY-MM-DD, today, or a relative span such as 7 days (ago). Overrides Posted within.

## `postedTo` (type: `string`):

YYYY-MM-DD, today, or a relative span such as 2 days.

## `activeOnly` (type: `boolean`):

On the SAM path: only open opportunities. On the awards path: only awards whose period of performance has not ended.

## `status` (type: `string`):

active, inactive or all. Overrides Active only when set. Accepted so fortuitous_pirate inputs run unchanged.

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

Hard cap for the whole run. The Actor stops when this many rows have been delivered. maxOpportunities, limit and count also work.

## `includeAwards` (type: `boolean`):

On (default): attach matched past awards and incumbent company names to each opportunity, or — when no SAM API key is set — deliver award rows directly from USAspending.gov (no key required).

## `maxAwardsPerNotice` (type: `integer`):

When joining awards onto a SAM notice, keep at most this many past awards. Default 5.

## `samApiKey` (type: `string`):

Your own free public API key from Account Details on SAM.gov. Required only for live opportunities. If this is empty, the Actor skips SAM, says so in the log and RUN_SUMMARY, and still returns USAspending award rows when Include awards is on. Never logged or written to the dataset. apiKey and api_key also work.

## `maxConcurrency` (type: `integer`):

How many USAspending award-detail requests to run at once.

## `maxRetries` (type: `integer`):

Retries for timeouts and HTTP errors.

## `proxyConfiguration` (type: `object`):

Apify Proxy (datacenter / automatic) is on by default. Official USAspending and SAM APIs do not need residential IPs; this Actor will not switch to them.

## `maxOpportunities` (type: `integer`):

Alias of Max records. Accepted so fortuitous_pirate inputs run unchanged.

## `setAsideType` (type: `string`):

Single set-aside code. Accepted so jungle_synthesizer inputs run unchanged.

## `opportunityType` (type: `string`):

Single notice type. Accepted so jungle_synthesizer inputs run unchanged.

## `agency` (type: `string`):

Single agency name. Accepted so jungle_synthesizer inputs run unchanged.

## `state` (type: `string`):

Single state code. Accepted so jungle_synthesizer inputs run unchanged.

## `naics` (type: `array`):

Alias of NAICS codes.

## `limit` (type: `integer`):

Alias of Max records.

## `apiKey` (type: `string`):

Alias of SAM.gov API key. Stored as a secret; never logged.

## `api_key` (type: `string`):

Alias of SAM.gov API key. Stored as a secret; never logged.

## `includeAttachments` (type: `boolean`):

Accepted for compatibility. Public attachment URLs from SAM are listed when true; files are never downloaded, and this Actor never charges extra for them.

## `includeAttachmentUrls` (type: `boolean`):

List public SAM attachment URLs on opportunity rows. Default off, for slimmer LLM-ready output. Files are never downloaded.

## `downloadAttachments` (type: `boolean`):

Accepted so saved rival inputs validate. This Actor does not download files.

## `fetchDetails` (type: `boolean`):

Accepted for compatibility. Official APIs already return the structured fields we publish (minus personal contacts).

## `includeDescription` (type: `boolean`):

On (default): include the public description with emails and phone numbers redacted. Off: leave the description empty.

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

Accepted for compatibility. Awards are returned by amount (highest first); SAM uses the official API order.

## `dataType` (type: `string`):

Accepted so jungle_synthesizer inputs validate. Only opportunities (joined with awards) are supported; exclusions, wage determinations and assistance listings are ignored.

## `sp_intended_usage` (type: `string`):

Accepted so jungle_synthesizer inputs validate. Not stored or used.

## `sp_improvement_suggestions` (type: `string`):

Accepted so jungle_synthesizer inputs validate. Not stored or used.

## `sp_contact` (type: `string`):

Accepted so jungle_synthesizer inputs validate. Not stored or used.

## `onlyNew` (type: `boolean`):

Accepted so fortuitous_pirate inputs validate. Monitor state is not implemented in this version.

## `monitorId` (type: `string`):

Accepted so fortuitous_pirate inputs validate.

## `firstRunMode` (type: `string`):

Accepted so fortuitous_pirate inputs validate.

## `webhookUrl` (type: `string`):

Accepted so fortuitous_pirate inputs validate. This Actor does not POST to webhooks.

## Actor input object example

```json
{
  "keywords": [
    "cybersecurity"
  ],
  "keywordMode": "ANY",
  "postedWithinDays": 365,
  "activeOnly": true,
  "maxItems": 100,
  "includeAwards": true,
  "maxAwardsPerNotice": 5,
  "maxConcurrency": 2,
  "maxRetries": 5,
  "proxyConfiguration": {
    "useApifyProxy": true
  },
  "includeAttachmentUrls": false,
  "includeDescription": true
}
```

# Actor output Schema

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

All dataset rows (status ok or error).

## `runSummary` (type: `string`):

JSON summary: processed/ok/failed counts, SAM skipped or used, events charged, HTTP stats.

# 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"
    ],
    "maxItems": 100,
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapemole/us-gov-contracts-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 = {
    "keywords": ["cybersecurity"],
    "maxItems": 100,
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("scrapemole/us-gov-contracts-scraper").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"
  ],
  "maxItems": 100,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call scrapemole/us-gov-contracts-scraper --silent --output-dataset

```

## MCP server setup

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

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/HsIRPOs5BgkxkAgt3/builds/WQ9jQNoIMsKhRNuEo/openapi.json
