# SAM.gov Federal Contract & GovCon Opportunity Monitor (`mellowed_headpiece/sam-gov-opportunities-monitor`) Actor

Monitor SAM.gov federal contract opportunities, solicitations, sources sought, and awards. Search by NAICS code, set-aside type (8a, WOSB, SDVOSB, HUBZone), agency, and state. Built on the official api.sam.gov endpoint for government contractors, GovCon BD teams, and capture managers.

- **URL**: https://apify.com/mellowed\_headpiece/sam-gov-opportunities-monitor.md
- **Developed by:** [Trevor Smith](https://apify.com/mellowed_headpiece) (community)
- **Categories:** Lead generation, Automation, Developer tools
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## SAM.gov Contract Opportunities Monitor

Pulls U.S. federal contract opportunities from SAM.gov using the **official,
documented `api.sam.gov` endpoint** — not SAM.gov's internal frontend API.

### Why this exists

The two most-bookmarked SAM.gov actors on Apify Store currently sit at
1.0★ and 1.8★. The written reviews on the top one are literally *"not
existing"* and *"doesn't work."* Both appear to depend on undocumented
frontend endpoints that break whenever SAM.gov changes its site. This actor
is built entirely on the documented public API instead, so there's nothing
undocumented to break silently.

### Setup

1. Get a free API key: sign in at sam.gov → Workspace → Profile → Account
   Details → Public API Key.
2. Paste it into the **SAM.gov API key** input field (stored encrypted).
3. Set your filters (title keyword, NAICS codes, set-aside, state, date
   window) and run.

### Known platform limitations (stated up front, not discovered the hard way)

- **No full-text search.** SAM.gov's official API only searches the
  `title` field — there's no way to search the full opportunity
  description server-side. This is a platform limitation, not a bug here.
- **One NAICS code per request.** If you give multiple NAICS codes, this
  actor runs one request sequence per code and dedupes the results — it
  does not (and cannot) send them as a single comma-joined filter.
- **One set-aside type per request.** Same story — pick one per run, or
  run separate scheduled tasks for each.
- **Daily API request quota.** SAM.gov limits how many *requests* per day
  your key gets (varies by account type). Each request can return up to
  100+ records, so a single scheduled daily run with a focused NAICS/date
  filter comfortably fits in quota — this is meant to be scheduled daily,
  not polled continuously.
- **Date range required.** SAM.gov requires a bounded `postedFrom`/`postedTo`
  window (max ~1 year). This actor computes it for you from
  `postedFromDaysAgo`.

### Reliability behavior

- Retries transient errors (429, 5xx, timeouts) with exponential backoff.
- Treats an invalid/expired API key as a hard failure with an actionable
  message — never silently returns an empty dataset when the real cause is
  an auth problem.
- Logs a warning (not a silent drop) if SAM.gov ever returns a record that
  doesn't match a NAICS filter — defensive in case the filter parameter
  behavior changes upstream.

### Output fields

Each dataset item includes: `noticeId`, `title`, `solicitationNumber`,
`noticeType`, `active`, `postedDate`, `responseDeadline`, `department`,
`subTier`, `office`, `naicsCode`, `setAsideDescription`,
`placeOfPerformanceState/City/Zip`, `contactName/Email/Phone`,
`awardAmount/Date/AwardeeName` (for award notices), and a direct
`samGovUrl` link to view the notice on sam.gov.

# Actor input Schema

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

Free personal API key from sam.gov (Workspace > Profile > Account Details > Public API Key). Required — this Actor only uses the official documented api.sam.gov endpoint, never SAM.gov's internal frontend API, so it does not break when the website changes.
## `title` (type: `string`):

Searches ONLY the opportunity title field. SAM.gov's official API has no full-text/description search — this is an intentional platform limitation, not a bug in this Actor. Leave blank to pull all opportunities matching your other filters.
## `naicsCode` (type: `array`):

One or more NAICS codes, e.g. 541512 (Computer Systems Design). Leave empty for all industries.
## `procurementTypes` (type: `array`):

Filter to specific notice types. Leave empty for all types.
## `setAsideTypes` (type: `array`):

Filter to specific small-business set-aside categories. Leave empty for all (including full-and-open).
## `state` (type: `string`):

Two-letter US state code, e.g. VA. Leave blank for all states.
## `postedFromDaysAgo` (type: `integer`):

Pull opportunities posted from this many days ago through today. SAM.gov's API requires a bounded date range, so this Actor computes it for you. Keep this small (7 for daily monitoring) — the API has a low daily request cap, so wide date ranges waste quota fast.
## `activeOnly` (type: `boolean`):

If true, excludes opportunities whose response deadline has already passed.
## `maxItems` (type: `integer`):

Stops the run after this many opportunities. Each page pulls up to 100 records per request, so keep this reasonable relative to your daily API quota.

## Actor input object example

```json
{
  "title": "",
  "naicsCode": [],
  "procurementTypes": [],
  "setAsideTypes": [],
  "state": "",
  "postedFromDaysAgo": 7,
  "activeOnly": true,
  "maxItems": 200
}
````

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("mellowed_headpiece/sam-gov-opportunities-monitor").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("mellowed_headpiece/sam-gov-opportunities-monitor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call mellowed_headpiece/sam-gov-opportunities-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=mellowed_headpiece/sam-gov-opportunities-monitor",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "SAM.gov Federal Contract & GovCon Opportunity Monitor",
        "description": "Monitor SAM.gov federal contract opportunities, solicitations, sources sought, and awards. Search by NAICS code, set-aside type (8a, WOSB, SDVOSB, HUBZone), agency, and state. Built on the official api.sam.gov endpoint for government contractors, GovCon BD teams, and capture managers.",
        "version": "0.1",
        "x-build-id": "3g83OVkF0bslIAnGV"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/mellowed_headpiece~sam-gov-opportunities-monitor/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-mellowed_headpiece-sam-gov-opportunities-monitor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/mellowed_headpiece~sam-gov-opportunities-monitor/runs": {
            "post": {
                "operationId": "runs-sync-mellowed_headpiece-sam-gov-opportunities-monitor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/mellowed_headpiece~sam-gov-opportunities-monitor/run-sync": {
            "post": {
                "operationId": "run-sync-mellowed_headpiece-sam-gov-opportunities-monitor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "apiKey"
                ],
                "properties": {
                    "apiKey": {
                        "title": "SAM.gov API key",
                        "type": "string",
                        "description": "Free personal API key from sam.gov (Workspace > Profile > Account Details > Public API Key). Required — this Actor only uses the official documented api.sam.gov endpoint, never SAM.gov's internal frontend API, so it does not break when the website changes."
                    },
                    "title": {
                        "title": "Title keyword",
                        "type": "string",
                        "description": "Searches ONLY the opportunity title field. SAM.gov's official API has no full-text/description search — this is an intentional platform limitation, not a bug in this Actor. Leave blank to pull all opportunities matching your other filters.",
                        "default": ""
                    },
                    "naicsCode": {
                        "title": "NAICS code(s)",
                        "type": "array",
                        "description": "One or more NAICS codes, e.g. 541512 (Computer Systems Design). Leave empty for all industries.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "procurementTypes": {
                        "title": "Procurement / notice types",
                        "type": "array",
                        "description": "Filter to specific notice types. Leave empty for all types.",
                        "items": {
                            "type": "string",
                            "enum": [
                                "p",
                                "o",
                                "k",
                                "r",
                                "g",
                                "s",
                                "a"
                            ],
                            "enumTitles": [
                                "Presolicitation",
                                "Solicitation",
                                "Combined Synopsis/Solicitation",
                                "Sources Sought",
                                "Sale of Surplus Property",
                                "Special Notice",
                                "Award Notice"
                            ]
                        },
                        "default": []
                    },
                    "setAsideTypes": {
                        "title": "Set-aside type(s)",
                        "type": "array",
                        "description": "Filter to specific small-business set-aside categories. Leave empty for all (including full-and-open).",
                        "items": {
                            "type": "string",
                            "enum": [
                                "SBA",
                                "8A",
                                "SDVOSBC",
                                "WOSB",
                                "EDWOSB",
                                "HZC",
                                "VSA",
                                "SBP"
                            ],
                            "enumTitles": [
                                "Total Small Business",
                                "8(a)",
                                "Service-Disabled Veteran-Owned Small Business",
                                "Women-Owned Small Business",
                                "Economically Disadvantaged WOSB",
                                "HUBZone",
                                "Very Small Business",
                                "Small Business Partnership"
                            ]
                        },
                        "default": []
                    },
                    "state": {
                        "title": "Place-of-performance state",
                        "type": "string",
                        "description": "Two-letter US state code, e.g. VA. Leave blank for all states.",
                        "default": ""
                    },
                    "postedFromDaysAgo": {
                        "title": "Posted from (days ago)",
                        "minimum": 1,
                        "maximum": 365,
                        "type": "integer",
                        "description": "Pull opportunities posted from this many days ago through today. SAM.gov's API requires a bounded date range, so this Actor computes it for you. Keep this small (7 for daily monitoring) — the API has a low daily request cap, so wide date ranges waste quota fast.",
                        "default": 7
                    },
                    "activeOnly": {
                        "title": "Active opportunities only",
                        "type": "boolean",
                        "description": "If true, excludes opportunities whose response deadline has already passed.",
                        "default": true
                    },
                    "maxItems": {
                        "title": "Max results",
                        "minimum": 1,
                        "maximum": 10000,
                        "type": "integer",
                        "description": "Stops the run after this many opportunities. Each page pulls up to 100 records per request, so keep this reasonable relative to your daily API quota.",
                        "default": 200
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
