# SAM.gov Public Opportunities API (`tidydata69/sam-gov-opportunities`) Actor

Search U.S. federal contract opportunities via the official GSA Get Opportunities Public API (api.sam.gov). Uses your own free SAM.gov api_key. No HTML scraping.

- **URL**: https://apify.com/tidydata69/sam-gov-opportunities.md
- **Developed by:** [Bryce](https://apify.com/tidydata69) (community)
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 opportunity rows

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 Public Opportunities API

Search **U.S. federal contract opportunities** using the official **GSA Get Opportunities Public API**\
(`https://api.sam.gov/opportunities/v2/search`).

This Actor is an **API client only**. It does **not** scrape `sam.gov` HTML, does **not** harvest contacts, and does **not** use paid proxies.

### Get a free SAM.gov API key

1. Create / sign in at [sam.gov](https://sam.gov).
2. Open **Account Details**.
3. Request a **Public API Key** (instant for registered users).
4. Paste that key into this Actor’s **apiKey** input (kept secret in Apify).

Docs: [open.gsa.gov — Get Opportunities Public API](https://open.gsa.gov/api/get-opportunities-public-api/).

### What you get

| Field | Description |
| --- | --- |
| `noticeId` | SAM notice id |
| `title` | Opportunity title |
| `solicitationNumber` | Solicitation number |
| `agency` | Organization path / agency |
| `postedDate` | Posted date |
| `responseDeadline` | Response deadline |
| `type` / `baseType` | Notice type |
| `naicsCode` / `classificationCode` | Codes |
| `setAside` / `setAsideCode` | Set-aside info |
| `active` | Yes / No |
| `uiLink` | SAM.gov UI link when provided |
| `descriptionLink` | Official noticedesc API URL (not scraped HTML) |
| `descriptionSummary` | Inline text only if the API returns text instead of a URL |
| `placeOfPerformance` | City / state / zip / country summary |
| `awardAmount` / `awardDate` / `awardNumber` | Award fields when present |

**Contact fields (`pointOfContact`) are intentionally omitted** — no contact harvesting.

### Input

- **apiKey** (required, secret) — your SAM.gov public API key
- **postedFrom** / **postedTo** (required) — `MM/dd/yyyy`, max 1-year span
- **keywords** — mapped to official `title=` filter
- **ptype**, **status**, **organizationCode**, **organizationName**, **ncode**, **ccode**, **state**, **zip**, **solnum**, **noticeid**, **typeOfSetAside**, **rdlfrom** / **rdlto**
- **limit** — max rows to write (default 25)
- **offset** — starting SAM page index (default 0)
- **pageSize** — rows per API page (max 1000)

#### Example

```json
{
  "apiKey": "YOUR_SAM_GOV_PUBLIC_API_KEY",
  "postedFrom": "10/01/2026",
  "postedTo": "11/04/2026",
  "keywords": "software",
  "ptype": "o",
  "limit": 10
}
```

### How it works

1. Calls `https://api.sam.gov/opportunities/v2/search` only.
2. Sends a descriptive `User-Agent` and `Accept: application/json`.
3. Stays around **~1 request/second** and honors HTTP **429**.
4. Paginates with SAM `offset` (page index) + `limit`.
5. Writes one dataset item per opportunity (contacts stripped).
6. Fails clearly if `apiKey` is missing or rejected by SAM.gov.

### Pricing (pay-per-event)

Intended Store pricing (synthetic events — configure in Apify Console when payout/billing info is available):

- **$0.005** per Actor start (`apify-actor-start`)
- **$0.001** per opportunity row written to the default dataset (`apify-default-dataset-item`)

Until Console monetization is enabled (requires payout / billing info on the account), the Actor still uses `Actor.pushData()` so synthetic PPE events will charge automatically once configured. No custom `Actor.charge()` events are required.

### Limitations & rules

- No HTML scraping of sam.gov.
- No contact harvesting (PoC email/phone/name dropped).
- No residential / upgraded proxies — plain HTTPS to `api.sam.gov`.
- You must supply your own free SAM.gov `api_key`. Daily quotas are enforced by GSA based on account role.
- Keep `limit` modest while exploring.

### Use cases

- Monitor new solicitations by keyword / NAICS / agency
- Export award notices for analysis
- Feed a govcon pipeline without fragile HTML scrapers

### Output

Open the run’s **Dataset** tab (or download via API). Each item is one opportunity record.

# Actor input Schema

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

Your free public API key from SAM.gov. Create a free account at https://sam.gov → Account Details → request a Public API Key (also documented at https://open.gsa.gov/api/get-opportunities-public-api/). Never share this key. Passed to the API as api_key=.

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

Inclusive lower bound for posted date. Required by SAM.gov. Format MM/dd/yyyy. Range with postedTo must be ≤ 1 year.

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

Inclusive upper bound for posted date. Required by SAM.gov. Format MM/dd/yyyy. Range with postedFrom must be ≤ 1 year.

## `keywords` (type: `string`):

Optional title filter. Mapped to the official API title= parameter (substring match on opportunity title). There is no separate q= on the public Opportunities API.

## `ptype` (type: `string`):

Optional notice type code(s). Codes: u=Justification (J\&A), p=Pre solicitation, a=Award Notice, r=Sources Sought, s=Special Notice, o=Solicitation, g=Sale of Surplus Property, k=Combined Synopsis/Solicitation, i=Intent to Bundle (DoD). Multiple codes can be comma-separated.

## `status` (type: `string`):

Optional opportunity status filter (API: active, inactive, archived, cancelled, deleted). Marked Coming Soon in GSA docs — passed through when provided.

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

Optional organizationCode filter (federal hierarchy code).

## `organizationName` (type: `string`):

Optional organizationName filter (department / subtier name search).

## `ncode` (type: `string`):

Optional NAICS code (max 6 digits).

## `ccode` (type: `string`):

Optional PSC / classification code.

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

Optional 2-letter state code for place of performance.

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

Optional ZIP code for place of performance.

## `solnum` (type: `string`):

Optional exact solicitation number filter.

## `noticeid` (type: `string`):

Optional notice ID filter.

## `typeOfSetAside` (type: `string`):

Optional set-aside code (e.g. SBA, 8A, HZC, SDVOSBC, WOSB). See open.gsa.gov Set-Aside Values.

## `rdlfrom` (type: `string`):

Optional response-deadline lower bound (MM/dd/yyyy).

## `rdlto` (type: `string`):

Optional response-deadline upper bound (MM/dd/yyyy).

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

Maximum opportunity records to return across pages. Each SAM page is at most 1000 rows. Keep small while testing (SAM daily quotas apply per api_key).

## `offset` (type: `integer`):

Zero-based SAM.gov page index to start from (passed as offset=). Default 0.

## `pageSize` (type: `integer`):

Records per SAM.gov request (API limit param, max 1000).

## Actor input object example

```json
{
  "postedFrom": "10/01/2026",
  "postedTo": "11/04/2026",
  "keywords": "software",
  "limit": 10,
  "offset": 0,
  "pageSize": 100
}
```

# Actor output Schema

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

Federal contract opportunity records from the official SAM.gov Opportunities API (no HTML scrape; contact fields omitted).

# 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 = {
    "postedFrom": "10/01/2026",
    "postedTo": "11/04/2026",
    "keywords": "software",
    "limit": 10,
    "offset": 0,
    "pageSize": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("tidydata69/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 = {
    "postedFrom": "10/01/2026",
    "postedTo": "11/04/2026",
    "keywords": "software",
    "limit": 10,
    "offset": 0,
    "pageSize": 100,
}

# Run the Actor and wait for it to finish
run = client.actor("tidydata69/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 '{
  "postedFrom": "10/01/2026",
  "postedTo": "11/04/2026",
  "keywords": "software",
  "limit": 10,
  "offset": 0,
  "pageSize": 100
}' |
apify call tidydata69/sam-gov-opportunities --silent --output-dataset

```

## MCP server setup

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