# SAM.gov Amendment Diff & USAspending Incumbent Recompete Radar (`duypham/samgov-recompete-delta`) Actor

Stateful U.S. federal GovCon intelligence Actor that tracks SAM.gov solicitation modifications (surviving the 10-req/day basic quota via limit=1000 and line-by-line Bulk CSV Fallback) and cross-walks against keyless USAspending.gov expiring awards to surface incumbent contractors.

- **URL**: https://apify.com/duypham/samgov-recompete-delta.md
- **Developed by:** [Duy Phạm](https://apify.com/duypham) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## 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 Amendment Diff & USAspending Incumbent Recompete Radar (`samgov-recompete-delta`)

Stateful U.S. Federal GovCon capture & recompete intelligence Actor for **n8n**, **Make**, and **Clay** pipelines.

### Key Capabilities

1. **Survives the 10-Req/Day Basic SAM.gov Quota:** Uses `limit=1000` narrow delta windows (`MM/dd/yyyy`) requiring only 1–2 API calls per run, plus a keyless `BULK_EXTRACT_FALLBACK` mode streamed line-by-line within `<= 180 MB RAM`.
2. **True Solicitation Amendment Diffing (`AMENDMENT_DIFF`):** Keys state by `(agencyCode, solicitationNumber)` rather than `noticeId` alone, catching deadline extensions, set-aside changes, and new SOW attachments even when `modNumber` is `null`.
3. **Keyless USAspending.gov Incumbent Cross-Walk:** Automatically matches new/modified solicitations against expiring federal contracts (`limit: 100`) to attach `incumbentRecipientName`, `recipientUei`, and `historicalObligatedAmount` while excluding individual sole proprietors.

### Transparent Pay-Per-Event (PPE) Pricing (`HYBRID_TIERED`)

- `actor-start`: **$0.005** per valid run (`$0.00` on `INPUT_VALIDATION_ERROR` or `dryRun: true`)
- `sam-amendment-diff-emitted`: **$0.004** per net-new or modified SAM.gov solicitation (without USAspending incumbent match)
- `sam-recompete-signal-emitted`: **$0.010** per net-new or modified SAM.gov solicitation enriched with expiring USAspending incumbent contract metadata (never double-charged with `sam-amendment-diff-emitted`)

### Data Provenance, Privacy-by-Design & Removal Requests (SLA <= 48h)

This Actor processes strictly public-sector institutional disclosures from official government open-data endpoints (`17 U.S.C. § 105`, `EU Commission Decision 2011/833/EU`, `UK Open Government Licence v3.0`). By default, built-in privacy filters (`redactPersonalContacts: true`, `redactResidentialStreets: true`, and individual recipient exclusions) strip personal contact emails and residential street addresses at parse time. If an organization or individual wishes to request the suppression of a specific CIK, OCID, Publication Number, Notice ID, or UEI from normalized outputs, please open an issue labeled `privacy-takedown` on the linked repository or contact the publisher via Apify Store. Valid suppression requests are processed within **48 hours**.

# Actor input Schema

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

Your personal or system api.sam.gov key used to fetch live incremental contract opportunities (limit=1000 per page to stay well within the 10-req/day basic quota). Not required when ingestionMode is set to BULK_EXTRACT_FALLBACK.

## `ingestionMode` (type: `string`):

Chooses between real-time REST pagination (API_INCREMENTAL, requires samApiKey) and keyless public Contract Opportunities data extracts (BULK_EXTRACT_FALLBACK). Both modes feed the exact same stateful diff engine and PPE billing rules.

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

Optional list of 6-digit North American Industry Classification System codes (e.g., \['541511', '541512']) to filter federal solicitations and incumbent contracts.

## `recompeteWindowDays` (type: `integer`):

Forward-looking window (in days) used when querying api.usaspending.gov for expiring incumbent federal awards (End Date). Identifies upcoming recompetes 3-12 months before replacement RFPs close.

## `includeUsaSpendingCrosswalk` (type: `boolean`):

Automatically cross-walks each new or modified SAM.gov solicitation against keyless USAspending.gov v2 endpoints to attach incumbent_recipient_name, recipient_uei, and historical_obligated_amount.

## `lookbackHours` (type: `integer`):

Lookback window (in hours) for scanning newly posted solicitations and solicitation amendments on SAM.gov.

## `deltaStateMode` (type: `string`):

Controls whether the Actor emits only newly created or modified records since the last checkpoint (stateful_delta_only) or re-emits all matching records in the lookback window (full_snapshot).

## `customStateKey` (type: `string`):

Optional identifier to isolate the stateful checkpoint cursor in the apify-delta-fleet-state Named Key-Value Store when running multiple parallel n8n/Make workflows.

## `maxDeltaRecords` (type: `integer`):

Hard ceiling on the number of delta records pushed and billed per run to strictly cap your Pay-Per-Event spend.

## `dryRun` (type: `boolean`):

Validates upstream connectivity and counts how many net-new delta records match your filters without mutating your saved checkpoint cursor. Incurs $0.00 in Pay-Per-Event charges.

## Actor input object example

```json
{
  "ingestionMode": "API_INCREMENTAL",
  "naicsCodes": [],
  "recompeteWindowDays": 180,
  "includeUsaSpendingCrosswalk": true,
  "lookbackHours": 24,
  "deltaStateMode": "stateful_delta_only",
  "customStateKey": "",
  "maxDeltaRecords": 100,
  "dryRun": false
}
```

# Actor output Schema

## `deltaDataset` (type: `string`):

No description

## `runSummary` (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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("duypham/samgov-recompete-delta").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("duypham/samgov-recompete-delta").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 '{}' |
apify call duypham/samgov-recompete-delta --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,duypham/samgov-recompete-delta"
        }
    }
}
```

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/4rd11NRfb3FoxxGZh/builds/LLWcFUMFKgHBDYhMI/openapi.json
