# Is there a SAM.gov API WebSocket for live contract data? No official one: every SAM.gov and USAspending API is REST and has to be polled within daily limits. samgovapi.io runs a WebSocket at wss://stream.samgovapi.io/v1/stream that pushes a JSON event whenever a load creates or changes an opportunity, award, exclusion or entity, filtered by NAICS, agency, state and set-aside. Every plan connects, the free one included, with events 5 minutes late.Checked on 2026-11-15.Official source: [open.gsa.gov API catalog](https://open.gsa.gov/api/) | URL | wss://stream.samgovapi.io/v1/stream | | --- | --- | | Plans | All; Free 5 min late | | Filters | types, naics, agency, state, set_aside | | Replay | 14 days with after= | ## The answer in detail Polling SAM.gov for changes costs requests you may not have: a personal key with no role gets 10 a day, and comparing yesterday's results with today's is work your code has to do. A change stream does the comparison once, on the server, and sends only what changed.Here every loader hashes each row and writes only rows whose content changed; a database trigger turns each written row into an event. The gateway sends it to every connection whose filters match, in order, with a cursor. Reconnect with after=<cursor> and the last 14 days replay before live events resume, so a deploy or a dropped laptop connection loses nothing.Events are pushed the moment a load commits a change. The sources themselves refresh on a schedule: opportunities once a day (about 05:15 UTC), exclusions daily (about 05:45 UTC), awards twice a day (07:00 and 15:00 UTC), entities monthly. So the stream removes polling, not the source's own delay.Event types: opportunity.created, .updated and .closed; award.created and .updated; exclusion.created, .updated and .removed; entity.created, .updated and .removed (opt in, monthly bursts); and, on Scale, the account's own alert firings. Individuals are never streamed. Delivered events cost 1 credit per 100, the same rate as search rows; opening a connection costs nothing.Every plan streams. Free: opportunities and exclusions, 5 minutes late, 1 connection. Developer (2) and Pro (3 connections): every record change in real time. Scale: also your alert firings, 5 connections. ## How the options compare | Option | Price | Access and limits | Coverage and history | Best for | Checked | | --- | --- | --- | --- | --- | --- | | [SAM.gov APIs (official)](https://open.gsa.gov/api/entity-api/) | Free | 10 requests a day with no SAM.gov role, 1,000 with a role or a non-federal system account; keys expire every 90 days | The live, authoritative record: entities, opportunities, exclusions, contract awards, hierarchy, subawards | Anyone who needs the official record itself, at low volume | 2026-11-12 | | [USAspending API (official)](https://api.usaspending.gov/docs/endpoints) | Free, no key | No key and no published daily cap | Prime awards and subawards back to FY2001; no SAM.gov registration status or expiry | Award and spending history | 2026-11-12 | | [samgovapi.io](https://samgovapi.io/pricing) | Free (10,000 credits a month, no card); Developer $49/mo, Pro $149/mo, Scale $499/mo | 120 to 1,200 requests a minute by plan, no daily cap; REST, MCP and keyless MCP search | 881,370 entities (1 Nov 2026 extract), 74,420 notices, 169,191 exclusions, 114,954 awards since 1 Oct 2026 | Developers and AI agents who want entities, bids and exclusions joined in one API | 2026-11-15 | ## Where samgovapi.io is the weaker choice - The free plan streams opportunities and exclusions 5 minutes late on one connection; real time, awards and entities start on Developer, and alert firings on the stream need Scale ($499 a month). - Events follow the source refresh: a notice posted on SAM.gov this morning arrives with the next nightly file, not the minute it is posted. ## Try it Open a connection for new and changed notices and awards in NAICS 5415, and resume from the last cursor after a disconnect. ``` // npm install ws import WebSocket from "ws"; let cursor = null; // persist this to resume after a restart let backoff = 1; function connect() { const params = new URLSearchParams({ types: "opportunity,award", naics: "5415" }); if (cursor) params.set("after", cursor); const ws = new WebSocket(`wss://stream.samgovapi.io/v1/stream?${params}`, { headers: { Authorization: `Bearer ${process.env.SAMGOVAPI_API_KEY}` }, }); let idle; const touch = () => { clearTimeout(idle); idle = setTimeout(() => ws.terminate(), 60_000); }; ws.on("open", () => { backoff = 1; touch(); }); ws.on("message", (raw) => { touch(); const msg = JSON.parse(raw); if (msg.type === "error") return console.error(msg.code, msg.message); if (msg.type === "connected" || msg.type === "heartbeat") return; console.log(msg.type, msg.key, msg.data.title ?? msg.data.recipient_name ?? msg.data.name); if (msg.cursor) cursor = msg.cursor; }); ws.on("close", (code) => { clearTimeout(idle); if ([4401, 4402, 4403].includes(code)) return; // fix the key or plan first setTimeout(connect, backoff * 1000); backoff = Math.min(backoff * 2, 60); }); ws.on("error", () => {}); } connect(); # pip install websockets import asyncio, json, os import websockets API_KEY = os.environ["SAMGOVAPI_API_KEY"] cursor = None # persist this to resume after a restart async def main(): global cursor backoff = 1 while True: url = "wss://stream.samgovapi.io/v1/stream?types=opportunity,award&naics=5415" if cursor: url += f"&after={cursor}" try: async with websockets.connect( url, additional_headers={"Authorization": f"Bearer {API_KEY}"}, ping_interval=20 ) as ws: backoff = 1 while True: msg = json.loads(await asyncio.wait_for(ws.recv(), timeout=60)) if msg["type"] == "error": print(msg["code"], msg["message"]) elif msg["type"] not in ("connected", "heartbeat"): print(msg["type"], msg["key"]) cursor = msg.get("cursor") or cursor except websockets.ConnectionClosed as e: if e.rcvd and e.rcvd.code in (4401, 4402, 4403): raise # fix the key or plan first except (OSError, asyncio.TimeoutError): pass await asyncio.sleep(backoff) backoff = min(backoff * 2, 60) asyncio.run(main()) ``` ## Questions Does SAM.gov offer webhooks or push notifications?Saved searches on SAM.gov send email. Its APIs have no push delivery; a client has to poll them.Can I use the WebSocket from a browser?It accepts an auth message as the first frame, so browsers can connect, but keep the key on a server and relay events to the page.How do I know the stream is up?https://stream.samgovapi.io/healthz returns ok, the open connection count and the time of the last event. ## Related - [WebSocket stream docs](https://samgovapi.io/docs/websocket) - [Webhooks](https://samgovapi.io/docs/webhooks) - [API docs](https://samgovapi.io/docs) - [Pricing](https://samgovapi.io/pricing) - [Answers](https://samgovapi.io/answers)Updated 2026-11-15. Sources checked 2026-11-15.Independent. Not affiliated with, endorsed by or sponsored by GSA, SAM.gov or any U.S. government agency. Registering in SAM.gov is free at sam.gov.

---

HTML version: https://samgovapi.io/answers/sam-gov-api-websocket . Markdown: https://samgovapi.io/answers/sam-gov-api-websocket.md

Independent. Not affiliated with, endorsed by or sponsored by GSA, SAM.gov or any U.S. government agency. Registering in SAM.gov is free at sam.gov.

Get a free API key: https://samgovapi.io/sign-up?ref=ai-claudebot
