Skip to content

contractwatch/sam-search

 
 

Repository files navigation

SAM.gov opportunity search and post to MS Teams

sam-search-build sam-search-run

Python client for the sam.gov opportunities API: https://open.gsa.gov/api/get-opportunities-public-api/. Searches by a list of NAICS codes and from-date, defaulting to a list of opps from the past day.

The SAM-Search-Run workflow pulls search results for specified NAICS each day and posts to a designated MS Teams channel. Search config data is stored in config.yaml. To run this you must obtain and configure as actions repo secrets:

  • SAM_API_KEY: API key from sam.gov, which is tied to a personal account, and expires every 90 days.
  • MS_URL: MS Teams webhook URL for your organization.

More info on setting up Teams webhooks: Create incoming webhooks with Workflows for Microsoft Teams

Note

The sam.gov get opportunities API does not allow searching by a list of NAICS like the front-end sam.gov web page does, so this client is making a series of GET requests for each NAICS configured in config.yaml. Sam.gov restricts non-federal accounts to 10 API requests per day, so this can only search a max of 10 NAICS per day. MS Teams also restricts the size of posted messages, so search results with over 40 records will be broken into additional Teams messages.

Local execution:

Python 3.13+ required. Install uv (brew install uv) and sync dependencies:

uv sync --dev

Lint:

uv run ruff check .
uv run ruff format --check .

Git hook (auto-formats Python files on commit):

git config core.hooksPath hooks

Type check:

uv run ty check

Tests:

uv run pytest test_search.py

Execute: pass sam api key, ms teams webhook url:

uv run python3 search.py my-sam-api-key my-ms-webhook-url

About

Simple Python client to query sam.gov and post to MS Teams

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 99.1%
  • Shell 0.9%