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

Search US federal contract opportunities and export notice details, deadlines, agencies and public attachment links. No bid submission or attachment downloads.

- **URL**: https://apify.com/barefoot_grade/sam-gov-opportunities-scraper.md
- **Developed by:** [Philip Kirkbride](https://apify.com/barefoot_grade) (community)
- **Categories:** Lead generation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 opportunities

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 Scraper

Search US federal contract opportunities and export notice details, deadlines, agency paths, published contacts and public attachment links. This actor does not submit bids, download attachments or retrieve restricted documents.

Run with `{}` to collect 10 recently updated active opportunities. No account or API key is required for the default search.

```json
{"mode":"search","activeOnly":true,"maxResults":10}
```

Use `keywords`, `naicsCodes`, `pscCodes`, `noticeTypes`, `setAside`, `agency`, `postedFrom` / `postedTo`, and `responseDeadlineFrom` / `responseDeadlineTo` to narrow search results. Code lists match any selected value within each field; different fields combine. NAICS codes have six digits; PSC codes have two to four uppercase letters or digits. `agency` takes a numeric SAM organization ID (for example `100000000` for Department of Defense). Set-aside takes a SAM code such as `SBA`. Date bounds are inclusive YYYY-MM-DD dates using UTC boundaries. `activeOnly` defaults to true; false includes inactive notices. Search results are ordered by last update.

Notice types: `solicitation`, `presolicitation`, `sourcesSought`, `award`, `specialNotice`, `combinedSynopsisSolicitation`, `justification`, `saleOfSurplusProperty`, `intentToBundle`.

For complete notice details, set `mode` to `details` and supply `noticeIds` as 32-character IDs or SAM.gov notice links. This mode retrieves the exact notices regardless of active status and accepts no search filters. It includes current public attachment names and URLs; controlled, export-restricted and deleted attachments are excluded. Attachment URLs are returned without fetching the files and may later expire or become unavailable.

```json
{"mode":"details","noticeIds":["https://sam.gov/opp/53e9119230bc4467884e7227ee2aef52/view"],"maxResults":10}
```

`maxResults` is 1–10,000 and defaults to 10. A search can examine only the first 10,000 source matches; use narrower filters to collect beyond this window across separate runs. Shifting source data can move notices between pages. Duplicate notice IDs are suppressed.

The API-key route is tested only against a documented response shape, not yet with a live key.

Optional `apiKey` selects the official SAM.gov API for search. It is stored as a secret. Obtain your personal public API key through your SAM.gov account profile and follow SAM.gov's access and quota rules. This route supports one value per code/type filter, does not accept website agency IDs, and searches titles with `keywords`. A posted-date window is required: omitted bounds default to the past 30 days through today; the maximum span is 365 days. Only active matches are saved when `activeOnly` is true. Official search returns fewer fields and excludes description text and attachment lists. The supplied key is used only with the official API; details mode requires it to be omitted.

Every row has `rowType: opportunity`, `noticeId`, and a canonical `url`. Output includes title, solicitation number, agency path/hierarchy, notice type, posted/updated dates, response deadline and source timezone when supplied, set-aside, NAICS/PSC codes, place of performance, plain-text description, published points of contact, award fields, and attachment metadata. Missing values are null or empty arrays. Award amounts and attachment sizes are numbers. Date-only source values remain ISO dates; timestamps retain their published timezone offset. `detailsComplete` is true for details-mode rows; search rows have no attachment enrichment. Source omissions remain omissions.

Rows save as each page or notice completes. Runs with saved rows succeed and name failed targets in the status. With no rows, a failed source fails the run; a twice-confirmed empty result succeeds. A shared deadline reserves 20 seconds to finish, and temporary errors retry only while time remains.

Only public notices and their published official points of contact are collected. No login, identity enrichment, private accounts or restricted content is accessed. This actor is independent of the US government.

Delivered opportunity rows are result units. See the Store pricing panel for current charges. Default memory is 512 MB.

### Output example

```json
{"rowType": "opportunity", "noticeId": "53e9119230bc4467884e7227ee2aef52", "url": "https://sam.gov/opp/53e9119230bc4467884e7227ee2aef52/view", "title": "REQUEST FOR QUOTATION NO. N4008426Q1020 PROCUREMENT OF (1) MICRO BUS FOR NAVAL AIR FACILITY ATSUGI TRANSPORATION DEPARMENT, AYASE, JAPAN", "solicitationNumber": "N4008426Q1020", "agencyPath": "DEPT OF DEFENSE > DEPT OF THE NAVY > NAVFAC > NAVFAC PACIFIC CMD > NAVFAC FAR EAST > NAVFACSYSCOM FAR EAST", "agencyHierarchy": [{"id": "100000000", "code": "9700", "name": "DEPT OF DEFENSE"}, {"id": "300000188", "code": "1700", "name": "DEPT OF THE NAVY"}, {"id": "100007016", "code": "NAVFAC", "name": "NAVFAC"}, {"id": "100037985", "code": "NAVFAC PACIFIC CMD", "name": "NAVFAC PACIFIC CMD"}, {"id": "100076582", "code": "NAVFAC FAR EAST", "name": "NAVFAC FAR EAST"}, {"id": "100513870", "code": "N40084", "name": "NAVFACSYSCOM FAR EAST"}], "noticeType": "Combined Synopsis/Solicitation", "noticeTypeCode": "k", "postedAt": "2026-10-30T00:22:20+00:00", "updatedAt": "2026-10-30T00:22:20+00:00", "responseDeadline": "2026-11-09T11:00:00+09:00", "responseTimeZone": "Asia/Seoul", "setAsideCode": null, "setAside": null, "naicsCodes": ["485113"], "pscCodes": ["2310"], "active": true, "description": "*** This combined synopsis/solicitation. Requesting a quote must not be construed as obligating the Government to award a contract or authorizing work to commence and must not serve as a basis for any future claims against the Government. ***(i) This is a combined synopsis/solicitation for commercial products or commercial services prepared in accordance with part 12. This announcement constitutes the only solicitation. Offers are being requested and a separate written solicitation will not be issued. Solicitation number N4008426Q1020 is issued as a Request for Quotation (RFQ) for procurement of a Micro Bus for Naval Air Facility Atsugi in Ayase, Japan. This acquisition is not set-aside for small business concerns. This solicitation incorporates provisions and clauses by reference. The full text of provisions and clauses may be accessed electronically at www.acquisition.gov. See attached 26Q1020_Combined_Synopsis-Soliciation.pdf for combined synopsis/solicitation details.", "pointsOfContact": [{"fullName": "Sheila Wieser", "title": null, "type": "primary", "email": "sheila.a.wieser.civ@us.navy.mil", "phone": null, "fax": null}], "placeOfPerformance": [{"streetAddress": "Ayase, Japan", "streetAddress2": null, "city": null, "state": null, "zip": null, "country": null}], "award": {"number": null, "date": null, "amount": null, "awardeeName": null, "awardeeUei": null, "awardeeCageCode": null}, "attachments": [], "detailsComplete": false}
```

### Billing

Start charges, where configured, apply per GB of memory, rounded up; the default 512 MB run is one start unit.

# Actor input Schema

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

Search opportunities or retrieve complete notices by ID. Search rows exclude attachment lists.

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

Details mode only: 32-character notice IDs or https://sam.gov/opp/ID/view URLs; at most 100.

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

Search terms. Website mode searches notice text; the optional API key route searches titles.

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

Six-digit NAICS codes, OR within this field. At most one value with apiKey.

## `pscCodes` (type: `array`):

Two to four character uppercase PSC codes, OR within this field. At most one value with apiKey.

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

Notice stages, OR within this field: solicitation, presolicitation, sourcesSought, award, specialNotice, combinedSynopsisSolicitation, justification, saleOfSurplusProperty, intentToBundle. At most one value with apiKey.

## `setAside` (type: `string`):

SAM set-aside code, for example SBA. Search only.

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

Numeric SAM organization ID, for example 100000000 for Department of Defense. Website search only; incompatible with apiKey.

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

Publication date: inclusive earliest date as YYYY-MM-DD. Search only; website date boundaries use UTC.

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

Publication date: inclusive latest date as YYYY-MM-DD. Search only; website date boundaries use UTC.

## `responseDeadlineFrom` (type: `string`):

Response deadline date: inclusive earliest date as YYYY-MM-DD. Search only; website date boundaries use UTC.

## `responseDeadlineTo` (type: `string`):

Response deadline date: inclusive latest date as YYYY-MM-DD. Search only; website date boundaries use UTC.

## `activeOnly` (type: `boolean`):

Search active notices only. False includes active and inactive notices. Details mode returns requested notices regardless of status.

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

Maximum rows to save, 1–10000. Website search cannot page beyond 10000 source matches; narrow filters for larger searches.

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

Optional personal SAM.gov public API key for official API search. Leave blank for keyless website search. Requires a posted window of at most 365 days, default last 30 days; supports one code per code filter and no agency ID filter. Details mode uses public website data and does not accept this field.

## Actor input object example

```json
{
  "mode": "search",
  "activeOnly": true,
  "maxResults": 10
}
```

# Actor output Schema

## `results` (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 = {
    "maxResults": 10
};

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

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

```

## MCP server setup

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