# USAspending Expiring Contracts Finder (`flamelit_constellation/usaspending-expiring-contracts-finder`) Actor

Unofficial tool, not affiliated with U.S. Treasury/USAspending.gov. Find US federal contracts whose period of performance ends within your chosen window, filtered by NAICS, amount and PSC/NAICS code keywords.

- **URL**: https://apify.com/flamelit_constellation/usaspending-expiring-contracts-finder.md
- **Developed by:** [Two Five Labs](https://apify.com/flamelit_constellation) (community)
- **Categories:** Business, Lead generation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 new or amended records

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

## USAspending Expiring Contracts Finder

**Not affiliated with or endorsed by the U.S. Department of the Treasury or USAspending.gov.** This is an independent tool from Two Five Labs that reads publicly available data. No government seals or logos are used.

### What it does

Requests a USAspending.gov award download for contracts with a transaction in your look-back period and at or above your minimum amount. It waits for the file, then keeps the contracts whose current period-of-performance end date falls between today and `monthsAhead` months from now. Only new or changed contracts are output on later runs.

Useful for spotting possible recompetes. It does not predict whether a contract will be re-competed, extended or ended.

### Who it's for

Federal contractors and capture teams planning future bids.

### Input

| Field | Description |
|---|---|
| `monthsAhead` | integer, default 6. End-date window: today to this many months ahead. |
| `actionLookbackMonths` | integer, default 1. Only contracts with a transaction in this many past months. |
| `minAmount` | integer, default 10,000,000 (USD). Skips smaller awards; lower values make the download larger and slower. |
| `naics` | list. NAICS codes, prefixes allowed (e.g. `5415`). |
| `keywords` | list. Matches the record title, i.e. the standard PSC/NAICS code descriptions (not free text). |
| `includeDescriptions` | boolean, default false. Off: no free-text description is output. On: the description is added in `extra.description`, trimmed to remove contact names (marked `[contact details removed]`). Leave it off unless you need it. |
| `maxPolls` / `pollIntervalMs` | default 60 / 5000. How many times, and how often (in ms, at least 5000), to check whether the download is ready. The wait between checks starts at 5 seconds and grows 1.5x per check, up to 30 seconds. |
| `maxSpendUsd`, `emitUnchanged`, `stateStoreName` | see "How runs work". |

Contract award types only (A, B, C, D).

No API key is needed for this source.

### Run it via API

```bash
curl -X POST "https://api.apify.com/v2/acts/flamelit_constellation~usaspending-expiring-contracts-finder/runs?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"maxSpendUsd": 1.0}'
```

Use your own Apify token.

### How runs work

- **First run:** returns every matching record in the look-back window, all marked `changeType: "new"`. A first run can find many contracts, so set `maxSpendUsd` and the filters to fit your budget. Records the cap stops are output on later runs.
- **Later runs:** return only records that are new, or whose content changed since they were last seen (`amended`). The actor keeps a content hash per record in a key-value store. A second run over the same data outputs nothing.
- `stateStoreName`: give each saved search its own name so each one tracks its own history.
- `emitUnchanged: true` also outputs unchanged records (`changeType: "same"`), which are never charged.
- **Spend cap:** `maxSpendUsd` (default 1.0) is a hard cap. When it is reached, the actor stops charging and stops output. Records not yet output are kept for the next run.
- **Errors and rate limits:** network errors, HTTP 429 and 5xx responses are retried up to 3 times with backoff. `Retry-After` is honoured in both its seconds and date forms; if the source asks for a wait longer than 2 minutes, the run stops instead of waiting.

### Output

Tender-style record: `id, source ("usaspending"), title (standard PSC/NAICS code descriptions plus the award ID, never free text), buyer (agency / sub-agency), naics[], region (place-of-performance state), value, currency ("USD"), posted (period start), deadline (current period-of-performance end), url, changeType, extra{awardId, incumbent, periodOfPerformanceEnd, excludedIndividual, attribution, description (only with `includeDescriptions`, max 1,000 chars)}`.

Excerpt from a live run (descriptions off):

```json
{
 "id": "CONT_AWD_49100422F0033_4900_GS00F354CA_4732",
 "source": "usaspending",
 "title": "SPECIAL STUDIES/ANALYSIS- SCIENTIFIC DATA — ADMINISTRATIVE MANAGEMENT AND GENERAL MANAGEMENT CONSULTING SERVICES (49100422F0033)",
 "buyer": "National Science Foundation / National Science Foundation",
 "naics": [
  "541611"
 ],
 "region": "NC",
 "value": 12641467,
 "currency": "USD",
 "posted": "2022-04-01T00:00:00.000Z",
 "deadline": "2027-03-31T00:00:00.000Z",
 "url": "https://www.usaspending.gov/award/CONT_AWD_49100422F0033_4900_GS00F354CA_4732/",
 "changeType": "new",
 "extra": {
  "awardId": "49100422F0033",
  "incumbent": "RESEARCH TRIANGLE INSTITUTE",
  "periodOfPerformanceEnd": "2027-03-31",
  "attribution": "Source: USAspending.gov (U.S. Department of the Treasury), https://www.usaspending.gov. Data filtered and normalized by this actor."
 }
}
```

**Sole proprietors excluded:** awards that USAspending flags as sole proprietorships are dropped entirely. When that flag is missing, a fallback name rule is used, and it can miss some individuals.

**Descriptions:** award descriptions are off by default. If you turn them on: Contact names after role labels are removed; other names in free text may remain. Long descriptions may be shortened, sometimes before any contact details, to remove contact names.

### Pricing

Pay per event: one `run-start` charge per run and one `new-item` charge per new or amended record output. Current prices are shown on this actor's Apify Store page.

### Limits

- Requests are spaced at least 1.1 seconds apart, and download status checks are at least 5 seconds apart. This is far under the contributor-stated limit of 1,000 requests per 300 seconds. The default run used 3–5 requests, including 1–3 download status checks.
- With the default inputs, the download is small and a run normally finishes well within the time limit below.
- Larger custom scopes can take several minutes. If the download is not ready after 60 checks (about 29 minutes of waiting), the run stops with an error. To avoid this, narrow the scope: shorten `actionLookbackMonths`, set `naics`, or raise `minAmount`.
- Default memory is 2048 MB. You can change it in the run options.

### Data source and terms

- Source: USAspending.gov (U.S. Department of the Treasury), `https://www.usaspending.gov`. Data filtered and normalized by this actor. Each record carries this in `extra.attribution`.
- No formal API terms-of-use page was found. Endpoints "do not currently require any authorization".
- **Not affiliated with or endorsed by the U.S. Department of the Treasury or USAspending.gov.**

### FAQ

**Does it return every record?** The first run returns everything matching. After that it returns only new or changed records.
**How often should I run it?** Daily is enough.
**Can I cap spend?** Yes. `maxSpendUsd` is a hard cap, and records it stops are output on the next run.
**What do keywords match?** The title, which is built from standard PSC/NAICS code descriptions plus the award ID. Use words from those code titles, e.g. "management consulting".
**Does it need a key?** No.

### Support

Questions or problems: please use the Issues tab on this actor's Apify page first.
Publisher: Two Five Labs, contact `twofivelabs@gmail.com`.

Requests to the source identify themselves with a contact address: `flamelit-constellation-actors/0.1 (+mailto:twofivelabs@gmail.com)`.

# Actor input Schema

## `includeDescriptions` (type: `boolean`):

Off by default. If on, the award description is included in extra.description (the title is always built from the PSC and NAICS code descriptions, never from free text), trimmed at the first contact detail (role label, initials, name pattern) with "\[contact details removed]". Descriptions are free text written by buyers and may still contain personal names that the trimming misses; leave off unless you need them.

## `monthsAhead` (type: `integer`):

Include contracts whose current period-of-performance end date is between today and this many months ahead.

## `actionLookbackMonths` (type: `integer`):

Only consider contracts with a transaction in this many past months (keeps the download to active awards).

## `minAmount` (type: `integer`):

Skip awards below this amount. Lower values make the USAspending download larger and slower.

## `naics` (type: `array`):

Only include awards with these NAICS codes (prefixes allowed, e.g. 5415).

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

Only include awards whose title (PSC / NAICS description) contains at least one of these words.

## `maxPolls` (type: `integer`):

How many times to check whether USAspending has finished preparing the download before giving up. Checks start 5 s apart and back off by 1.5x up to 30 s apart (5, 7.5, 11.25, 16.9, 25.3, then 30 s). With the default of 60 checks the actor waits up to about 28.6 minutes (1,716 s) in total.

## `pollIntervalMs` (type: `integer`):

Wait before the first status check, in ms (minimum 5000). Later checks back off by 1.5x, up to 30 s apart.

## `maxSpendUsd` (type: `number`):

Hard spending cap for this run, in US dollars. The actor stops charging and stops adding results once this amount is reached. Unsent items are kept for the next run.

## `emitUnchanged` (type: `boolean`):

If on, items already seen in earlier runs (changeType "same") are also output. Off by default, so you only get new and amended items. Unchanged items are never charged.

## `stateStoreName` (type: `string`):

Optional name of the key-value store that remembers what earlier runs saw. Use a different name per saved search so each search tracks its own new/amended items. Leave empty to use the run's default store.

## `fixturePath` (type: `string`):

Testing only. Path to a local file to replay instead of calling the live source. Leave empty for normal use.

## Actor input object example

```json
{
  "includeDescriptions": false,
  "monthsAhead": 6,
  "actionLookbackMonths": 1,
  "minAmount": 10000000,
  "naics": [],
  "keywords": [],
  "maxPolls": 60,
  "pollIntervalMs": 5000,
  "maxSpendUsd": 1,
  "emitUnchanged": false
}
```

# Actor output Schema

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

Tender records (new and amended only)

# 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 = {
    "actionLookbackMonths": 1,
    "minAmount": 10000000
};

// Run the Actor and wait for it to finish
const run = await client.actor("flamelit_constellation/usaspending-expiring-contracts-finder").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 = {
    "actionLookbackMonths": 1,
    "minAmount": 10000000,
}

# Run the Actor and wait for it to finish
run = client.actor("flamelit_constellation/usaspending-expiring-contracts-finder").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 '{
  "actionLookbackMonths": 1,
  "minAmount": 10000000
}' |
apify call flamelit_constellation/usaspending-expiring-contracts-finder --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,flamelit_constellation/usaspending-expiring-contracts-finder"
        }
    }
}
```

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/K0Lqgr9m9GtPdYPg4/builds/VZMLAPn1UMuCChy5q/openapi.json
