# SAM.gov Opportunities → Markdown Notice Cards (`ingenious_quip_bxq/sam-gov-opportunities-markdown`) Actor

Search U.S. federal contract opportunities via the official SAM.gov Opportunities API v2. Markdown notice cards (agency, NAICS, dates, value, link). Bring your own free public API key. No HTML scrape, no POC email/phone. Failures free. 256 MB.

- **URL**: https://apify.com/ingenious_quip_bxq/sam-gov-opportunities-markdown.md
- **Developed by:** [新世紀書僮](https://apify.com/ingenious_quip_bxq) (community)
- **Categories:** Business, Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.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 Opportunities → Markdown Notice Cards

Search **U.S. federal contract opportunities** on [SAM.gov](https://sam.gov/) via the **official Opportunities API v2** and get clean **JSON rows** plus **Markdown notice cards** you can read, paste into a CRM, or feed to an LLM / RAG pipeline.

- **Official HTTP only.** `https://api.sam.gov/opportunities/v2/search` (and the related official noticedesc endpoint). **No HTML scrape** of sam.gov pages.
- **Bring your own key (BYOK).** Free public API key from SAM.gov Account Details. Without a key the API returns **HTTP 404**; those rows are free.
- **Light:** 256 MB default, offset/limit pagination, stops at `maxNotices`.
- **Failures are free.** Missing/invalid key, empty search, rate limits, timeouts and server errors are logged as free rows.
- **No contacts / leads.** `pointOfContact` blocks are dropped. Emails and phones in free text are replaced with `[email removed]` / `[phone removed]`.

Part of the same **official procurement → Markdown** product line as **UK Tenders — Find a Tender + Contracts Finder OCDS** (UK), not a redo of that Actor.

### Get a free SAM.gov public API key

1. Create / sign in at <https://sam.gov/>
2. Open **Account Details**
3. Generate / view your **Public API Key** (also documented on [open.gsa.gov — Get Opportunities Public API](https://open.gsa.gov/api/get-opportunities-public-api/))
4. Paste it into the Actor input field `samApiKey` (stored encrypted; never logged)

The Opportunities API public key is **free**. This Actor does **not** buy, store, or share a publisher-owned SAM key — you bring your own.

### What you get

**Dataset**: one row per notice:

| Field | Example |
|---|---|
| `noticeId`, `solicitationNumber` | `5b345bbb7127b91a3ad577b203fc6f68`, `47PF0018R0023` |
| `title`, `agency` | "Historic Office Renovation", "GENERAL SERVICES ADMINISTRATION.…" |
| `type`, `baseType`, `naicsCode`, `setAside` | Solicitation, Combined Synopsis/Solicitation, `236220` |
| `postedDate`, `responseDeadline`, `active` | ISO / SAM date strings |
| `awardAmount`, `awardNumber`, `awardDate`, `awardeeName` | when award data is present |
| `placeOfPerformance`, `uiLink` | structured PoP + https://sam.gov/opp/…/view |
| `descriptionExcerpt`, `markdown` | scrubbed excerpt + full notice card |
| `status`, `errorClass`, `hint` | `ok` / `failed` |

**Key-value store**

- `REPORT.md` — summary table + one Markdown card per notice + "Not charged" section
- `REPORT.json`, `SUMMARY`, `OUTPUT` — counts, filters, charged events, duration, peak memory

#### Example card

```markdown
#### Historic Office Renovation

- **Agency:** GENERAL SERVICES ADMINISTRATION.PUBLIC BUILDINGS SERVICE.PBS R5
- **IDs:** notice `5b345bbb…` · sol `47PF0018R0023` · [view on SAM.gov](https://sam.gov/opp/…/view)
- **Type:** Award Notice (base: Combined Synopsis/Solicitation)
- **NAICS:** `236220`
- **Dates:** posted 2018-05-04
- **Award / value:** $800,620 · 47PF0018C0066 · D.G. Beyer, Inc.

> Renovation of historic office space …
```

### Input (high level)

| Field | Default | Notes |
|---|---|---|
| `samApiKey` | — | **Required for live data** (isSecret). No key → 404 / `missing_key` free |
| `keywords` | — | Official `title` filter |
| `postedFrom` / `postedTo` | daysBack=7 | **MM/dd/yyyy**, max 1 year apart (SAM rule) |
| `daysBack` | 7 | Used when `postedFrom` is empty |
| `ncode` | — | NAICS (≤6 digits) |
| `ptype` | — | e.g. `o,k` (solicitation / combined) |
| `organizationName`, `solnum`, `state`, `typeOfSetAside`, `status` | — | Official filters |
| `noticeIds` | — | Optional direct noticeId list (still needs date window) |
| `maxNotices` | 50 | Cap successful cards |
| `pageSize` | 100 | Official `limit` (max 1000); paging via `offset` |
| `maxConcurrency` | 2 | Description / noticeId parallelism |
| `maxRetries` | 3 | 429 / 5xx / timeout only |
| `fetchDescriptions` | true | Optional official noticedesc excerpt |

### Pricing (pay-per-event)

| Event | Price |
|---|---|
| Actor start | $0.001 |
| `opportunity-notice` (primary) | **$0.003** per successful notice card |

Failures (missing key, invalid key, not found, empty search, rate limit, 5xx) are **free**.

### Diff vs Store scrapers

| | This Actor | Typical Store scrapers |
|---|---|---|
| Source | Official Opportunities API v2 | HTML / browser scrapes |
| Memory | **256 MB** | often 1–4 GB |
| Contacts | **Never** (POC dropped) | often marketed as Contacts / Leads |
| Auth | Buyer public API key | "No key" scrapes that break |
| Output | Markdown notice cards + JSON | raw scrape rows |

### Legal / attribution

Data comes from the U.S. General Services Administration SAM.gov public Opportunities API. You are responsible for complying with SAM.gov / GSA terms and your own daily API quota. This Actor does not scrape HTML and does not harvest contact lists.

### Source code

Open source (AGPL-3.0): https://github.com/xbox002000/sam-gov-opportunities-markdown

# Changelog

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

# Actor input Schema

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

Your free SAM.gov Public API Key. Get it: sign in at https://sam.gov/ → Account Details → Public API Key (or see https://open.gsa.gov/api/get-opportunities-public-api/). Passed as the api_key query parameter. WITHOUT a key the API returns HTTP 404 — those rows are marked failed and NOT charged. Stored encrypted; never logged. The publisher does not buy or host a SAM key.

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

Passed to the official title query parameter (substring match on opportunity title).

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

Start of posted-date window. Format MM/dd/yyyy (SAM requirement). Max span with postedTo is 1 year. If omitted, computed from daysBack.

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

End of posted-date window. Format MM/dd/yyyy. Defaults to today (UTC).

## `daysBack` (type: `integer`):

When postedFrom is empty, search the last N days ending at postedTo/today. Max 365.

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

Official ncode filter — up to 6 digits (e.g. 541512).

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

Official ptype code(s), comma-separated. o=Solicitation, p=Presolicitation, k=Combined synopsis/solicitation, r=Sources sought, s=Special notice, a=Award notice, u=Justification (J\&A), g=Sale of surplus, i=Intent to bundle.

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

Official organizationName filter (department or sub-tier keyword).

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

Official solnum filter.

## `noticeIds` (type: `array`):

Optional. When set, each noticeId is fetched via the official noticeid parameter (still requires postedFrom/postedTo window). Overrides keyword search.

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

Two-letter US state code (official state filter), e.g. VA.

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

Official typeOfSetAside (e.g. SBA, 8A, HZC, SDVOSBC, WOSB). See open.gsa.gov docs.

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

active | inactive | archived | cancelled | deleted (when supported by SAM).

## `maxNotices` (type: `integer`):

Stop after this many successful notice cards.

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

Official limit per page (max 1000). Pagination uses offset+=page.

## `maxConcurrency` (type: `integer`):

Parallel description fetches / noticeId lookups. SAM rate-limits; 2 is usually safe.

## `maxRetries` (type: `integer`):

Retries for HTTP 429 (honours Retry-After), 5xx and timeouts. 400/401/403/404 (incl. missing key) are not retried.

## `requestTimeoutSecs` (type: `integer`):

Timeout for each SAM.gov API call.

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

When true, follow the official noticedesc URL for a short description excerpt (emails/phones scrubbed). Extra API calls count against your SAM daily quota.

## `descriptionMaxChars` (type: `integer`):

Truncate description excerpt. 0 skips description body even if fetchDescriptions is true.

## Actor input object example

```json
{
  "keywords": "information technology",
  "daysBack": 7,
  "ptype": "o,k",
  "status": "",
  "maxNotices": 10,
  "pageSize": 100,
  "maxConcurrency": 2,
  "maxRetries": 3,
  "requestTimeoutSecs": 30,
  "fetchDescriptions": true,
  "descriptionMaxChars": 800
}
```

# Actor output Schema

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

Dataset items: noticeId, title, agency, NAICS, type, postedDate, responseDeadline, award/value, uiLink, descriptionExcerpt, markdown, errorClass.

## `reportMarkdown` (type: `string`):

Summary table plus one Markdown notice card per opportunity. No POC contacts.

## `reportJson` (type: `string`):

Compact JSON of notice cards (same fields as dataset, no contact fields).

## `summary` (type: `string`):

noticesOk, noticesFailed, byClass, apiKeyProvided, keyHint, charged, durationSecs, peakMemoryMb.

# 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": "information technology",
    "daysBack": 7,
    "ptype": "o,k",
    "maxNotices": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("ingenious_quip_bxq/sam-gov-opportunities-markdown").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": "information technology",
    "daysBack": 7,
    "ptype": "o,k",
    "maxNotices": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("ingenious_quip_bxq/sam-gov-opportunities-markdown").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": "information technology",
  "daysBack": 7,
  "ptype": "o,k",
  "maxNotices": 10
}' |
apify call ingenious_quip_bxq/sam-gov-opportunities-markdown --silent --output-dataset

```

## MCP server setup

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

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/LGIPbriuGJI0DeWgA/builds/MUz3pJJdvSg90rJW9/openapi.json
