# SAM.gov Contract Opportunities API (Official, Your Own Key) (`gigsmith/sam-gov-contract-opportunities`) Actor

Search US federal contract opportunities on SAM.gov through the official Get Opportunities API with your own free key. Filter by keyword, NAICS, set-aside, notice type, agency, state and dates. Clean, flat rows with contacts, deadlines, awards and attachment links. $0.002 per opportunity.

- **URL**: https://apify.com/gigsmith/sam-gov-contract-opportunities.md
- **Developed by:** [Gigsmith](https://apify.com/gigsmith) (community)
- **Categories:** Lead generation, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.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 API: federal bids as clean data, with your own key

**SAM.gov Contract Opportunities** searches US federal contract opportunities through the **official SAM.gov Get Opportunities API** and returns clean, flat rows: title, notice type, agency, NAICS, set-aside, posted date, response deadline, place of performance, points of contact, award details and attachment links. Filter by keyword, NAICS code, set-aside, notice type, agency, state and dates. It **costs $0.002 per opportunity**.

It uses your own free SAM.gov API key and the official public API, not page scraping, so results are complete, stable and within SAM.gov's terms.

### What can this SAM.gov Actor do?

- 🏛️ **Official data**: calls `api.sam.gov/opportunities/v2/search` with your key. No HTML scraping, no broken selectors
- 🔎 **Rich filters**: title keywords, NAICS codes, notice types (solicitation, presolicitation, sources sought, award...), set-aside (SBA, 8(a), HUBZone, SDVOSB, WOSB...), agency, organization code, state, ZIP, PSC code, solicitation number, posted dates and response-deadline window
- 🧹 **Normalized rows**: department, agency and office split out; contacts, place of performance and award details flattened; duplicates across searches removed
- 📎 **Links ready to use**: SAM.gov page link, attachment URLs and description link, **with your API key stripped out** so you can share the dataset safely
- 📝 **Optional full descriptions** (one extra API call each)
- 🛡️ **Quota-aware**: plans the API calls before it starts and stops cleanly when your key's daily quota is used up
- ⏰ **Built for monitoring**: "Posted in the last N days" makes daily or weekly scheduled runs simple

### Who uses SAM.gov opportunity data?

- **Government contractors and small businesses** watching for bids in their NAICS codes and set-aside programs
- **Capture and BD teams** feeding new solicitations into a CRM, spreadsheet or Slack channel
- **Bid-matching and GovTech tools** that need a reliable opportunities feed
- **Analysts and researchers** studying federal procurement by agency, set-aside or industry

### How to get SAM.gov opportunities

1. Get a free **SAM.gov public API key**: sign in at sam.gov, open **Account Details**, and request an API key.
2. Click **Try for free** on this Actor and paste the key into **SAM.gov API key**.
3. Add **Title keywords**, **NAICS codes** and any other filters, and choose the posted-date window.
4. Click **Start**. Each opportunity becomes one row in the **Output** tab (views: Opportunities, Contacts, All fields), downloadable as JSON, CSV or Excel.

#### Input example

```json
{
  "samApiKey": "<your SAM.gov key>",
  "keywords": ["cybersecurity"],
  "naicsCodes": ["541511", "541512"],
  "noticeTypes": ["o", "k"],
  "setAside": "SBA",
  "postedWithinDays": 7,
  "activeOnly": true,
  "maxItems": 500,
  "maxApiCalls": 10
}
```

| Field | What it does |
|---|---|
| `samApiKey` | Your own SAM.gov public API key (stored encrypted, never logged or saved) |
| `keywords` | Title searches; each keyword is one API search |
| `naicsCodes` | Each NAICS code is one API search (every keyword x NAICS x notice-type combination is a call) |
| `noticeTypes` | `o` Solicitation, `p` Presolicitation, `k` Combined Synopsis/Solicitation, `r` Sources Sought, `s` Special Notice, `a` Award Notice, `u` J\&A, `g` Surplus sale, `i` Intent to bundle |
| `setAside` | One set-aside code, e.g. `SBA`, `8A`, `HZC`, `SDVOSBC`, `WOSB` |
| `agency`, `organizationCode`, `state`, `zip`, `classificationCode`, `solicitationNumber`, `noticeId` | Extra API filters |
| `postedWithinDays` / `postedFrom` / `postedTo` | Posted-date window (at most 1 year, an API rule) |
| `responseDeadlineFrom` / `responseDeadlineTo` | Response-deadline window |
| `activeOnly` | Drop archived notices |
| `mustContain` | Free local title filter applied after the search |
| `fetchDescriptions` | Add the full description text (one API call per opportunity) |
| `includeRaw` | Add the original SAM.gov record under `raw` (key stripped) |
| `maxItems`, `maxApiCalls` | Row cap, and a cap on calls to protect your key's daily quota |

#### Output example

The record below is the example notice from the official SAM.gov API documentation, as this Actor returns it:

```json
{
  "noticeId": "5b345bbb7127b91a3ad577b203fc6f68",
  "title": "Historic Office Renovation",
  "solicitationNumber": "47PF0018R0023",
  "noticeType": "Award Notice",
  "baseType": "Combined Synopsis/Solicitation",
  "postedDate": "2018-05-04",
  "responseDeadline": null,
  "archiveDate": null,
  "archiveType": "manual",
  "active": true,
  "setAsideCode": null,
  "setAside": null,
  "naicsCode": "236220",
  "naicsCodes": [
    "236220"
  ],
  "classificationCode": "Z",
  "department": "GENERAL SERVICES ADMINISTRATION",
  "subTier": "PUBLIC BUILDINGS SERVICE",
  "office": "PBS R5",
  "agencyPath": null,
  "agencyPathCode": null,
  "officeAddress": {
    "city": "CHICAGO",
    "state": "IL",
    "zip": "60604",
    "country": "USA"
  },
  "placeOfPerformance": {
    "city": "Milwaukee",
    "state": "WI",
    "zip": "53202",
    "country": "USA"
  },
  "pointsOfContact": [
    {
      "type": "primary",
      "name": "Jesse L. Jones",
      "title": "Contracting Officer",
      "email": "jesse.jones@gsa.gov",
      "phone": "2174941263"
    }
  ],
  "award": {
    "number": "47PF0018C0066",
    "amount": 800620.0,
    "date": "2018-05-04",
    "awardeeName": "D.G. Beyer, Inc.",
    "awardeeUei": "025114695AST"
  },
  "samUrl": "https://sam.gov/opp/5b345bbb7127b91a3ad577b203fc6f68/view",
  "descriptionApiUrl": "https://api.sam.gov/prod/opportunities/v1/noticedesc?noticeid=5b345bbb7127b91a3ad577b203fc6f68",
  "additionalInfoLink": null,
  "attachmentUrls": [],
  "matchedQuery": {
    "ptype": "a"
  }
}
```

The run's `OUTPUT` record has a summary: queries, API calls used, records matched on SAM.gov, rows returned and charged events.

### How much does it cost?

This Actor uses **pay-per-event** pricing.

| Event | Price | When it's charged |
|---|---|---|
| `opportunity` | **$0.002** | Once per opportunity saved to the dataset, after duplicates are removed |

- No monthly rental. Apify platform usage is included. The only other charge is Apify's standard run-start event of $0.00005 per run.
- 1,000 opportunities cost **$2**. A daily NAICS watch that returns 20 new notices costs about **$0.04 a day**.
- Rejected keys, invalid inputs and failed API calls are **not charged**.
- The SAM.gov API itself is free; you only need your own key.
- Set **Max charge per run** to cap your spend.

### About SAM.gov API limits

SAM.gov limits how many API requests each key can make per day, depending on the account's role. Personal keys without a role get a small daily allowance (about 10 requests); keys from accounts with a SAM.gov role or a system account get far more. Each search page returns up to 1,000 opportunities in one request, so a focused daily search usually needs only 1–3 calls. The Actor counts its calls, refuses searches that would need more than **Max API calls**, and stops cleanly with a clear message if SAM.gov reports the quota is used up.

### FAQ

**Is this scraping SAM.gov?** No. It uses the official, documented Get Opportunities public API with your own key.

**Why do I need my own API key?** SAM.gov issues keys per user and doesn't allow sharing them. With your own key, the data access is yours and fully within SAM.gov's terms. Keys from api.data.gov and `DEMO_KEY` don't work on SAM.gov; it must be the key from your SAM.gov Account Details page.

**Can I search the description text?** The API searches titles. Use `fetchDescriptions` to download descriptions, then filter them in your own tools.

**Can I get attachments?** Each row includes `attachmentUrls`. Opening them requires appending your own API key, which the Actor deliberately leaves out of the dataset.

**Can I run it every morning?** Yes. Create an Apify Schedule with `postedWithinDays: 1` and connect the dataset to Google Sheets, Slack, email, Make, Zapier or n8n.

**Something went wrong?** Open an issue on the **Issues** tab with the run link and I'll fix it.

### Keywords

SAM.gov API, SAM.gov scraper, federal contract opportunities, government contracts, government bids, RFP search, federal RFPs, NAICS search, set-aside opportunities, small business contracts, 8(a) contracts, SDVOSB contracts, contract opportunities API, govcon leads, procurement data

***

Made by **Gigsmith**. Not affiliated with or endorsed by GSA or SAM.gov.

# Actor input Schema

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

Your own public API key: sign in at sam.gov, open Account Details and request an API key. Stored encrypted by Apify; never written to the dataset or log. SAM.gov limits how many requests a key can make per day.

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

Each keyword runs one SAM.gov title search (e.g. cybersecurity, janitorial). Results are merged and de-duplicated. Leave empty for all titles.

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

Each code runs one search (e.g. 541511, 541512). Combined with keywords, every keyword x NAICS pair is one API call.

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

Leave empty for all types. Each selected type is a separate API call.

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

Only one set-aside per run (an API limit).

## `agency` (type: `string`):

Department, sub-tier or office name, e.g. "Department of Veterans Affairs" or "GENERAL SERVICES ADMINISTRATION".

## `organizationCode` (type: `string`):

Agency code, as in the agencyPathCode output field.

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

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

## `zip` (type: `string`):

Five-digit ZIP code of the place of performance.

## `classificationCode` (type: `string`):

e.g. D302 or R.

## `solicitationNumber` (type: `string`):

Exact solicitation number, e.g. W15QKN-26-R-0001.

## `noticeId` (type: `string`):

Exact SAM.gov notice ID.

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

Used when "Posted from" is empty. Ideal for daily or weekly scheduled runs.

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

Optional. The window from "Posted from" to "Posted to" can be at most 1 year.

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

Optional, defaults to today (UTC).

## `responseDeadlineFrom` (type: `string`):

Optional: only opportunities whose response deadline is in this window.

## `responseDeadlineTo` (type: `string`):

Optional end of the response deadline window (at most 1 year after the start).

## `activeOnly` (type: `boolean`):

Drop archived notices.

## `mustContain` (type: `array`):

Extra local filter: keep a row only if its title contains one of these words. Free (no API calls).

## `fetchDescriptions` (type: `boolean`):

Downloads each notice's description text. Uses one extra API call per opportunity from your key's daily quota.

## `includeRaw` (type: `boolean`):

Adds the original API record under `raw` (links without your key).

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

Stop after this many rows.

## `maxApiCalls` (type: `integer`):

Protects your key's daily quota. Each search page (up to 1,000 rows) and each description is one call. Personal keys without a SAM.gov role get about 10 calls a day; keys with a role get about 1,000.

## Actor input object example

```json
{
  "keywords": [
    "software"
  ],
  "naicsCodes": [
    "541511"
  ],
  "postedWithinDays": 7,
  "activeOnly": false,
  "fetchDescriptions": false,
  "includeRaw": false,
  "maxItems": 500,
  "maxApiCalls": 10
}
```

# Actor output Schema

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

Default dataset items, shown in the "Opportunities" view.

## `contactsView` (type: `string`):

Default dataset items, shown in the "Contacts" view.

## `detailsView` (type: `string`):

Default dataset items, shown in the "All fields" view.

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

JSON summary of the run: queries, API calls, records matched and returned, and charged events.

# 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": [
        "541511"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("gigsmith/sam-gov-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": ["541511"],
}

# Run the Actor and wait for it to finish
run = client.actor("gigsmith/sam-gov-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": [
    "541511"
  ]
}' |
apify call gigsmith/sam-gov-contract-opportunities --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,gigsmith/sam-gov-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/NGxCSyVKSV8sbMNoI/builds/xgyS4ZlPZaXh5kiM9/openapi.json
