# SAM.gov data in Python With Python and the requests library, one GET call returns a SAM.gov entity, its registration status and its award history as JSON. Set SAMGOVAPI_API_KEY in your environment and send it as a Bearer token. A 429 body states which limit was hit and the upgrade or top-up link. Back off for the per-minute limit; for the monthly allowance, upgrade or add a top-up.Checked on 2026-11-12.Official source: [open.gsa.gov](https://open.gsa.gov/api/) | Library | requests (any HTTP client works) | | --- | --- | | Auth | Authorization: Bearer key | | Pagination | next_cursor | | Format | JSON | ## Look up an entity by UEI ``` import os, requests r = requests.get( "https://samgovapi.io/api/v1/entities/ABCDEFGH1234", headers={"Authorization": f"Bearer {os.environ['SAMGOVAPI_API_KEY']}"}, timeout=30, ) r.raise_for_status() print(r.json()) ``` ## Check registration expiry ``` import os, requests r = requests.get( "https://samgovapi.io/api/v1/registration-status/ABCDEFGH1234", headers={"Authorization": f"Bearer {os.environ['SAMGOVAPI_API_KEY']}"}, timeout=30, ) r.raise_for_status() print(r.json()) ``` ## Page through search results ``` import os, requests url = "https://samgovapi.io/api/v1/opportunities?q=cybersecurity&active=true" headers = {"Authorization": f"Bearer {os.environ['SAMGOVAPI_API_KEY']}"} cursor = None while True: r = requests.get(url, headers=headers, params={"cursor": cursor} if cursor else None, timeout=30) r.raise_for_status() body = r.json() for row in body["rows"]: print(row["notice_id"], row["title"]) cursor = body.get("next_cursor") if not cursor: break ``` ## Handle 429 A 429 body states which limit was hit and the upgrade or top-up link. Back off for the per-minute limit; for the monthly allowance, upgrade or add a top-up. ## Get this as JSON ``` curl "https://samgovapi.io/api/v1/entities/ABCDEFGH1234" \ -H "Authorization: Bearer sg_YOUR_KEY" ``` MCP tool: `get_entity`Keys start free, with no card. [Get a free API key](https://samgovapi.io/sign-up) or read the [docs](https://samgovapi.io/docs). ## Related - [JavaScript](https://samgovapi.io/javascript) - [Quickstart](https://samgovapi.io/docs/quickstart) - [Errors](https://samgovapi.io/docs/errors)Updated 2026-11-12. Sources checked 2026-11-12.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/python . Markdown: https://samgovapi.io/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
