# US Federal Contracts & Grants Extractor (SAM.gov & Grants) (`edenwood.ai/federal-contracts-grants`) Actor

Extract US federal contract awards, open federal grant opportunities, and live SAM.gov solicitations into one clean schema. Works out-of-the-box with ZERO API keys on USAspending.gov & Grants.gov, plus optional SAM.gov v2 support.

- **URL**: https://apify.com/edenwood.ai/federal-contracts-grants.md
- **Developed by:** [EdenWood](https://apify.com/edenwood.ai) (community)
- **Categories:** Business, Lead generation, Automation
- **Features:** Limited permissions
- **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 extracteds

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

## US Federal Contracts & Grants Extractor (USAspending, Grants.gov & SAM.gov)

Extract structured **US federal contract awards**, **open federal grant opportunities**, and **live SAM.gov solicitations** into one clean, unified JSON/CSV dataset.

Built for **GovCon business development teams, proposal agencies, grant writers, compliance researchers, n8n/Make pipelines, and AI agents (MCP)**.

***

### Why Choose This GovCon & Grants Extractor?

- **Works Out-of-the-Box with ZERO API Keys:** Queries official **USAspending.gov** (federal contract & grant awards) and **Grants.gov** (open & forecasted grant opportunities) immediately with zero signup.
- **Optional SAM.gov v2 Solicitations:** Pass your free `samApiKey` (encrypted Apify secret, automatically scrubbed from all logs) with built-in request capping (`maxSamRequests`) and 365-day window clamping to protect your SAM.gov daily quota.
- **Clean Normalized Schema + Zero Duplicate Billing:** Unifies notice numbers, agencies, award dollar amounts (`awardAmountUsd`), NAICS & CFDA codes, posted/close dates (`YYYY-MM-DD`), and direct `.gov` links — deduplicated across overlapping keywords *before* Pay-Per-Event charging.

***

### Pay-Per-Event Pricing

- **`opportunity-extracted`:** `$3.00 / 1,000 records` (`$0.003` per record extracted)
- **`apify-actor-start`:** `$0.00005` platform startup fee

***

### Input Example (Zero API Keys Required)

```json
{
  "sources": ["usaspending", "grants_gov"],
  "usaSpendingAwardCategory": "contracts",
  "keywords": ["cybersecurity", "artificial intelligence"],
  "naicsCodes": ["541512"],
  "agencyFilter": "",
  "minAwardAmountUsd": 100000,
  "maxResultsPerSource": 50,
  "maxTotalResults": 100
}
```

*Optional:* Add `"sam_gov"` to `sources` and supply your free `samApiKey` from SAM.gov Account Details to pull live federal RFP/RFQ solicitations alongside USAspending & Grants.gov.

***

### Output Example

```json
{
  "opportunityId": "usaspending:CONT_AWD_36C10B24F0281",
  "source": "usaspending",
  "recordType": "contract_award",
  "noticeNumber": "36C10B24F0281",
  "title": "CYBERSECURITY TRANSFORMATION PROGRAM",
  "agency": "Department of Veterans Affairs",
  "recipientName": "EXAMPLE SYSTEMS INC",
  "awardAmountUsd": 104626598.48,
  "postedDate": "2026-10-15",
  "closeDate": "2027-10-14",
  "status": "awarded",
  "naicsCode": "541512",
  "cfdaCodes": [],
  "description": "CYBERSECURITY TRANSFORMATION PROGRAM...",
  "url": "https://www.usaspending.gov/award/CONT_AWD_36C10B24F0281"
}
```

***

### Use via Python API or MCP AI Agents

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("edenwood.ai/federal-contracts-grants").call(run_input={
    "sources": ["usaspending", "grants_gov"],
    "keywords": ["cybersecurity"],
    "maxTotalResults": 50
})
records = list(client.dataset(run["defaultDatasetId"]).iterate_items())
```

***

### FAQ

- **Do I need a SAM.gov API key to use this Actor?** No — `usaspending` and `grants_gov` work immediately with zero API keys. `samApiKey` is only needed if you also select `sam_gov`.
- **Is my `samApiKey` safe?** Yes — it is marked `isSecret: true` in Apify's encrypted input storage and automatically redacted from all logs and error messages.
- **Why are contracts and grants separated on USAspending?** USAspending's official API requires separate award-type code sets for contracts (`A–D`) vs. grants (`02–05`); use `usaSpendingAwardCategory` to switch cleanly without HTTP 422 errors.

# Actor input Schema

## `sources` (type: `array`):

Select which official US federal APIs to query. 'usaspending' and 'grants_gov' work with ZERO API keys; 'sam_gov' requires your free samApiKey.

## `usaSpendingAwardCategory` (type: `string`):

Choose whether USAspending queries federal contracts (A-D) or federal grants (02-05).

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

Keywords to search across contract awards, grants, or SAM.gov solicitation titles.

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

Start of date window in YYYY-MM-DD format. Leave blank to default to 30 days ago.

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

End of date window in YYYY-MM-DD format. Leave blank to default to today (UTC).

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

6-digit NAICS industry codes (e.g. '541511', '541512') for USAspending and SAM.gov.

## `agencyFilter` (type: `string`):

Case-insensitive substring matched against awarding agency name or code (e.g. 'Defense', 'DHS', 'HHS').

## `minAwardAmountUsd` (type: `integer`):

Filter USAspending awards to at least this dollar amount.

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

Required only when 'sam_gov' is included in sources. Stored encrypted as a secret and scrubbed from all logs.

## `maxSamRequests` (type: `integer`):

Safety cap protecting free SAM.gov public API keys (10 requests/day quota).

## `maxResultsPerSource` (type: `integer`):

Maximum post-filter deduplicated records per source.

## `maxTotalResults` (type: `integer`):

Hard ceiling on total records extracted across all sources.

## Actor input object example

```json
{
  "sources": [
    "usaspending",
    "grants_gov"
  ],
  "usaSpendingAwardCategory": "contracts",
  "keywords": [
    "cybersecurity",
    "artificial intelligence"
  ],
  "naicsCodes": [],
  "agencyFilter": "",
  "maxSamRequests": 5,
  "maxResultsPerSource": 50,
  "maxTotalResults": 100
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

## `summary` (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 = {
    "sources": [
        "usaspending",
        "grants_gov"
    ],
    "keywords": [
        "cybersecurity",
        "artificial intelligence"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("edenwood.ai/federal-contracts-grants").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 = {
    "sources": [
        "usaspending",
        "grants_gov",
    ],
    "keywords": [
        "cybersecurity",
        "artificial intelligence",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("edenwood.ai/federal-contracts-grants").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 '{
  "sources": [
    "usaspending",
    "grants_gov"
  ],
  "keywords": [
    "cybersecurity",
    "artificial intelligence"
  ]
}' |
apify call edenwood.ai/federal-contracts-grants --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,edenwood.ai/federal-contracts-grants"
        }
    }
}
```

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/KuzMy7Ed58DMnrpRE/builds/OPbogMs3TiDGWm2Ej/openapi.json
