# Federal Contract Opportunities + Incumbent Intel (`cherry_hippopotamus/federal-contract-opportunities`) Actor

New and recently posted U.S. federal contract opportunities from the official public SAM.gov extract, optionally joined to the last related USAspending award. No contact PII. No API key required.

- **URL**: https://apify.com/cherry_hippopotamus/federal-contract-opportunities.md
- **Developed by:** [Carson Packard](https://apify.com/cherry_hippopotamus) (community)
- **Categories:** Lead generation, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.50 / 1,000 opportunities

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

## Federal Contract Opportunities + Incumbent Intel

> **Status:** listed on the Apify Store as [Federal Contract Opportunities + Incumbent Intel](https://apify.com/cherry_hippopotamus/federal-contract-opportunities). Pay-per-event pricing below is live.
> This Actor sends anonymous error and usage stats, including the run's input settings (filters, mode, limits) for debugging. No personal or scraped data is included. The secret `samApiKey` is never sent. URLs are sent without query strings; emails, phone numbers, and secrets are masked. `disableTelemetry` turns this off.

Recently posted U.S. federal contract opportunities from the **official public SAM.gov Contract Opportunities extract** (no API key required), normalized into one schema. Optionally search the live Opportunities API with **your** SAM.gov key, and optionally attach the last related award from the public USAspending API (incumbent intel). Schedule it in **delta mode** to get only notices you have not seen before.

This is not a website scraper. Contact names, emails, phones, faxes, and street addresses from the extract are never written to the dataset.

### What you get

One row per notice: `notice_id`, `solicitation_number`, `title`, `notice_type`, `department`, `agency`, `office`, `naics`, `psc`, `set_aside`, `posted_date`, `response_deadline`, place-of-performance city/state, award fields when the notice is an award, a public `source_url`, a scrubbed `description`, `change_type` (`new` / `seen`), and optional `incumbent_*` fields. The frozen field list is in `SPEC.md`.

Diagnostic failures appear as `type=error` rows (`reason`, `store`) and are not billed. Besides source errors, two warning reasons exist: `zero_rows` (the source returned 0 notices where some were expected, for example after SAM.gov changes the extract format; never triggered by your own filters or by "nothing new" in delta mode) and `time_budget` (the run was close to its timeout, so it stopped reading or enriching early and kept what it had).

### Quick start (keyless)

```json
{
  "keywords": ["software"],
  "naicsCodes": ["5415"],
  "noticeTypes": ["solicitation", "combined", "sources_sought", "presolicitation"],
  "postedWithinDays": 7,
  "openForResponseOnly": true,
  "mode": "full",
  "maxItems": 25,
  "enrichIncumbent": false,
  "source": "extract"
}
```

That is also the Store prefill: it uses the official public extract, needs no API key, and is sized to finish in well under five minutes with a non-empty dataset.

Schedule daily with `"mode": "delta"` and a `stateStoreName` per task to get only new notices. Under Apify limited permissions, the Actor can create and reuse a named store for your account. If opening that store is forbidden (for example a store with the same name already exists outside this Actor's scope), the run still succeeds: it falls back to the run's default key-value store and records in the status and dataset that delta state was not persisted. Use a new `stateStoreName` so the Actor can create its own store.

### Example output

```json
{
  "notice_id": "abc123",
  "notice_key": "sam:abc123",
  "title": "Software development support",
  "notice_type": "solicitation",
  "department": "ENERGY, DEPARTMENT OF",
  "agency": "ENERGY, DEPARTMENT OF",
  "naics": "541511",
  "posted_date": "2026-11-18",
  "response_deadline": "2026-12-01",
  "pop_city": "Austin",
  "pop_state": "TX",
  "source_url": "https://sam.gov/workspace/contract/opp/abc123/view",
  "source": "extract",
  "change_type": "new",
  "enriched": false,
  "schema_version": "1.0"
}
```

### Optional: live API search

Set `"source": "api"` and paste a key from your SAM.gov Account Details page into `samApiKey`. The field is secret and is never written to the dataset, logs, or telemetry. Personal accounts are often limited to about 10 API requests per day; the keyless extract is the better default for daily backfills.

### Optional: incumbent intel

Set `"enrichIncumbent": true` to look up a recent related contract award on USAspending (no key). The `incumbent-intel` event is charged only when a record is actually attached.

### Pricing (pay per event)

Live Store prices. Apify bills the synthetic start event once per GB of run memory (minimum one event). The default run memory is 512 MB, so a typical run is charged one start event. Diagnostic error rows are not billed. The `incumbent-intel` event is charged only when a record is actually attached.

| Event | Price | When it is charged |
|---|---|---|
| Actor start (`apify-actor-start`) | $0.01 per start event | Synthetic platform event; not charged again from code |
| `opportunity` | $0.0025 ($2.50 / 1,000) | Each opportunity row emitted (`new` or `seen`) |
| `incumbent-intel` | $0.01 | Only when `enrichIncumbent` is on and an incumbent award is actually attached |

Set `maxItems` to cap a run. The Actor stops cleanly when the cap is reached, and unemitted new notices stay pending for the next run. `samApiKey` is a user-supplied secret for optional live API search; this Actor does not ship a shared key.

### How it fetches

- Default: stream the official public nightly CSV and stop after the date window (and `maxItems`). Typical prefill traffic is tens of megabytes, not the full ~214 MB file.
- Optional: Get Opportunities v2 with your key.
- Optional: USAspending `spending_by_award`, at most one polite request per candidate, 429 honored.
- If a source returns 403 or 429, the run does not try to bypass it. A 403 on one official Public extract URL may fall back to the other official Public URL for the same file.

### Data sources and terms

Official public SAM.gov Contract Opportunities extract and, optionally, the public Opportunities API and the public USAspending API. See `SOURCES.md`. Website scraping of sam.gov is prohibited and is not used. Do not use this Actor to collect restricted, CUI, or contact PII.

Most federal public-domain data is provided as-is. This project is not affiliated with GSA, SAM.gov, or USAspending.

### Development

```bash
python3 -m venv .venv && .venv/bin/pip install -r requirements-dev.txt
.venv/bin/python -m pytest -q
.venv/bin/python tools/live_smoke.py   # live, public extract, no key, no Apify
```

Pinned runtime deps: `apify==4.2.1`, `httpx==0.28.1`.

# Actor input Schema

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

Match if any keyword appears in the title, description, or solicitation number (case-insensitive). Leave empty to skip the keyword filter.

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

Match notices whose NAICS starts with any of these values (for example 5415 matches 541511).

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

Optional product/service classification prefixes.

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

Optional set-aside codes from the extract (for example SBA, 8A, SDVOSBC). Case-insensitive exact match on the code.

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

Two-letter US state or territory codes. Leave empty for all.

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

Match if any of these substrings appear in the department, sub-tier, or office name.

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

Limit to these notice types. Leave empty for all types in the extract.

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

Look back this many days from today (America/Denver). Ignored when dateFrom is set. Capped at 90.

## `dateFrom` (type: `string`):

Optional inclusive start date. The window cannot exceed 90 days.

## `dateTo` (type: `string`):

Optional inclusive end date. Defaults to today.

## `openForResponseOnly` (type: `boolean`):

When true, keep only notices that are still marked Active and have a response deadline today or later (or no deadline).

## `mode` (type: `string`):

delta returns only notices not seen in the named state store. full returns every match in the window (still records state so a later delta run can skip them).

## `source` (type: `string`):

extract (default) reads the official public SAM.gov Contract Opportunities full CSV — no API key. api calls the Get Opportunities v2 search and requires samApiKey. Personal SAM.gov accounts are typically limited to about 10 API requests per day.

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

Required only when source is api. Create a key on your SAM.gov Account Details page. This field is secret and is never written to the dataset, logs, or telemetry. Do not use a login-walled or non-public key to pull restricted data.

## `enrichIncumbent` (type: `boolean`):

When true, look up a recent related contract award on the public USAspending API (no key) and attach incumbent name, award id, and amount. The incumbent-intel event is charged only when a record is actually attached. Off in the Store prefill to keep the daily test short.

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

Hard cap on billable opportunity rows per run. The extract is streamed and stopped once this cap (and the date window) is satisfied — the Actor does not download the entire ~214 MB file on a typical run.

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

Apify key-value store used to remember notice ids between delta runs.

## `stateKey` (type: `string`):

Key inside the state store. Advanced; leave the default unless you run isolated snapshots.

## `disableTelemetry` (type: `boolean`):

Turn off anonymous PostHog usage events (status, sanitized input, error counts). The public ingest key cannot query or modify your data.

## Actor input object example

```json
{
  "keywords": [
    "software"
  ],
  "naicsCodes": [
    "5415"
  ],
  "noticeTypes": [
    "solicitation",
    "combined",
    "sources_sought",
    "presolicitation"
  ],
  "postedWithinDays": 7,
  "openForResponseOnly": true,
  "mode": "full",
  "source": "extract",
  "enrichIncumbent": false,
  "maxItems": 25,
  "stateStoreName": "federal-contract-opportunities-state",
  "stateKey": "snapshot",
  "disableTelemetry": false
}
```

# Actor output Schema

## `results` (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 = {
    "keywords": [
        "software"
    ],
    "naicsCodes": [
        "5415"
    ],
    "noticeTypes": [
        "solicitation",
        "combined",
        "sources_sought",
        "presolicitation"
    ],
    "postedWithinDays": 7,
    "openForResponseOnly": true,
    "mode": "full",
    "source": "extract",
    "enrichIncumbent": false,
    "maxItems": 25
};

// Run the Actor and wait for it to finish
const run = await client.actor("cherry_hippopotamus/federal-contract-opportunities").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": ["software"],
    "naicsCodes": ["5415"],
    "noticeTypes": [
        "solicitation",
        "combined",
        "sources_sought",
        "presolicitation",
    ],
    "postedWithinDays": 7,
    "openForResponseOnly": True,
    "mode": "full",
    "source": "extract",
    "enrichIncumbent": False,
    "maxItems": 25,
}

# Run the Actor and wait for it to finish
run = client.actor("cherry_hippopotamus/federal-contract-opportunities").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": [
    "software"
  ],
  "naicsCodes": [
    "5415"
  ],
  "noticeTypes": [
    "solicitation",
    "combined",
    "sources_sought",
    "presolicitation"
  ],
  "postedWithinDays": 7,
  "openForResponseOnly": true,
  "mode": "full",
  "source": "extract",
  "enrichIncumbent": false,
  "maxItems": 25
}' |
apify call cherry_hippopotamus/federal-contract-opportunities --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,cherry_hippopotamus/federal-contract-opportunities"
        }
    }
}
```

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/ZUudSwYnaDxu3JGy4/builds/thdJuWwrxx8127fQE/openapi.json
