SAM.gov API Python Client

N/A · active · verified Tue Mar 17

Python wrapper for the SAM.gov (System for Award Management) public API. Provides access to entity registration data, opportunities, exclusions, and other federal procurement data from SAM.gov. Simplifies authentication and pagination when querying the SAM.gov API endpoints.

Warnings

Install

Imports

Quickstart

Minimal example searching for entity registrations on SAM.gov by keyword.

import os
import requests

api_key = os.environ.get("SAM_GOV_API_KEY", "DEMO_KEY")
resp = requests.get(
    "https://api.sam.gov/entity-information/v3/entities",
    params={"api_key": api_key, "purposeOfRegistrationCode": "Z2", "entityEFTIndicator": "", "samRegistered": "Yes"},
    headers={"Accept": "application/json"}
)
resp.raise_for_status()
data = resp.json()
print(f"Total records: {data.get('totalRecords', 0)}")

view raw JSON →