If you have ever built a GovCon opportunity tracker, a federal bid alert bot, or an AI sales agent for government contractors, you know the pain of SAM.gov's official developer API:

  1. You have to create a Login.gov account, register a public API key, and remember to rotate it every 90 days.
  2. Search results return stripped summaries — leaving out structured Contracting Officer emails, phone numbers, and direct RFP PDF attachment links unless you chain extra undocumented endpoints.
  3. Passing repeated query parameters like ?naics=541511&naics=541512 silently drops the second NAICS code!

While researching the US federal procurement pipeline (currently 44,000+ active contract opportunities), I mapped out SAM.gov's public, zero-API-key JSON architecture and packaged it into a 512 MB Pay-Per-Event Apify Actor (SAM.gov Federal Contracts & RFPs Scraper). Here are the four technical gotchas I discovered along the way.

1. The Accept Header Trap (HTTP 406)

SAM.gov's public search API lives at:

https://sam.gov/api/prod/sgs/v1/search/?index=opp&mode=search&responseType=json&is_active=true 

If you send a plain Accept: application/json header, SAM.gov responds with HTTP 406 Not Acceptable. The endpoint serves HAL-formatted JSON, so you must send:

headers = { "Accept": "application/hal+json, application/json, text/plain, */*", "Referer": "https://sam.gov/search/", } 

Once that header is in place, it returns clean paginated JSON with zero cookies, zero headless Chrome, and zero API keys.

2. Multi-Value Filters Must Be Comma-Joined (Not Repeated)

A subtle bug in many GovCon scrapers is passing multiple NAICS or set-aside codes as repeated query parameters (naics=541511&naics=541512). On SAM.gov's search backend, that silently evaluates only the first parameter:

  • naics=541511&naics=541512 -> 513 matches (dropped 541512!)
  • naics=541511,541512 -> 786 matches (proper OR union!)
  • notice_type=o,k -> 22,562 active solicitations + combined synopses
  • set_aside=SBA,8A -> 11,443 Small Business & 8(a) set-asides

Joining filter lists with commas (",".join(codes)) fixes silent data loss immediately.

3. Enriching Contracting Officer Emails & Direct RFP PDF Links

The search endpoint gives you the opportunity ID (_id), solicitation number, agency hierarchy, and deadline — but the real GovCon value sits in two companion endpoints:

  1. Opportunity Detail (v2): https://sam.gov/api/prod/opps/v2/opportunities/{opp_id}
    • Exposes data2.pointOfContact[] (Contracting Officer name, email, and phone), exact naics[], classificationCode (PSC), setAside, placeOfPerformance, and full HTML scope description.
  2. Attachments & External Links (v3): https://sam.gov/api/prod/opps/v3/opportunities/{opp_id}/resources
    • Lists every attached RFP PDF/DOCX/XLSX (resourceId maps cleanly to https://sam.gov/api/prod/opps/v3/opportunities/resources/files/{resource_id}/download) plus external DoD/Navy portal URLs like piee.eb.mil and neco.navy.mil.

4. Turning Federal RFPs into an Autonomous AI Agent Pipeline (MCP)

Because the entire pipeline is pure HTTP JSON (running in ~6 seconds on 512 MB RAM), it works cleanly inside automated n8n / Make workflows or directly inside Claude Desktop / Cursor via the Apify MCP Server (https://mcp.apify.com):

{ "keywords": "cybersecurity", "naicsCodes": ["541511", "541512", "541519"], "setAsideCodes": ["SBA", "8A"], "noticeTypes": ["o", "k"], "activeOnly": true, "maxResults": 25, "includeFullDetailsAndContacts": true } 

Every record includes computed days_until_deadline and deadline_urgency (critical_lt_3d, urgent_lt_7d, soon_lt_14d, normal) so your agent or Slack bot can prioritize urgent RFPs before the response window closes.

Try It Live (Zero API Key, Pay-Per-Event)