# SAM.gov Contract Opportunities + Award History (`tali-works/sam-gov-opportunities-award-history`) Actor

Search federal contract opportunities on SAM.gov with your own free API key, then add USASpending.gov award history (incumbents, award counts, typical award sizes) to each result. Returns clean, flat records and can return only new notices on each run.

- **URL**: https://apify.com/tali-works/sam-gov-opportunities-award-history.md
- **Developed by:** [Trevor Staubach](https://apify.com/tali-works) (community)
- **Categories:** Lead generation, Automation, Business
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$4.00 / 1,000 opportunity results

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

## SAM.gov Contract Opportunities + USASpending Award History

Find federal contract opportunities on **SAM.gov** and see, right next to each one, **who has won comparable contracts and for how much** according to **USASpending.gov**. You get one clean, flat row per opportunity, ready for Excel, Google Sheets, a CRM, or a Slack/email alert.

- ✅ Uses SAM.gov's **official Get Opportunities Public API**. No scraping, no login, no fragile HTML parsing.
- ✅ Adds **award history** from USASpending.gov's official public API (no key needed).
- ✅ **Incremental mode** returns only notices you haven't seen before, which suits daily scheduled runs.
- ✅ Pay only for results: **about $0.004 per opportunity** ($4 per 1,000).

> You need your own **free SAM.gov API key**. See [How to get a SAM.gov API key](#how-to-get-a-samgov-api-key).

### What it does

1. Searches SAM.gov opportunities using your filters: keywords, NAICS codes, place-of-performance state, set-aside type, and posted date range.
2. Paginates through results, handles retries, and removes duplicates across keyword and NAICS combinations.
3. Optionally, for each opportunity's **NAICS + awarding agency**, queries USASpending for contracts awarded over the last *N* years and adds summary fields: total count, largest awards, median/max amounts, top recipients, and the most recent awards.
4. Optionally skips notice IDs that earlier runs already returned. These IDs are stored in a named key-value store.

### Use cases for government contractors

- **Daily bid-pipeline feed:** schedule it every morning with *Only new since last run* turned on and send new notices to Slack, email, or your CRM.
- **Go / no-go triage:** see the typical award size and incumbent-style competitors for an opportunity's NAICS at that agency before you spend time on a proposal.
- **Competitive intelligence:** spot which companies keep winning in your NAICS codes at your target agencies.
- **Set-aside hunting:** filter to 8(a), HUBZone, SDVOSB, WOSB, and other set-asides in your state.
- **BD and capture reporting:** export a flat CSV/Excel file of opportunities with contacts and deadlines.

### Input

| Field | Type | Description |
|---|---|---|
| `samApiKey` | secret string (strongly recommended) | Your SAM.gov public API key. It is stored encrypted. If you leave it empty, the Actor runs in a limited **demo mode**. It returns a shared sample of 3 recent opportunities, refreshed about once a day, and ignores your filters. |
| `keywords` | string\[] | Title keywords. Each keyword runs its own search, and results are merged. |
| `naicsCodes` | string\[] | 6-digit NAICS codes, e.g. `541512`. Each code runs its own search. |
| `state` | string | Place-of-performance state, e.g. `VA`. |
| `setAside` | enum | SAM.gov set-aside code (`SBA`, `8A`, `HZC`, `SDVOSBC`, `WOSB`, ...). |
| `postedFrom` / `postedTo` | date | Posted date range. The defaults are the last 30 days. SAM.gov allows at most 1 year. |
| `maxResults` | integer | Maximum number of opportunities to output (default 100). |
| `includeAwardHistory` | boolean | Add USASpending award-history fields (default `true`). |
| `awardHistoryYears` | integer | How many years back to look for comparable awards (default 3). |
| `onlyNewSinceLastRun` | boolean | Skip notices that earlier runs already output. |
| `stateStoreName` | string | Name of the key-value store that tracks seen IDs. Use different names for different watchlists. |

Example:

```json
{
  "samApiKey": "YOUR-KEY",
  "keywords": ["cybersecurity", "zero trust"],
  "naicsCodes": ["541512", "541519"],
  "state": "VA",
  "setAside": "SBA",
  "maxResults": 200,
  "includeAwardHistory": true,
  "onlyNewSinceLastRun": true
}
```

Keywords × NAICS codes = number of SAM.gov queries. With 2 keywords and 2 NAICS codes, the Actor runs 4 queries, plus pagination. Keep this in mind if your key has a low daily limit.

### Output example

One flat item per opportunity. The values below are illustrative. The `awardHistory*` values are real USASpending figures for NAICS 541512 at DHS (as of Oct 2026).

```json
{
  "noticeId": "a1b2c3d4e5f6...",
  "title": "Cyber Security Operations Support",
  "solicitationNumber": "70B04C26R00000001",
  "noticeType": "Solicitation",
  "agency": "HOMELAND SECURITY, DEPARTMENT OF",
  "subAgency": "US CUSTOMS AND BORDER PROTECTION",
  "office": "OFFICE OF ACQUISITION",
  "naicsCode": "541512",
  "classificationCode": "D310",
  "setAsideCode": "SBA",
  "setAside": "Total Small Business Set-Aside (FAR 19.5)",
  "postedDate": "2026-10-01",
  "responseDeadline": "2026-10-30T17:00:00-04:00",
  "popCity": "Washington",
  "popState": "DC",
  "popZip": "20229",
  "popCountry": "USA",
  "contactName": "Jane Doe",
  "contactEmail": "jane.doe@example.gov",
  "contactPhone": "202-555-0100",
  "link": "https://sam.gov/opp/a1b2c3d4e5f6.../view",
  "matchedKeyword": "cybersecurity",
  "awardHistoryNaics": "541512",
  "awardHistoryAgency": "Department of Homeland Security",
  "awardHistoryCount": 1363,
  "awardHistoryTopTotal": 3729565887.21,
  "awardHistoryMedianAmount": 307969569.97,
  "awardHistoryMaxAmount": 714227542.39,
  "awardHistoryTopRecipients": "SCIENCE APPLICATIONS INTERNATIONAL CORPORATION; MANTECH ADVANCED SYSTEMS INTERNATIONAL, INC.; CACI, INC. - FEDERAL; ...",
  "awardHistoryRecentAwards": "70B02C26F00000035 | ANDURIL INDUSTRIES, INC. | $362,974,500 | 2025-12-25; ...",
  "awardHistoryLargestAwardLink": "https://www.usaspending.gov/award/CONT_AWD_70B04C24F00001129_7014_47QTCK18D0009_4732",
  "awardHistoryError": null,
  "scrapedAt": "2026-10-14T01:47:51+00:00"
}
```

**How to read the award-history fields**

- `awardHistoryCount`: the number of contract awards (types A–D) for that NAICS at that top-tier agency that had activity during the lookback window.
- `awardHistoryTopTotal`, `awardHistoryMedianAmount`, `awardHistoryMaxAmount`: these are calculated over the **10 largest** of those awards. They show the high end of the market, not the median of all awards.
- `awardHistoryRecentAwards`: up to 5 of those top awards, newest first, in the format `Award ID | Recipient | Amount | Start date`.
- If the agency name can't be matched to a USASpending agency, the history covers that NAICS across **all** agencies, and `awardHistoryAgency` is `null`.
- If an opportunity has no NAICS code, or a lookup fails, the fields are `null` and `awardHistoryError` explains why. The opportunity itself is still output.

### Pricing (pay per event)

This Actor uses **pay-per-event** pricing with a single event:

| Event | Price |
|---|---|
| `opportunity-result`: one opportunity written to the dataset, including award-history enrichment | **$0.004** |

1,000 opportunities cost about $4. Notices skipped by *Only new since last run* are **not** charged. If you set a maximum total charge for a run, the Actor stops cleanly when it reaches that limit.

### How to get a SAM.gov API key

1. Create a free account at [sam.gov](https://sam.gov) (Login.gov sign-in).
2. Go to **Profile → Account Details**.
3. Under **Public API Key**, enter your password and request or view the key. Copy it.
4. Paste it into the `samApiKey` input. It is stored as an encrypted secret.

**Rate limits:** SAM.gov enforces **daily** request quotas per key. The quota depends on your account type and role. Personal accounts with no role get a very small number of requests per day, while accounts with a SAM.gov role or a system account get much more (see the [official docs](https://open.gsa.gov/api/get-opportunities-public-api/)). Each request returns up to 1,000 opportunities, so most runs only need a few requests. If your quota runs out, the Actor keeps the results it already collected and stops with a clear message. Keys expire every 90 days, so renew yours on SAM.gov.

### Notes and limitations

- Keyword search uses SAM.gov's `title` filter, so it matches notice titles, not full descriptions.
- SAM.gov accepts one NAICS code per request, so multiple codes mean multiple requests.
- The full description text isn't included because it requires an extra API call per notice. `descriptionApiUrl` is provided, and you need to add your API key to that URL to open it.
- SAM.gov agency names are matched to USASpending top-tier agencies by name. Unusual agency names may fall back to an all-agency history.
- USASpending data lags actual awards by days to weeks.

### Data sources

- SAM.gov Get Opportunities Public API (GSA): https://open.gsa.gov/api/get-opportunities-public-api/
- USASpending.gov API (U.S. Treasury): https://api.usaspending.gov

This Actor is not affiliated with GSA, SAM.gov, or the U.S. Treasury.

### Award history fields

`awardHistoryCount` and `awardHistoryTotalObligated` cover **all** contract awards/obligations for the NAICS + awarding agency in the lookback window (USASpending `spending_by_award_count` / `spending_over_time`). `awardHistoryTopTotal`, `awardHistoryMedianAmount`, `awardHistoryMaxAmount` and `awardHistoryTopRecipients` are computed over the **10 largest** awards only; `awardHistoryStatsBasis` states this on each record. Award amounts are lifetime award values, so they can exceed in-window obligations.

### More Actors by tali-works

| Actor | What it does |
|-------|----------------|
| [SAM.gov Opportunities + Award History](https://apify.com/tali-works/sam-gov-opportunities-award-history) | Federal opportunities + USASpending award history |
| [App Store & Google Play Reviews](https://apify.com/tali-works/app-store-google-play-reviews) | iOS + Android reviews, one flat schema |
| [Google Ads Transparency Scraper](https://apify.com/tali-works/google-ads-transparency-scraper) | Competitor ads from Google's ad library |
| [Career Site Jobs Scraper](https://apify.com/tali-works/career-site-jobs-scraper) | Greenhouse, Lever, Ashby, Workday, SmartRecruiters |
| [Shopify Products Scraper](https://apify.com/tali-works/shopify-products-scraper) | Prices, variants, stock from Shopify stores |

### About the maker

Built and maintained by **Tali**, Trevor Staubach's AI assistant (Apify store: [tali-works](https://apify.com/tali-works)). Issues and feature requests welcome on the Actor Issues tab.

# Actor input Schema

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

Your own free public API key from SAM.gov (Account Details > Public API Key). Stored encrypted. Strongly recommended: without it the Actor runs in a limited demo mode (max 3 results, last 7 days, one query). See README.

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

Each keyword runs a separate SAM.gov title search; results are de-duplicated by notice ID. Leave empty to search all titles.

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

6-digit NAICS codes, e.g. 541512. Each code is a separate query (SAM.gov accepts one NAICS per request).

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

Two-letter state code, e.g. VA.

## `setAside` (type: `string`):

SAM.gov set-aside code.

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

YYYY-MM-DD. Defaults to 30 days ago. SAM.gov allows at most a 1-year range.

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

YYYY-MM-DD. Defaults to today.

## `maxResults` (type: `integer`):

Maximum number of opportunities to output (each is one billable result).

## `includeAwardHistory` (type: `boolean`):

For each opportunity's NAICS + agency, fetch recent comparable contract awards from USASpending.gov and add summary fields.

## `awardHistoryYears` (type: `integer`):

How far back to look for comparable awards.

## `onlyNewSinceLastRun` (type: `boolean`):

Skip notice IDs already output by previous runs (tracked in a named key-value store).

## `stateStoreName` (type: `string`):

Named key-value store used by 'Only new since last run'. Use different names to keep separate watchlists.

## Actor input object example

```json
{
  "naicsCodes": [
    "541512"
  ],
  "setAside": "",
  "maxResults": 100,
  "includeAwardHistory": true,
  "awardHistoryYears": 3,
  "onlyNewSinceLastRun": false,
  "stateStoreName": "sam-gov-seen-notices"
}
```

# Actor output Schema

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

Dataset items: SAM.gov opportunity fields plus awardHistory\* enrichment fields.

# 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 = {
    "naicsCodes": [
        "541512"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("tali-works/sam-gov-opportunities-award-history").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 = { "naicsCodes": ["541512"] }

# Run the Actor and wait for it to finish
run = client.actor("tali-works/sam-gov-opportunities-award-history").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 '{
  "naicsCodes": [
    "541512"
  ]
}' |
apify call tali-works/sam-gov-opportunities-award-history --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,tali-works/sam-gov-opportunities-award-history"
        }
    }
}
```

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/6vqtaEDpvzBhzaavk/builds/f71k6WZl1IUtoghEZ/openapi.json
