neushua guides

SAM.gov Contract Opportunities API: export new federal bids to CSV, with or without an API key

By neushua. Tested on 1 December 2026.

SAM.gov is where US federal agencies post contract opportunities: solicitations, sources-sought notices, presolicitations and award notices. If you want them in a spreadsheet, a database or a daily alert, there are two official routes and one shortcut:

  1. The Get Opportunities API. It needs a SAM.gov account and an API key, and it has a daily request quota.
  2. The public daily extract. This is one CSV file of every active notice. It needs no key and no login.
  3. A ready-made scheduled job that reads route 2 for you. We built one; it's covered at the end, with its price.

Routes 1 and 2 are free. Everything below was checked against the live sources on 1 December 2026.

Route 1: the Get Opportunities API (needs a key)

Endpoint: GET https://api.sam.gov/opportunities/v2/search (GSA documentation).

To use it:

  1. Create a SAM.gov account, sign in, and open Account Details. Request a Public API Key there. You have to re-enter your password to see it.
  2. Send api_key, postedFrom and postedTo. The two dates are mandatory, use the format MM/dd/yyyy, and can be at most one year apart.
  3. Set limit=1000. The default is 1, so a request without limit returns a single notice.
curl "https://api.sam.gov/opportunities/v2/search?api_key=$SAM_API_KEY&postedFrom=11/24/2026&postedTo=11/30/2026&ncode=541512&limit=1000&offset=0"

What trips people up:

The API is the right choice when you need a notice minutes after it is posted, or when you need archived notices.

Route 2: the public daily extract (no key)

SAM.gov's Data Services publishes the whole list of active contract opportunities as one public CSV, also listed on data.gov:

https://sam.gov/api/prod/fileextractservices/v1/api/download/Contract%20Opportunities/datagov/ContractOpportunitiesFullCSV.csv?privacy=Public

What we saw on 1 December 2026:

Python: the last N days of notices for your NAICS code, as CSV

"""Stream SAM.gov's public Contract Opportunities extract and keep recent notices.
No API key. The file is sorted newest PostedDate first, so we stop early.
Only organisation-level columns are written (no contact names, emails or phones)."""
import csv, datetime as dt, sys
import requests

URL = ("https://sam.gov/api/prod/fileextractservices/v1/api/download/"
       "Contract%20Opportunities/datagov/ContractOpportunitiesFullCSV.csv?privacy=Public")
DAYS = int(sys.argv[1]) if len(sys.argv) > 1 else 3
NAICS_PREFIX = sys.argv[2] if len(sys.argv) > 2 else ""          # e.g. 5415
KEEP = ["NoticeId", "Title", "Sol#", "Department/Ind.Agency", "Sub-Tier", "Office",
        "PostedDate", "Type", "SetASideCode", "ResponseDeadLine", "NaicsCode",
        "ClassificationCode", "PopState", "Link"]

def lines(resp):
    for raw in resp.iter_lines():          # mixed UTF-8 / Windows-1252: decode per line
        try:
            yield raw.decode("utf-8")
        except UnicodeDecodeError:
            yield raw.decode("cp1252", errors="replace")

cutoff = (dt.datetime.now(dt.timezone.utc).date() - dt.timedelta(days=DAYS)).isoformat()
with requests.get(URL, stream=True, timeout=120,
                  headers={"User-Agent": "sam-extract-example/1.0"}) as resp:
    resp.raise_for_status()
    reader = csv.DictReader(lines(resp))
    out = csv.DictWriter(sys.stdout, fieldnames=KEEP, extrasaction="ignore")
    out.writeheader()
    for row in reader:
        posted = (row.get("PostedDate") or "")[:10]
        if posted and posted < cutoff:
            break                          # older than the window: stop downloading
        if NAICS_PREFIX and not (row.get("NaicsCode") or "").startswith(NAICS_PREFIX):
            continue
        out.writerow(row)

Run it with python3 sam_extract_latest.py 3 5415 > it-notices.csv. On 1 December 2026 it returned 19 notices in NAICS 5415 (computer systems design) posted on 29 and 30 November, 11 of them sources-sought notices. It finished in under a second.

To turn this into a daily alert, you still have to do three things yourself: run it on a schedule after about 05:00 UTC, remember which NoticeIds you have already seen, and send the new ones somewhere (email, Slack or a sheet).

Route 3: the same extract as a scheduled Apify Actor (paid, by us)

Disclosure: we (neushua) built and maintain this one. It does route 2 for you: it streams the extract, applies your filters, remembers what it already sent you, and leaves out the contact columns and the free-text description, which often repeats contact details. It runs on Apify, so schedules, webhooks and the Google Sheets, Slack, Zapier, Make and n8n integrations come with it.

SAM.gov Federal Contract Opportunities Monitor on Apify

Example input (open IT-services bids set aside for small businesses, posted in the last 7 days, and only new ones on later runs):

{
  "daysBack": 7,
  "noticeTypes": ["Solicitation", "Combined Synopsis/Solicitation"],
  "naicsCodes": ["5415"],
  "setAsideCodes": ["SBA"],
  "openOnly": true,
  "onlyNew": true,
  "maxItems": 50
}

A real output row from a run on 29 November 2026 (shortened):

{
  "noticeId": "322338355ae84c6ebabbea545495ac0d",
  "title": "S--Landscaping services for Eureka CA WFO",
  "solicitationNumber": "1305M327Q0051",
  "noticeType": "Solicitation",
  "department": "COMMERCE, DEPARTMENT OF",
  "subTier": "NATIONAL OCEANIC AND ATMOSPHERIC ADMINISTRATION",
  "postedDate": "2026-11-27",
  "responseDeadline": "2026-11-30T13:00:00-08:00",
  "setAsideCode": "SBA",
  "naicsCode": "561730",
  "pscCode": "S208",
  "placeOfPerformanceState": "CA",
  "samUrl": "https://sam.gov/workspace/contract/opp/322338355ae84c6ebabbea545495ac0d/view"
}

In our tests on 29 November 2026, a 7-day unfiltered run returned 4,331 notices in about 7 seconds, because it read only 14 MB of the file. A run filtered to NAICS 5415 and 5416, open bids only, returned 59 notices. The next "only new" run returned 0.

Price: $0.005 per run plus $0.002 per notice returned ($2 per 1,000), and no monthly fee. A daily watch that returns 20 new notices costs $0.045 that day. A day with nothing new costs $0.005. Apify's free plan includes $5 of usage a month.

Honest limits: it is up to a day behind, because SAM.gov rebuilds the extract once a day. It covers active notices only, with no attachments and no description text. Everything in it is free on sam.gov. What you pay for is the filtering, the scheduling and the "only new" memory. If you need minute-level alerts, use SAM.gov's own saved searches or route 1.

Which route should you use?

You need Use
A one-off export of what is open now Route 2 (the extract), free
Notices minutes after posting, or archived notices Route 1 (the API), with a key
A daily "new bids for my NAICS codes" list without running a server Route 2 on your own cron, or route 3

FAQ

Is there a SAM.gov API without a key? Not for the Get Opportunities API. The public extract above needs no key and has no quota.

How often is SAM.gov data updated? Active notices refresh daily, and archived notices weekly, according to GSA. The public extract was rebuilt at about 04:30 UTC every day we checked.

Why does the same solicitation number appear twice? Amendments and follow-on notices get a new notice ID under the same Sol#. Group by solicitation number if you want one row per opportunity.

Independent guide. Not affiliated with GSA or SAM.gov. Figures are from SAM.gov's public files on the dates shown.