# SAM.gov Contract Opportunities + Likely Incumbent (USAspending) (`second_byte_surplus_llc/sam-gov-opportunities-incumbents`) Actor

Open SAM.gov federal contract opportunities from the official daily public extract (no key, no proxy), each matched to the likely incumbent contractor, award value and end date via USAspending.gov. Filters: state, NAICS, PSC, set-aside, deadline; only-new alerts.

- **URL**: https://apify.com/second_byte_surplus_llc/sam-gov-opportunities-incumbents.md
- **Developed by:** [Second Byte Surplus](https://apify.com/second_byte_surplus_llc) (community)
- **Categories:** Lead generation, Business
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 notice returneds

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 + Likely Incumbent (USAspending)

Open federal contract opportunities from **SAM.gov's official daily public extract**,
each matched to the **contractor that most likely holds the work today**: their name,
UEI, current award value, end date and USAspending link. You get the bid and the
incumbent you'd be competing against in one row.

- **No SAM.gov key, no login, no proxy.** The Actor downloads SAM.gov's official public
  "Contract Opportunities" daily file from SAM.gov Data Services. It doesn't scrape the website.
- **Incumbent lookup** on USAspending.gov (public Treasury data, no key). The SAM.gov
  opportunity scrapers we checked don't offer this.
- Flat, CRM-ready columns: primary/secondary contact name, email and phone, deadline and
  days left, set-aside, NAICS, PSC, place of performance and award details.
- **Only new or updated** mode for daily alerts. A notice is reported again if its deadline,
  type, award or set-aside changes.

### Who it's for

- Small businesses (8(a), HUBZone, SDVOSB, WOSB) deciding bid/no-bid. Who's the incumbent, how big is the
  current contract, and when does it end?
- Capture/BD teams and consultants who need to see who they're up against.
- Subcontractors looking for primes. The incumbent is a teaming target.

### How the incumbent is found

For solicitations, presolicitations, sources sought and special notices:

1. **same_office**: prior contract awards whose award ID (PIID) starts with the notice's
   contracting-office code (AAC), in the same NAICS. Under the uniform PIID format the first 6
   characters are the issuing office.
2. **same_agency_naics_state**: if there's no office match, prior awards from the same agency in the
   same 4-6 digit NAICS and the same place-of-performance state.

Candidates are ranked by exact PSC match, then by how close the award end date is to today.
Up to 3 candidates are returned. `incumbent_confidence`:

- `high`: same office and the same PSC
- `medium`: same office only, or agency/state with the same PSC
- `low`: agency, state and NAICS only

**This is a lead, not proof.** Large buying offices (Army TACOM, DLA) buy many items under one
NAICS. For construction (PSC Y/Z) the "incumbent" is usually the firm that won similar recent
work from that office, so read it as competitor intel, not a re-bid. Always check the
USAspending link.

### Output (one row per notice)

`notice_id, title, solicitation_number, notice_type, base_type, department, subtier, office,
office_aac, posted_date, response_deadline, days_until_deadline, archive_date, set_aside_code,
set_aside, naics, psc, pop_street, pop_city, pop_state, pop_zip, pop_country, active,
award_number, award_date, award_amount, awardee, primary_contact_name/title/email/phone,
secondary_contact_name/email/phone, office_city/state/zip, additional_info_link, sam_url, [description], source, incumbent_match, incumbent_confidence, likely_incumbent,
likely_incumbent_uei, likely_incumbent_award_id, likely_incumbent_amount,
likely_incumbent_end_date, likely_incumbent_url, incumbent_candidates[], [change_type]`

### Input

`states`, `naicsCodes` (prefix), `pscCodes` (prefix), `setAsideCodes`, `noticeTypes`,
`keywords`, `postedWithinDays`, `minDaysToDeadline` / `maxDaysToDeadline`, `excludeClosed`,
`enrichIncumbents`, `maxIncumbentLookups`, `includeDescription`, `onlyNewOrUpdated`, `maxResults`.
Advanced: `dataSource` = `api` with your own `samApiKey` (stored as a secret input).

### Freshness and limits

- The extract holds **all active notices** (73,887 on 2026-11-20) and SAM.gov regenerates it
  daily. The file was last modified 2026-11-19 11:30 PM ET. Notices posted after that appear in the next run.
  Archived/inactive notices aren't in it.
- Each run downloads about 230 MB and scans every row in a few seconds. Peak memory on a full scan was about 450 MB.
- USAspending: one request per unique (office, NAICS) pair, cached within the run, about 0.6 s apart.

### Pricing

Pay per event:

- `result`: $0.003 per notice
- `incumbent-found`: $0.007, charged only when an incumbent candidate is found

### Data and terms

SAM.gov says most of its material is public domain and may be copied or redistributed
(sam.gov/about/terms-of-use). USAspending.gov is public U.S. Treasury data with a keyless API.
Not affiliated with GSA, Treasury or any agency.

### Local development

```bash
python -m venv .venv && .venv/bin/pip install -r requirements.txt pytest
.venv/bin/python -m pytest -q tests            # offline tests (real fixtures)
bash scripts/smoke_test.sh                    # live: download extract, enrich, only-new
.venv/bin/python scripts/run_local.py --input in.json --out-prefix sample_output
.venv/bin/python -m src                       # via Apify SDK (input in storage/key_value_stores/default/INPUT.json)
```

# Actor input Schema

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

Two-letter codes, e.g. \["MI", "OH"]. Empty = all.

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

Prefix match: '5617' matches 561720 and 561730.

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

Prefix match, e.g. 'S2' for housekeeping services.

## `setAsideCodes` (type: `array`):

SBA, SBP, 8A, 8AN, HZC, HZS, SDVOSBC, SDVOSBS, WOSB, WOSBSS, EDWOSB, EDWOSBSS, VSA, VSS, ISBEE, IEE, BICiv. Empty = all (including none).

## `noticeTypes` (type: `array`):

Exact SAM.gov labels: Solicitation, Combined Synopsis/Solicitation, Presolicitation, Sources Sought, Special Notice, Award Notice, Justification. Empty = all.

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

Any keyword in title or description (case-insensitive).

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

Empty = any posting date.

## `minDaysToDeadline` (type: `integer`):

e.g. 7 to skip bids you can't make in time.

## `maxDaysToDeadline` (type: `integer`):

Only notices due within this many days.

## `excludeClosed` (type: `boolean`):

Drop notices whose response deadline is already past.

## `enrichIncumbents` (type: `boolean`):

For solicitations, presolicitations, sources sought and special notices: look up prior awards from the same contracting office/NAICS on USAspending.gov.

## `maxIncumbentLookups` (type: `integer`):

Cap on notices sent to USAspending for incumbent lookup.

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

Include the notice description text (long).

## `descriptionMaxChars` (type: `integer`):

Truncate descriptions to this many characters.

## `onlyNewOrUpdated` (type: `boolean`):

Remembers notice IDs plus deadline/type/award in a named key-value store; use with a daily schedule.

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

Cost cap. 0 = no cap.

## `dataSource` (type: `string`):

The extract is SAM.gov's official daily file of all active notices. Use the API only if you need it and have a key.

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

Your personal public API key from SAM.gov Account Details. Non-federal users with no SAM.gov role get 10 requests/day.

## `maxApiRequests` (type: `integer`):

API mode only: max SAM.gov API calls per run (personal keys allow 10/day without a role).

## Actor input object example

```json
{
  "states": [
    "MI"
  ],
  "noticeTypes": [
    "Solicitation",
    "Combined Synopsis/Solicitation",
    "Presolicitation",
    "Sources Sought"
  ],
  "excludeClosed": true,
  "enrichIncumbents": true,
  "maxIncumbentLookups": 100,
  "includeDescription": false,
  "descriptionMaxChars": 4000,
  "onlyNewOrUpdated": false,
  "maxResults": 500,
  "dataSource": "bulkExtract",
  "maxApiRequests": 5
}
```

# Actor output Schema

## `overview` (type: `string`):

All records in the default dataset, Overview view.

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

RUN_SUMMARY record: counts per county/type, errors.

# 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 = {
    "states": [
        "MI"
    ],
    "noticeTypes": [
        "Solicitation",
        "Combined Synopsis/Solicitation",
        "Presolicitation",
        "Sources Sought"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("second_byte_surplus_llc/sam-gov-opportunities-incumbents").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 = {
    "states": ["MI"],
    "noticeTypes": [
        "Solicitation",
        "Combined Synopsis/Solicitation",
        "Presolicitation",
        "Sources Sought",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("second_byte_surplus_llc/sam-gov-opportunities-incumbents").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 '{
  "states": [
    "MI"
  ],
  "noticeTypes": [
    "Solicitation",
    "Combined Synopsis/Solicitation",
    "Presolicitation",
    "Sources Sought"
  ]
}' |
apify call second_byte_surplus_llc/sam-gov-opportunities-incumbents --silent --output-dataset

```

## MCP server setup

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

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/h8D3rRYcShbi3KZUv/builds/tw3V220MjGLNiYUTj/openapi.json
