# How do I get SAM.gov data in Python? Use requests against the official SAM.gov API with your api_key parameter, or against an API over the same data with a Bearer key. Officially, entity searches return 10 records a page; here they return up to 100 with a next_cursor, so a Python loop over a NAICS code takes a tenth of the calls. Here responses are flat rows with a meta block (as_of, credits_charged, next_cursor, remaining_credits).Checked on 2026-11-15.Official source: [open.gsa.gov Entity Management API](https://open.gsa.gov/api/entity-api/) | Official auth | api_key query parameter | | --- | --- | | Here | Authorization: Bearer header | | Rows per call here | Up to 100 | | Paging | meta.next_cursor | ## The answer in detail The official Entity API takes api_key as a query parameter, which ends up in logs and proxies; keep it in an environment variable and redact it. Responses nest registration, core data and assertions in separate objects, so most scripts flatten them before writing to pandas.Here responses are flat rows with a meta block (as_of, credits_charged, next_cursor, remaining_credits). Pass the cursor back until it is null to read a whole result set, and read meta.as_of to label your output with the data date.For notebooks, pandas.json_normalize on the data list gives a DataFrame in one line. ## 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 Python SDK is published yet; plain requests works. ## Try it Read every active firm in a NAICS code into pandas, following the cursor. ``` import os, requests, pandas as pd url = "https://samgovapi.io/api/v1/entities" h = {"Authorization": f"Bearer {os.environ['SAMGOVAPI_API_KEY']}"} params, rows = {"naics": "541715", "status": "active", "limit": 100}, [] while True: body = requests.get(url, params=params, headers=h, timeout=30).json() rows += body["data"] if not body["meta"]["next_cursor"]: break params["cursor"] = body["meta"]["next_cursor"] df = pd.json_normalize(rows) print(len(df), "firms, data as of", body["meta"]["as_of"]) ``` ## Questions Is there a pip package?Not published yet; the REST API works with requests or httpx, and /openapi.json can generate a typed client.How do I avoid 429 errors in a loop?Stay under your plan's per-minute limit and back off until reset_at when a 429 arrives. ## Related - [Python](https://samgovapi.io/python) - [Recipe: Python requests](https://samgovapi.io/agents/python-requests) - [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-python . Markdown: https://samgovapi.io/answers/sam-gov-data-in-python.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
