# SAM.gov Contract Opportunities Scraper (`lulzasaur/sam-gov-scraper`) Actor

Search US government contract opportunities from SAM.gov. Filter by keyword, NAICS code, set-aside type, agency, location, and date range. Get solicitations, awards, and contact info.

- **URL**: https://apify.com/lulzasaur/sam-gov-scraper.md
- **Developed by:** [lulz bot](https://apify.com/lulzasaur) (community)
- **Categories:** E-commerce
- **Stats:** 0 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 results

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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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 Government Contract Opportunities Scraper

Search and extract federal government contract opportunities from SAM.gov (System for Award Management). Find solicitations, presolicitations, award notices, and more with powerful filtering by agency, NAICS code, set-aside type, location, and deadline.

### Features

- **Keyword search** -- Find contract opportunities by keyword across all federal agencies
- **NAICS code filtering** -- Target specific industries (e.g., `541512` for Computer Systems Design)
- **Set-aside filtering** -- Filter by small business, 8(a), HUBZone, SDVOSB, WOSB, and more
- **Agency filtering** -- Search opportunities from specific departments (DoD, NASA, HHS, etc.)
- **Location filtering** -- Filter by state and ZIP code for place of performance
- **Opportunity details** -- Fetch full descriptions and contact info for specific notices
- **Award data** -- Includes award amounts, awardee info, and contract numbers when available
- **Automatic pagination** -- Handles multi-page result sets with rate limiting

### Input Parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `mode` | string | `"search"` | `search` to find opportunities, `details` for a specific notice |
| `apiKey` | string | **required** | SAM.gov public API key (free at [api.sam.gov](https://api.sam.gov)) |
| `searchQuery` | string | `""` | Keyword search (e.g., "cybersecurity", "construction") |
| `opportunityId` | string | `""` | Notice ID for `details` mode |
| `solicitationNumber` | string | `""` | Solicitation number for `details` mode |
| `naicsCode` | string | `""` | NAICS code filter (up to 6 digits) |
| `setAsideType` | string | `""` | Set-aside type: `SBA`, `8A`, `HZC`, `SDVOSBC`, `WOSB`, etc. |
| `opportunityType` | string | `""` | Type: solicitation, presolicitation, sources sought, award, etc. |
| `agency` | string | `""` | Agency or department name (partial match) |
| `postedFrom` | string | `""` | Posted after date (MM/DD/YYYY) |
| `postedTo` | string | `""` | Posted before date (MM/DD/YYYY) |
| `deadlineFrom` | string | `""` | Response deadline start (MM/DD/YYYY) |
| `deadlineTo` | string | `""` | Response deadline end (MM/DD/YYYY) |
| `state` | string | `""` | Place of performance state (2-letter code) |
| `zip` | string | `""` | Place of performance ZIP code |
| `limit` | integer | `100` | Max results (0 for all available) |

### Example Inputs

**Search for IT security contracts:**

```json
{
  "mode": "search",
  "apiKey": "YOUR_SAM_GOV_API_KEY",
  "searchQuery": "cybersecurity",
  "naicsCode": "541512",
  "setAsideType": "SBA",
  "limit": 50
}
```

**Find DoD opportunities in Virginia:**

```json
{
  "mode": "search",
  "apiKey": "YOUR_SAM_GOV_API_KEY",
  "agency": "Department of Defense",
  "state": "VA",
  "opportunityType": "o",
  "limit": 100
}
```

**Get details for a specific opportunity:**

```json
{
  "mode": "details",
  "apiKey": "YOUR_SAM_GOV_API_KEY",
  "opportunityId": "abc123def456"
}
```

### Output Fields

| Field | Type | Description |
|-------|------|-------------|
| `noticeId` | string | Unique notice identifier |
| `title` | string | Opportunity title |
| `solicitationNumber` | string | Solicitation number |
| `type` | string | Human-readable opportunity type |
| `typeCode` | string | Single-letter type code |
| `agency` | string | Full agency path |
| `agencyCode` | string | Agency hierarchy code |
| `naicsCode` | string | NAICS industry code |
| `classificationCode` | string | Product/service classification code |
| `setAsideType` | string | Set-aside description |
| `active` | boolean | Whether the opportunity is currently active |
| `postedDate` | string | Date posted |
| `responseDeadline` | string | Response submission deadline |
| `placeOfPerformance` | object | City, state, country, ZIP of performance |
| `pointOfContact` | array | Contact names, emails, phones |
| `award` | object | Award date, number, amount, and awardee info |
| `awardAmount` | number | Contract award dollar amount |
| `description` | string | Full description (in `details` mode) |
| `url` | string | SAM.gov opportunity URL |
| `officeAddress` | object | Contracting office location |

### Use Cases

- **Government contracting** -- Find and bid on federal contract opportunities
- **Small business outreach** -- Discover set-aside opportunities for SBA, 8(a), HUBZone, SDVOSB
- **Market research** -- Analyze government spending patterns by agency, NAICS, or region
- **Competitive intelligence** -- Track awards to competitors and analyze win rates
- **Subcontracting** -- Find prime contractors winning large awards for teaming opportunities

### Data Source

Data is sourced from the official [SAM.gov Opportunities API](https://api.sam.gov/). A free API key is required (register at [api.sam.gov](https://api.sam.gov)).

***

### Run on Apify

This scraper runs on the [Apify platform](https://apify.com/?fpr=lulzasaur) -- a full-stack web scraping and automation cloud. Sign up for a free account to get started with 30-day trial of all features.

[Try Apify free ->](https://apify.com/?fpr=lulzasaur)

# Actor input Schema

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

Operation mode: 'search' to find opportunities, 'details' to get a specific opportunity by notice ID or solicitation number.

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

Your SAM.gov public API key. Get one free at https://api.sam.gov. Required.

## `searchQuery` (type: `string`):

Keyword to search for (e.g., 'cybersecurity', 'construction', 'IT services'). Used in search mode.

## `opportunityId` (type: `string`):

Specific notice ID to retrieve details for. Used in details mode.

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

Solicitation number to search for. Used in details mode as alternative to notice ID.

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

Filter by NAICS code (up to 6 digits, e.g., '541512' for Computer Systems Design). Leave empty for all.

## `setAsideType` (type: `string`):

Filter by set-aside type

## `opportunityType` (type: `string`):

Filter by procurement type

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

Filter by agency or department name (e.g., 'Department of Defense', 'NASA'). Partial match supported.

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

Only include opportunities posted on or after this date. Format: MM/DD/YYYY. Required for search mode.

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

Only include opportunities posted on or before this date. Format: MM/DD/YYYY. Required for search mode.

## `deadlineFrom` (type: `string`):

Filter by response deadline start date. Format: MM/DD/YYYY.

## `deadlineTo` (type: `string`):

Filter by response deadline end date. Format: MM/DD/YYYY.

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

Filter by place of performance state (2-letter code, e.g., 'CA', 'TX', 'VA').

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

Filter by place of performance ZIP code.

## `limit` (type: `integer`):

Maximum number of opportunities to return. Set 0 for all available. Default 100.

## `proxyConfiguration` (type: `object`):

Proxy settings (usually not needed for API access)

## Actor input object example

```json
{
  "mode": "search",
  "searchQuery": "",
  "opportunityId": "",
  "solicitationNumber": "",
  "naicsCode": "",
  "setAsideType": "",
  "opportunityType": "",
  "agency": "",
  "postedFrom": "",
  "postedTo": "",
  "deadlineFrom": "",
  "deadlineTo": "",
  "state": "",
  "zip": "",
  "limit": 100,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

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

# Run the Actor and wait for it to finish
run = client.actor("lulzasaur/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 '{}' |
apify call lulzasaur/sam-gov-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,lulzasaur/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/9mDymi6lNyv8aJLGA/builds/zEfqtdweHN3bm7lYh/openapi.json
