# SAM.gov Scraper — Federal Contract Opportunities (`khadinakbar/sam-gov-scraper`) Actor

Search public SAM.gov federal contract opportunities through SAM.gov's public API. Returns solicitations, sources sought, awards, contacts, deadlines, set-asides and direct SAM.gov links.

- **URL**: https://apify.com/khadinakbar/sam-gov-scraper.md
- **Developed by:** [Khadin Akbar](https://apify.com/khadinakbar) (community)
- **Categories:** Lead generation, MCP servers, Jobs
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.50 / 1,000 opportunity returneds

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/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

### What is SAM.gov Scraper — Federal Contract Opportunities?

SAM.gov Scraper is an Apify Actor for capture teams, proposal teams, analysts, and AI agents that need public U.S. federal contract opportunities from the public SAM.gov Opportunities API. It accepts a search query and optional filters, and each dataset record represents one validated opportunity. The returned record can include the opportunity title, solicitation number, notice type, agency, NAICS code, set-aside details, deadlines, contacts, attachment URLs, and direct SAM.gov links, giving you a structured result set for review and downstream routing.

### Best fit and connected workflows

This Actor fits workflows that start with a procurement signal and end with a decision on what to review next. Common routing patterns include:

- Keyword-led opportunity discovery for a capability area such as cybersecurity or cloud migration.
- NAICS, set-aside, agency, or place-of-performance filtering for focused market monitoring.
- Deadline-based screening for proposal calendars and capture queues.
- Award, sources sought, solicitation, and special notice monitoring in one normalized output stream.
- Apify-based automation and AI agent workflows that need one consistent opportunity dataset.

Because it is an Apify Actor, it is usable through Apify MCP as part of a larger agent workflow, while the data still comes from the public SAM.gov API and is written to the default dataset.

### Practical scenario

A capture manager starts with the query "network modernization", the NAICS code 541512, and a posted-date range for the current search window. The Actor returns records with fields like `title`, `noticeType`, `agency`, `responseDeadline`, `setAsideCode`, `contacts`, and `samUrl`. The manager uses the deadline and set-aside fields to decide which opportunities move into the capture queue, then opens `samUrl` for the public notice and attached documents.

### Inputs

| Field | Type | Purpose |
| --- | --- | --- |
| `query` | string | Searches words in the opportunity title. Required. |
| `noticeTypes` | array\[string] | Limits results to published SAM.gov notice-type codes such as `o`, `k`, `r`, or `a`. |
| `naicsCode` | string | Filters by one 2-to-6-digit NAICS industry code. |
| `setAsideCode` | string | Filters by one SAM.gov set-aside code such as `SBA`, `8A`, `HZC`, or `SDVOSBC`. |
| `state` | string | Filters by a two-letter place-of-performance state or territory code. |
| `agency` | string | Filters by SAM.gov organization name, such as `Department of Defense`. |
| `postedFrom` | string | Sets the first posted date in `YYYY-MM-DD` or `MM/DD/YYYY` format. |
| `postedTo` | string | Sets the last posted date in `YYYY-MM-DD` or `MM/DD/YYYY` format. |
| `responseDueFrom` | string | Starts an inclusive response-deadline range. Use with `responseDueTo`. |
| `responseDueTo` | string | Ends an inclusive response-deadline range. Use with `responseDueFrom`. |
| `maxResults` | integer | Caps validated opportunity records written to the dataset. Defaults to 100. |

#### Focused JSON input example

```json
{
  "query": "cybersecurity",
  "noticeTypes": ["o", "k", "r"],
  "naicsCode": "541512",
  "setAsideCode": "SBA",
  "state": "VA",
  "agency": "Department of Defense",
  "postedFrom": "2026-07-01",
  "postedTo": "2026-07-19",
  "responseDueFrom": "2026-07-20",
  "responseDueTo": "2026-08-31",
  "maxResults": 100
}
```

### Output fields

The default dataset uses a stable schema. `noticeId`, `title`, `samUrl`, `sourceUrl`, `contacts`, and `attachmentUrls` are required on every record.

| Field | Type | Purpose |
| --- | --- | --- |
| `noticeId` | string | SAM.gov unique opportunity identifier. |
| `title` | string | Published federal procurement opportunity title. |
| `solicitationNumber` | string or null | Solicitation identifier when present. |
| `noticeType` | string or null | Current SAM.gov notice type. |
| `baseNoticeType` | string or null | Original notice type before revision. |
| `postedDate` | string or null | Posted date. |
| `responseDeadline` | string or null | Response deadline. |
| `active` | boolean or null | Active status from the source record. |
| `naicsCode` | string or null | NAICS code. |
| `classificationCode` | string or null | PSC or classification code. |
| `setAsideCode` | string or null | Set-aside code. |
| `setAsideDescription` | string or null | Set-aside description. |
| `agency` | string or null | Agency name from the source. |
| `office` | string or null | Office name from the source. |
| `placeOfPerformance` | object or null | City, state, zip, and country when available. |
| `contacts` | array | Public points of contact. |
| `award` | object or null | Award details when the source record includes them. |
| `descriptionUrl` | string or null | Description URL. |
| `attachmentUrls` | array\[string] | Attachment URLs returned by the source. |
| `samUrl` | string | Direct public SAM.gov opportunity page. |
| `sourceUrl` | string | public API source URL for the record. |

#### Illustrative dataset record

```json
{
  "noticeId": "ff826a59eac743c4a1a07ff5e0cf3e3a",
  "title": "Network modernization services",
  "noticeType": "Solicitation",
  "postedDate": "2026-07-18",
  "responseDeadline": "2026-08-17T17:00:00-04:00",
  "naicsCode": "541512",
  "setAsideCode": "SBA",
  "agency": "DEPARTMENT OF DEFENSE",
  "contacts": [
    {
      "name": "Ada Lovelace",
      "title": "Contracting Officer",
      "email": "ada@example.gov",
      "phone": null
    }
  ],
  "attachmentUrls": [],
  "samUrl": "https://sam.gov/opp/ff826a59eac743c4a1a07ff5e0cf3e3a/view",
  "sourceUrl": "https://api.sam.gov/opportunities/v2/search?noticeid=ff826a59eac743c4a1a07ff5e0cf3e3a"
}
```

### How it works

This Actor searches published U.S. federal contract opportunities through the public SAM.gov Opportunities API. It uses the public search endpoint behind SAM.gov opportunities, applies your filters, and writes normalized opportunity records to the default dataset.

Implementation facts surfaced in the contract:

- It searches published opportunities only.
- It returns notice types including solicitations, combined synopsis/solicitation, presolicitation, sources sought, special notices, award notices, justifications, sale of surplus property, and intent to bundle.
- It defaults to a posted-date window from 30 days ago through today when dates are omitted.
- It uses `maxResults` as a hard cap for validated opportunity records written to the dataset.
- The output also includes `OUTPUT` and `RUN_SUMMARY` records in the default key-value store.

SAM.gov Scraper — Federal Contract Opportunities is designed as a focused workflow.

### Pricing

SAM.gov Scraper — Federal Contract Opportunities uses Pay per event plus Apify platform usage.

- Actor start: charged once per configured GB of memory when the run starts.
- Opportunity returned: charged for each validated SAM.gov opportunity written to the default dataset.

A run capped at one hundred returned opportunities means one hundred Opportunity returned events, plus one Actor start event, and then Apify platform usage on top of that. To see the live amount that applies to your current configuration, open the Pricing tab in the Apify console.

### Use with AI agents (MCP)

This Actor can be used through Apify MCP as a tool for procurement discovery and opportunity triage. The tool returns structured SAM.gov opportunity records from the public API, so an agent can search, read, and route opportunities using stable fields like `noticeId`, `title`, `agency`, `responseDeadline`, `contacts`, and `samUrl`.

Actor identity: `khadinakbar/sam-gov-scraper`

> Find current SAM.gov opportunities for cybersecurity work in Virginia, return only records with public titles and deadlines, and summarize which ones appear earliest by response date. Use the dataset output as the source of truth and keep the SAM.gov link with each record.

Output interpretation:

- Treat each dataset row as one validated opportunity.
- Use `noticeId` for deduplication.
- Use `samUrl` for the human review step.
- Use `sourceUrl` for provenance back to the public API record.
- Use `contacts` for public points of contact only when they are present in the source.

Scope and pagination:

- The actor searches published opportunities through the public SAM.gov Opportunities API.
- It follows the contract's filtered search fields and returns normalized records.
- `maxResults` sets the total cap for written records, so it also helps bound opportunity-event charges.

Cost guidance:

- Each returned opportunity is a billable event.
- A narrower query, tighter date window, or lower `maxResults` can reduce the number of returned records.
- Apify platform usage is separate from event charges.

### Apify API example

```javascript
import { ApifyClient } from "apify-client";

const client = new ApifyClient({
  token: process.env.APIFY_TOKEN,
});

const run = await client.actor("khadinakbar/sam-gov-scraper").call({
  query: "cybersecurity",
  noticeTypes: ["o", "r"],
  postedFrom: "2026-07-01",
  postedTo: "2026-07-19",
  maxResults: 10,
});

const datasetItems = await client.dataset(run.defaultDatasetId).listItems();
console.log(datasetItems.items);
```

Set `APIFY_TOKEN` in your environment before running the example. The code starts the Actor, waits for completion, and reads back the default dataset items.

### Best results and outcome guidance

For the most useful output, start with one clear search intent and then add filters that match the workflow you are building:

- Use `query` for capability keywords that appear in the opportunity title.
- Use `noticeTypes` when you want a narrower notice set such as solicitations or sources sought.
- Use `naicsCode` and `setAsideCode` to align the search with your market focus.
- Use `postedFrom` and `postedTo` to keep monitoring windows current.
- Use `responseDueFrom` and `responseDueTo` when deadline priority matters.
- Use `maxResults` to match the amount of opportunity review your process can handle.

### Continue the workflow

- Then use [APEC Jobs Scraper](https://apify.com/khadinakbar/apec-jobs-scraper) to extend SAM.gov Scraper — Federal Contract Opportunities with a neighboring job-market research source when the brief calls for Apec data.
- Then use [ZipRecruiter Jobs Scraper](https://apify.com/khadinakbar/ziprecruiter-jobs-scraper) to extend SAM.gov Scraper — Federal Contract Opportunities with a neighboring job-market research source when the brief calls for Ziprecruiter data.

### Design note

I found that the dataset contract requires both `contacts` and `attachmentUrls` on every record, while many other fields are nullable. That is a useful signal that the output is structured for stable downstream handling even when the source omits optional details.

### FAQ

#### Can I route by notice type?

Yes. `noticeTypes` accepts published SAM.gov notice-type codes such as solicitation, combined synopsis/solicitation, sources sought, special notice, and award notice.

#### Can I search by agency and place of performance together?

Yes. The input includes both `agency` and `state`, so a workflow can focus on an organization name and a work-location state at the same time.

#### How should I use the returned links?

Use `samUrl` for the public opportunity page and `sourceUrl` for the public API source record. Both are useful for provenance and review.

#### What should I use for deduplication?

Use `noticeId`. It is the SAM.gov unique opportunity identifier in the output schema.

#### Is this Actor useful for AI agents?

Yes. It exposes structured procurement data through Apify, and the result set can be consumed in Apify MCP workflows or through the Apify API.

### Responsible use

Use the returned public data for lawful procurement research and workflow automation. Verify the public SAM.gov notice before making business, proposal, contact, or compliance decisions. The Actor searches published opportunities through the public API and returns source-backed records, but the final procurement judgment belongs with the user and their review process.

# Changelog

This Actor's version history is a separate document: https://apify.com/khadinakbar/sam-gov-scraper/changelog.md

# Actor input Schema

## `query` (type: `string`):

Use this to search words in the SAM.gov opportunity title, for example cybersecurity or cloud migration. It defaults to no keyword so filters can return all matching opportunities. This is not a full-text search of attached solicitation documents.

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

Use this to limit results to published SAM.gov notice-type codes. Select values such as o for Solicitation, k for Combined Synopsis/Solicitation, r for Sources Sought, or a for Award Notice. It defaults to all supported types. This is not a contract award category.

## `naicsCode` (type: `string`):

Use this to filter opportunities by one 2-to-6-digit NAICS industry code, for example 541512. It is optional and the official API accepts one code per request. This is not a PSC or a free-text industry name.

## `setAsideCode` (type: `string`):

Use this to filter by one SAM.gov set-aside code, for example SBA, 8A, HZC, or SDVOSBC. It is optional and should use the official short code. This is not a description such as 'small business'.

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

Use this to filter the work location by a two-letter state or territory code, for example VA. It is optional and maps to SAM.gov's place-of-performance filter. This is not the contracting agency's state.

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

Use this to filter by the SAM.gov organization name, for example Department of Defense. It is optional and supports the official organization-name field. This is not a contracting officer's name.

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

Use this to set the first posted date as YYYY-MM-DD or MM/DD/YYYY, for example 2026-07-01. It defaults to 30 days ago and SAM.gov permits at most one year per search. This is not a response deadline.

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

Use this to set the last posted date as YYYY-MM-DD or MM/DD/YYYY, for example 2026-07-19. It defaults to today and must not precede posted from. This is not an archive date.

## `responseDueFrom` (type: `string`):

Use this with response deadline to include only opportunities whose response date is on or after this date. Use YYYY-MM-DD or MM/DD/YYYY, for example 2026-07-20. Both deadline fields are required together. This is not a posted-date filter.

## `responseDueTo` (type: `string`):

Use this with response deadline from to include only opportunities whose response date is on or before this date. Use YYYY-MM-DD or MM/DD/YYYY, for example 2026-08-31. Both deadline fields are required together. This is not an award date.

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

Use this to cap validated SAM.gov opportunity records written to the dataset. Enter an integer from 1 through 10000, for example 100. It defaults to 100 and prevents charges beyond this number of returned opportunities. This is not an API page count.

## Actor input object example

```json
{
  "query": "cybersecurity",
  "noticeTypes": [
    "o",
    "k",
    "r"
  ],
  "naicsCode": "541512",
  "setAsideCode": "SBA",
  "state": "VA",
  "agency": "Department of Defense",
  "postedFrom": "2026-07-01",
  "postedTo": "2026-07-19",
  "responseDueFrom": "2026-07-20",
  "responseDueTo": "2026-08-31",
  "maxResults": 100
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `output` (type: `string`):

No description

## `summary` (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 = {
    "query": "software",
    "noticeTypes": [
        "o",
        "k",
        "r"
    ],
    "maxResults": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("khadinakbar/sam-gov-scraper").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 = {
    "query": "software",
    "noticeTypes": [
        "o",
        "k",
        "r",
    ],
    "maxResults": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("khadinakbar/sam-gov-scraper").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 '{
  "query": "software",
  "noticeTypes": [
    "o",
    "k",
    "r"
  ],
  "maxResults": 10
}' |
apify call khadinakbar/sam-gov-scraper --silent --output-dataset

```

## MCP server setup

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

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/SZC3tSm0Rhoc9KRzO/builds/A3pyMQQMBWtQe3RrS/openapi.json
