# SAM.gov Contract Opportunities Watch (`socosupply/sam-opportunities-watch`) Actor

Scheduled monitor for US federal contract opportunities on SAM.gov. Returns only opportunities that are new or changed since your last run, filtered to your NAICS, keywords, and set-aside criteria.

- **URL**: https://apify.com/socosupply/sam-opportunities-watch.md
- **Developed by:** [Soco Supply](https://apify.com/socosupply) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 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.

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 Watch

A scheduled Apify Actor for **small government contractors** who want a **cheap daily feed** of federal contract opportunities filtered to their niche (NAICS, PSC, keywords, set-aside, state). Each run returns only opportunities that are **new or changed** since the previous run. State is kept in a named key-value store (`sam-opportunities-watch-state`).

### Who it is for

- Small businesses watching one or a few NAICS codes
- Teams that do not want to re-read thousands of SAM.gov rows every morning
- Integrations that need structured JSON with stable `noticeId` keys and change detection

### Input example

```json
{
  "dataSource": "search",
  "naicsCodes": ["541511"],
  "keywords": ["cloud", "DevSecOps"],
  "setAsideTypes": ["SBA"],
  "placeOfPerformanceStates": ["CA", "VA"],
  "postedFrom": 3,
  "responseDeadlineWithinDays": 30,
  "maxResults": 50,
  "emitAll": false,
  "apiKey": ""
}
```

**Recommended:** request a free [SAM.gov API key](https://api.sam.gov/) and set `apiKey` in input — the official **Get Opportunities Public API v2** is the most reliable source.

With `dataSource: "auto"`, the actor uses API v2 when `apiKey` is set, otherwise the **Contract Opportunities file extract** when Data Services is healthy, otherwise the public search + detail fallback (rate-limited: 2 concurrent detail requests, ≥300 ms between details, descriptive User-Agent). `maxResults` only marks opportunities as seen after they are emitted.

### Output example

One record from local testing (fields only; no contact data):

```json
{
  "noticeId": "506e7a2712a94719a180fe94689d4f02",
  "title": "N6852027R1003: Naval Air Systems Command (NAVAIR) Depot Maintenance System (NDMS) IT Program/Project Functional Requirements and Software Lifecycle Support (ITPSS) Request for Proposal (RFP)",
  "solicitationNumber": "N6852027R1003",
  "department": "DEPT OF DEFENSE",
  "subTier": "DEPT OF THE NAVY",
  "office": "",
  "postedDate": "2026-10-07T20:14:45.680+00:00",
  "responseDeadline": "2026-11-09T14:00:00-05:00",
  "type": "Special Notice",
  "baseType": "s",
  "setAside": "",
  "naicsCode": "541511",
  "classificationCode": "",
  "placeOfPerformance": { "city": "", "state": "", "country": "" },
  "active": true,
  "award": { "amount": null, "date": null, "awardeeName": null },
  "uiLink": "https://sam.gov/opp/506e7a2712a94719a180fe94689d4f02/view",
  "changeType": "new"
}
```

Point-of-contact names, emails, and phone numbers are **never** included in output.

### Pricing

**$4.00 per 1,000 opportunities** returned, plus **$0.003 per run**. Platform usage is included. You pay only for rows the Actor delivers after your filters and change detection, not for the full SAM.gov catalog.

### Sample run vs. monitoring

The example input in Console returns up to 10 current matching records so you can see the output right away ("Emit all matches" on, max results 10). For a scheduled monitor, turn "Emit all matches" off and clear the max-results limit: each run then returns only records that are new or changed since the previous run, so you pay only for what's new.

### Schedule daily

In Apify Console: open the task → **Schedule** → e.g. `0 7 * * *` (7:00 AM UTC) or your timezone. Use the same input each time; the key-value store remembers prior snapshots. For a full refresh, set `emitAll: true` once or clear the `sam-opportunities-watch-state` store.

Local cron example:

```bash
0 7 * * * cd /path/to/sam-opportunities-watch && APIFY_LOCAL_STORAGE_DIR=./storage node src/main.js
```

### Data source attribution

Opportunity data comes from **SAM.gov** (U.S. General Services Administration / IAE):

- [SAM.gov Data Services — Contract Opportunities](https://sam.gov/data-services/Contract%20Opportunities)
- [Get Opportunities Public API](https://open.gsa.gov/api/get-opportunities-public-api/)
- [SAM.gov terms of use](https://sam.gov/about/terms-of-use)

Use consistent with federal open-data terms; verify current SAM.gov policies before production use.

### Local run

```bash
npm install
APIFY_LOCAL_STORAGE_DIR=./storage node src/main.js
```

Place input in `storage/key_value_stores/default/INPUT.json` or use `npx apify-cli run -p` from this directory.

# Actor input Schema

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

Your free api.sam.gov public API key. When set, the actor uses the official Get Opportunities Public API v2. When empty, it uses SAM.gov public search and opportunity detail endpoints (no key). File extract is tried first when dataSource is auto or extract.

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

auto = try Contract Opportunities file extract, then API key path, then public SAM.gov search. extract = file extract only. api = Get Opportunities API v2 (requires apiKey). search = SAM.gov public search API (no key).

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

Include opportunities with these NAICS codes (up to 6 digits). Empty = any NAICS.

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

Product Service Code (classificationCode) filter. Empty = any PSC.

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

Match if any keyword appears in the title or description (case-insensitive).

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

Set-aside codes or labels (e.g. SBA, 8A, SDVOSBC). Case-insensitive partial match. Empty = any.

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

Notice type codes from SAM.gov (e.g. o= Solicitation, p= Presolicitation, a= Award, r= Sources Sought, s= Special Notice). Empty = any.

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

Two-letter US state codes where work is performed. Empty = any.

## `postedFrom` (type: `integer`):

Only include opportunities posted within this many days of today (UTC).

## `responseDeadlineWithinDays` (type: `integer`):

If set (>0), only include opportunities whose response deadline is between now and this many days ahead. 0 = no deadline window filter.

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

Stop after pushing this many opportunity records (0 = unlimited).

## `emitAll` (type: `boolean`):

If true, push every opportunity matching filters (changeType will be new, updated, or unchanged). If false, only new or updated since the last run. The example input turns this on so a first run shows a sample; turn it off for scheduled monitoring.

## Actor input object example

```json
{
  "dataSource": "auto",
  "naicsCodes": [
    "541511"
  ],
  "pscCodes": [],
  "keywords": [],
  "setAsideTypes": [],
  "noticeTypes": [],
  "placeOfPerformanceStates": [],
  "postedFrom": 3,
  "responseDeadlineWithinDays": 0,
  "maxResults": 10,
  "emitAll": true
}
```

# Actor output Schema

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

New or updated SAM.gov contract opportunities from this run (default dataset).

# 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 = {
    "apiKey": "",
    "dataSource": "auto",
    "naicsCodes": [
        "541511"
    ],
    "pscCodes": [],
    "keywords": [],
    "setAsideTypes": [],
    "noticeTypes": [],
    "placeOfPerformanceStates": [],
    "postedFrom": 3,
    "responseDeadlineWithinDays": 0,
    "maxResults": 10,
    "emitAll": true
};

// Run the Actor and wait for it to finish
const run = await client.actor("socosupply/sam-opportunities-watch").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 = {
    "apiKey": "",
    "dataSource": "auto",
    "naicsCodes": ["541511"],
    "pscCodes": [],
    "keywords": [],
    "setAsideTypes": [],
    "noticeTypes": [],
    "placeOfPerformanceStates": [],
    "postedFrom": 3,
    "responseDeadlineWithinDays": 0,
    "maxResults": 10,
    "emitAll": True,
}

# Run the Actor and wait for it to finish
run = client.actor("socosupply/sam-opportunities-watch").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 '{
  "apiKey": "",
  "dataSource": "auto",
  "naicsCodes": [
    "541511"
  ],
  "pscCodes": [],
  "keywords": [],
  "setAsideTypes": [],
  "noticeTypes": [],
  "placeOfPerformanceStates": [],
  "postedFrom": 3,
  "responseDeadlineWithinDays": 0,
  "maxResults": 10,
  "emitAll": true
}' |
apify call socosupply/sam-opportunities-watch --silent --output-dataset

```

## MCP server setup

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

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/cuVhCtclByuvtAy7m/builds/jQLWMQ0AfcOvDPehM/openapi.json
