# SAM.gov Contract Opportunities Scraper (No Key Required) (`guiltless_beanstalk/sam-gov-opportunities`) Actor

Search U.S. federal contract opportunities on SAM.gov: solicitations, RFPs, sources sought & award notices. Works with NO API key via GSA's official public extract, or add your free SAM.gov key for live API queries. Filter by NAICS, set-aside & state.

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

## Pricing

from $2.00 / 1,000 opportunity notices

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: federal bids, RFPs and solicitations

Search **live U.S. federal contract opportunities** on [SAM.gov](https://sam.gov): solicitations, combined synopses, presolicitations, sources sought, special notices, award notices and justifications. Filter by keyword, NAICS code, set-aside, notice type, place-of-performance state and posted date, and get a clean table with agency, deadline, set-aside, contacts and a link to the notice.

This Actor does not scrape the SAM.gov website. It has two official modes:

1. **Live API (recommended)** — with your free SAM.gov public API key, it calls the official **[Get Opportunities Public API v2](https://open.gsa.gov/api/get-opportunities-public-api/)** (`https://api.sam.gov/opportunities/v2/search`) and returns current notices.
2. **Daily extract fallback (no key)** — if `apiKey` is empty, it streams GSA's public [Contract Opportunities data extract](https://sam.gov/data-services/Contract%20Opportunities/datagov?privacy=Public) (`ContractOpportunitiesFullCSV.csv` via SAM.gov Data Services). No account and no API key are required. The file is rebuilt about once a day (usually each morning), so a notice posted today often appears tomorrow. The Actor streams the CSV newest-first and stops at your date window / `maxResults`, so a default run stays small and fast.

### Get a free SAM.gov API key

1. Create a free account at [SAM.gov](https://sam.gov). Sign-in uses [Login.gov](https://login.gov).
2. Sign in, open **Account Details** (your profile / account settings).
3. Re-enter your account password when prompted so SAM.gov can show API key information.
4. Generate a **public API key** if you do not already have one. The key is shown on that page until you navigate away.
5. Paste the key into this Actor's **SAM.gov API key** field. Apify stores secret inputs encrypted and decrypts them only inside the run.
6. Official documentation: [SAM.gov Get Opportunities Public API](https://open.gsa.gov/api/get-opportunities-public-api/).

There is no charge from GSA for a public API key. Daily request limits depend on the role on the account (federal, non-federal, or general). Official docs do not publish the exact numbers in the Opportunities API page; widely reported caps (confirm in your own Account Details) are about **10 requests/day** for a personal account with no role, **1,000/day** with a role or a non-federal system account, and **10,000/day** for a federal system account. This Actor defaults `maxApiCalls` to 8 so one run is unlikely to exhaust a 10-request personal key. If you omit the key, none of this quota applies: the run uses the public extract instead.

### Who uses this

- **Government contractors and BD teams**: a daily list of new bids in your NAICS codes, set-aside and state, with response deadlines.
- **Small, 8(a), HUBZone, SDVOSB and WOSB firms**: filter to the set-asides you can bid.
- **Sales and partner teams selling into GovCon**: see which agencies are buying and who won award notices.
- **Journalists and researchers**: track federal solicitations by keyword, agency or state.

### What you can filter

| Filter | Official API parameter | Example |
|---|---|---|
| Keywords (title search) | `title` | janitorial, cybersecurity |
| NAICS codes | `ncode` | 561720, 541511 |
| Set-aside | `typeOfSetAside` | SBA, 8A, HZC, SDVOSBC, WOSB |
| Notice type | `ptype` | Solicitation, Sources Sought, Award Notice |
| Place-of-performance state | `state` | FL, TX, DC |
| Posted date range or look-back days | `postedFrom` / `postedTo` (MM/dd/yyyy, max 1 year) | last 7 days |

Posted-from and posted-to are required by the API; if you leave the dates blank, the Actor fills them from **Look back (days)** (default 7) through today. The window cannot be longer than one year. The same date window and filters are applied in extract mode (keywords match the title; NAICS, set-aside, notice type and place-of-performance state are applied while streaming the file).

`ptype` accepts multiple notice types in one request. `title`, `ncode`, `typeOfSetAside` and `state` are single-value filters: extra keywords, NAICS codes, set-asides or states are searched as separate combinations and each combination uses more of your daily quota. Prefer one value per filter when your key has a low cap. Page size is 1,000 (the official maximum) so pagination uses as few requests as possible. The official `offset` parameter is a **page index** (the second page is `offset=1`, not 1000).

### Output fields

`noticeId`, `title`, `solicitationNumber`, `noticeType`, `baseType`, `postedDate`, `responseDeadline`, `naicsCode`, `classificationCode`, `setAside`, `setAsideCode`, `active`, `archiveType`, `archiveDate`, `department`, `subTier`, `office`, `organizationName`, `organizationCode`, `popStreet`, `popCity`, `popState`, `popZip`, `popCountry`, `officeCity`, `officeState`, `officeZip`, `contacts` (name, title, type, email, phone as published on the notice), `awardNumber`, `awardAmount`, `awardDate`, `awardeeName`, `awardeeUei`, `awardeeCity`, `awardeeState`, `descriptionUrl`, `resourceLinks`, `additionalInfoLink`, `noticeUrl`, `uiLink`.

In **API mode** the Actor does not download notice description HTML or attachments (each download would spend another API call). `descriptionUrl` and `resourceLinks` are returned with any `api_key` query parameter stripped; append your own key if you fetch them yourself. In **extract mode** those URL fields are typically empty because the daily file does not include the keyed description endpoint or attachment links; the other fields are mapped to the same schema. `noticeUrl` is always the public `https://sam.gov/opp/{noticeId}/view` link.

#### Sample record

```json
{
  "title": "Janitorial Services",
  "noticeType": "Solicitation",
  "postedDate": "2026-11-20",
  "responseDeadline": "2026-12-05T17:00:00-05:00",
  "naicsCode": "561720",
  "setAside": "Total Small Business Set-Aside (FAR 19.5)",
  "setAsideCode": "SBA",
  "department": "DEPARTMENT OF VETERANS AFFAIRS",
  "popState": "FL",
  "noticeUrl": "https://sam.gov/opp/abc123/view"
}
```

### Example inputs

Florida janitorial solicitations posted in the last week:

```json
{
  "apiKey": "YOUR_SAM_GOV_PUBLIC_API_KEY",
  "keywords": ["janitorial"],
  "naicsCodes": ["561720"],
  "noticeTypes": ["o", "k"],
  "states": ["FL"],
  "lookbackDays": 7,
  "maxResults": 50
}
```

Small-business set-asides nationwide, last 3 days:

```json
{
  "apiKey": "YOUR_SAM_GOV_PUBLIC_API_KEY",
  "setAsideTypes": ["SBA"],
  "lookbackDays": 3,
  "maxResults": 100
}
```

### Schedule it as a bid-alert feed

Create an Apify **Schedule** to run daily with `lookbackDays: 1` and your NAICS / set-aside / state filters, then send new rows to Google Sheets, Slack, a CRM or Zapier/Make. Watch `maxApiCalls` so a scheduled run cannot burn a small daily quota. Personal keys with a ~10 request/day cap are enough for a tight daily scan; they are not enough for large historical dumps.

### Pricing

Pay per event: you pay for each opportunity saved to your dataset (the `opportunity` event) plus a small Actor-start fee. See the Pricing tab. The same price applies in API mode and extract mode. This Actor does not bundle or share a SAM.gov API key; live API mode uses only the key you paste into the secret input.

### Data source and fair use

Data comes from the official SAM.gov Get Opportunities Public API, which returns the latest active version of each notice. Active notices are updated daily; archived notices are updated weekly (GSA). This Actor is not affiliated with or endorsed by GSA or SAM.gov. Always confirm details on the official notice before bidding.

Contact names, emails and phone numbers appear only when SAM.gov publishes them as points of contact on the notice. Use the data lawfully and follow anti-spam and privacy laws (CAN-SPAM, TCPA, GDPR where relevant) when contacting anyone.

### FAQ

**Do I have to provide an API key?** No. Leave `apiKey` empty to use the official public daily extract (no login). Add a free SAM.gov public API key when you want live API results rather than yesterday's file.

**Why would I still get a key?** The Get Opportunities API is live and supports server-side filters. The extract is a daily snapshot of active notices, usually a few hours to a day behind, and is the official no-key source published on SAM.gov Data Services and data.gov.

**The run stopped after a few requests.** Check `maxApiCalls` (default 8) and your daily key quota. Narrow keywords, NAICS, state or the date window rather than raising the cap on a 10-request/day key.

**Why is the description empty?** The API returns a URL to the description, not the full text, and fetching that URL costs another request plus your key. The Actor keeps the sanitized URL in `descriptionUrl`.

**Date errors?** SAM.gov requires `postedFrom` and `postedTo` in `MM/dd/yyyy` and rejects ranges longer than one year. Enter dates as `YYYY-MM-DD` in the input form; the Actor converts them.

**Does the Actor log or store my key in the dataset?** No. The key is a secret input. Request URLs are never logged, and `api_key` is stripped from any output URLs. A key is never used unless you paste it into `apiKey` (or, on a local machine only, set `SAM_GOV_API_KEY`).

# Actor input Schema

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

Optional. Your free SAM.gov public API key enables live Get Opportunities API results. Create a SAM.gov account, open Account Details, re-enter your password, and generate a public API key. Apify stores this field encrypted. If you leave it empty, the Actor uses GSA's public daily Contract Opportunities extract (no key, usually updated each morning). Official API docs: https://open.gsa.gov/api/get-opportunities-public-api/

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

Words or phrases matched against the opportunity title using the official API 'title' parameter. One phrase uses one API request; each extra keyword starts another search (OR) and counts against your daily SAM.gov quota. Leave empty for all titles.

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

North American Industry Classification codes, up to 6 digits (official API parameter ncode). Example: 561720 (janitorial), 541511 (custom computer programming). One code is sent to the API; additional codes run as separate searches and use more of your daily quota.

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

Keep only these official SAM.gov set-aside codes (API parameter typeOfSetAside). Only one code can be sent per request; additional selections run as separate searches. Leave empty for all.

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

Procurement / notice types (official API parameter ptype). Multiple types are sent in one request. Leave empty for all types.

## `states` (type: `array`):

Two-letter U.S. state or territory codes for place of performance (official API parameter state), e.g. FL, TX, DC. One state is sent to the API; additional states run as separate searches. Leave empty for all.

## `lookbackDays` (type: `integer`):

Used when no From date is set: search notices posted this many days up to the To date (or today). SAM.gov's API allows at most a 1-year posted-date window. The no-key daily extract is streamed newest-first and stops after this window, so a short lookback finishes fast.

## `dateFrom` (type: `string`):

Optional start of the posted-date range. Overrides Look back. Format YYYY-MM-DD. The range to Posted to cannot exceed 1 year (SAM.gov rule).

## `dateTo` (type: `string`):

Optional end of the posted-date range. Defaults to today. Format YYYY-MM-DD.

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

Maximum number of opportunities to save. Keep this small for a fast run. The Store default is 20 so the daily auto-test finishes quickly. In API mode, each page (up to 1,000 records) uses one request from your daily SAM.gov quota.

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

Stop after this many requests to api.sam.gov in one run, so a personal key is not exhausted. Personal accounts with no role are widely reported to allow only 10 requests per day. Each extra keyword, NAICS, set-aside or state can add a request.

## `requestDelaySecs` (type: `number`):

Pause between SAM.gov requests. The first request is not delayed.

## Actor input object example

```json
{
  "lookbackDays": 7,
  "maxResults": 20,
  "maxApiCalls": 8,
  "requestDelaySecs": 0.5
}
```

# Actor output Schema

## `opportunities` (type: `string`):

Federal contract opportunities found on SAM.gov.

# 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 = {
    "lookbackDays": 7,
    "maxResults": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("guiltless_beanstalk/sam-gov-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 = {
    "lookbackDays": 7,
    "maxResults": 20,
}

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

```

## MCP server setup

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