DEV Community

gianluca de dominicis
gianluca de dominicis

Posted on

How to get every US federal contract opportunity as JSON, and be told only what changed

Disclosure: I built the tool used in this article (SAM.gov Contract Opportunities & Bid Alerts on Apify).

The US federal government publishes every contract opportunity above a small threshold on SAM.gov: what it wants to buy, which office is buying, the deadline, whether the contract is reserved for small businesses, and the documents you need to bid. It is the largest public list of sales leads in the world, and it is free.

Working with it is another matter. The website's saved searches email you links, one notice at a time. The official API needs a key, has daily quotas, and returns the description and the attachments as further links to follow. If you want "every open IT solicitation due in the next 30 days, with the set-aside, the contracting officer and the files" in one table, you end up writing a small crawler.

This article shows how to get that table with one HTTP call, and how to turn it into a daily alert that only tells you what changed.

One call

curl -X POST "https://api.apify.com/v2/acts/surefeed~sam-gov-scraper/run-sync-get-dataset-items" \
  -H "Authorization: Bearer YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"naicsCodes": ["541512"], "noticeTypes": ["o", "k"], "setAsides": ["SBA"], "maxResultsPerSearch": 10}'
Enter fullscreen mode Exit fullscreen mode

That asks for solicitations (o) and combined synopsis/solicitations (k) under NAICS 541512, computer systems design, reserved for small businesses. The answer is a JSON array, one object per notice, already complete: no second request for the description or the files.

The same in Python (pip install apify-client, version 3 or later) — open IT notices due within 30 days:

from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("surefeed/sam-gov-scraper").call(run_input={
    "naicsCodes": ["541512", "541511"],
    "noticeTypes": ["o", "k", "r"],
    "deadlineWithinDays": 30,
    "maxResultsPerSearch": 25,
})
for n in client.dataset(run.default_dataset_id).iterate_items():
    print(f'{n["daysUntilDeadline"]:>3} days | {n["noticeType"][:30]:30} | '
          f'{(n["department"] or "")[:26]:26} | {len(n["attachments"] or [])} files | {n["title"][:56]}')
Enter fullscreen mode Exit fullscreen mode

Run on November 16, 2026, it returned 24 notices. The first few:

  3 days | Combined Synopsis/Solicitation | DEPT OF DEFENSE            | 1 files | SOLICITATION_SERVICENOW STAFF AUGMENTATION SERVICES
 19 days | Sources Sought                 | COMMERCE, DEPARTMENT OF    | 1 files | RFI NOAA Ship Acquisition Engineering & Correspondence M
  1 days | Combined Synopsis/Solicitation | DEPT OF DEFENSE            | 2 files | Intel Xeon W-3500 Series Tower Workstation
  5 days | Combined Synopsis/Solicitation | INTERIOR, DEPARTMENT OF TH | 8 files | R--IT TSC - DATA ANALYTICS AND SERVICES
  5 days | Combined Synopsis/Solicitation | DEPT OF DEFENSE            | 3 files | 30 RS Mission Planning Software Tool (MPST)
Enter fullscreen mode Exit fullscreen mode

What each notice contains

  • What and who: title, solicitation number, notice type, department, sub-tier and office.
  • Codes: NAICS, product/service code (PSC), set-aside.
  • Dates: posted, last modified, response deadline, and daysUntilDeadline so you can sort by urgency.
  • Where: place of performance.
  • Contacts: the contracting officers published on the notice.
  • The text: the full description as plain text.
  • The files: every attachment with a direct download link, name and size.
  • Awards: on award notices, the winner, its UEI and the amount.

Two things worth knowing before you search

Search by code, not only by keyword. A keyword is matched against the whole notice, and federal solicitations carry pages of standard clauses. When I searched for "cybersecurity" with a deadline filter, most results were spare-parts solicitations that mention cybersecurity rules in their boilerplate. NAICS and PSC codes are what contracting officers themselves use to classify a purchase; start from those and add a keyword to narrow.

"Active" does not mean "open". SAM.gov keeps a notice active until its archive date, which can be long after the response deadline. A search without a deadline filter returns notices whose deadline passed months ago. deadlineWithinDays keeps the ones you can still answer.

From a search to an alert

The part that saves time is not the search, it is not reading the same notices again tomorrow. Two fields do that:

{
  "naicsCodes": ["541512"],
  "noticeTypes": ["o", "k", "r"],
  "updatedWithinDays": 3,
  "onlyNewOrUpdated": true
}
Enter fullscreen mode Exit fullscreen mode

With onlyNewOrUpdated, the first run returns the current matches and every later run returns only notices that are new or were modified since. Each one says which it is (changeType), and when an amendment moved the due date you get deadlineChanged: true and the previous deadline — the change you least want to miss. Schedule it daily and send the result to email or Slack; there is a ready n8n workflow for it (schedule → HTTP request → digest → email).

Three ways people use it

  • Bid alerts for a small contractor: your NAICS codes, your set-aside, your states, every morning.
  • Shaping work early: sources-sought notices (r) and presolicitations (p) are where an agency is still deciding what to buy.
  • Market research: award notices (a) with activeOnly: false show who won what, and for how much, in your category.

Cost

Pay per result, no subscription: $2 per 1,000 notices, with the description, contacts and attachment links included. Notices that did not change are not charged in alert mode. A daily alert that returns ten to twenty notices costs well under a dollar a month. Apify's free plan includes monthly credit, enough to try it.

Limits

The data is SAM.gov's public contract opportunity data; it needs no API key. SAM.gov returns at most 10,000 records per search, so narrow broad codes with a state or a notice type. Always confirm deadlines and amendments on SAM.gov before you bid. The tool is not affiliated with the US government or GSA.

Link: https://apify.com/surefeed/sam-gov-scraper

Top comments (0)