# How do I get SAM.gov data in JavaScript or Node.js? Use fetch from a server: Node.js 18+, Deno, Bun or a Next.js route handler, with the key in an environment variable and an Authorization: Bearer header. Never call the API from browser code with your key; proxy through your server and cache results, since registrations change monthly and bids nightly. The official SAM.gov API puts the key in the URL, which makes browser use impossible to secure.Checked on 2026-11-15.Source: [OpenAPI document](https://samgovapi.io/openapi.json) | Runtime | Node.js 18+, Deno, Bun, edge | | --- | --- | | Auth | Authorization: Bearer | | Types | Generate from /openapi.json | | Entity cache | Days (monthly data) | ## The answer in detail The official SAM.gov API puts the key in the URL, which makes browser use impossible to secure. The same applies here even though the key goes in a header: anything in client JavaScript is public.Cache by data date. Entity data changes once a month (the 1 Nov 2026 extract is current until about 17 Dec 2026), so an entity lookup can be cached for days; opportunities change nightly; exclusions daily.TypeScript users can generate types from /openapi.json with openapi-typescript and get autocompletion for every parameter. ## 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 | | [GovCon API (govconapi.com)](https://govconapi.com/pricing) | Developer $19/mo, Pro $39/mo; 14-day trial | 1,000 requests an hour (50 a minute burst); trial 50 a day | 12,265,150 contracts and 758,552 opportunities from FY2025; 904,090 entities, monthly | Developers who want the lowest entry price and FY2025+ history | 2026-11-15 | | [samgovapi.io](https://samgovapi.io/pricing) | Free (100 credits a month, no card); Developer $49/mo, Pro $149/mo, Scale $499/mo | 20 to 180 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 - No official npm package is published yet; fetch works without one. ## Try it A Next.js route that proxies a registration check and caches it for a day. ``` // app/api/registration/[id]/route.ts export async function GET(_: Request, { params }: { params: Promise }) { const { id } = await params; const res = await fetch(`https://samgovapi.io/api/v1/registration-status/${encodeURIComponent(id)}`, { headers: { Authorization: `Bearer ${process.env.SAMGOVAPI_API_KEY}` }, next: { revalidate: 86400 }, }); return Response.json(await res.json(), { status: res.status }); } ``` ## Questions Can I call it from a browser?Not with your key. Proxy through your server.Is CORS enabled?Use a server-side call; keys must not be shipped to browsers. ## Related - [JavaScript](https://samgovapi.io/javascript) - [Node fetch guide](https://samgovapi.io/agents/node-fetch) - [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-data-in-javascript . Markdown: https://samgovapi.io/answers/sam-gov-data-in-javascript.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
