Python client for USAC E-Rate Open Data (Socrata SODA API)
Project description
usac-data
Python client for USAC E-Rate Open Data (Socrata SODA API).
Provides typed dataset definitions, a fluent SoQL query builder, automatic pagination, and high-level helpers for common E-Rate data queries.
Install
pip install usac-data
Requires Python 3.11+. Versions before 0.1.6 were never published to PyPI; to install one of those, use a tag-pinned git URL instead:
pip install "usac-data @ git+https://github.com/sgentzen/usac-data@v0.1.5"
Quick start
from usac_data import USACClient, Form471, C2BudgetTool
client = USACClient(app_token="optional-socrata-app-token")
# Simple query
rows = client.get(Form471.dataset_id, query=Form471.for_year(2024).limit(10))
# C2 budget with remaining funds in Virginia
from usac_data import c2_budget_remaining_query
dataset_id, query = c2_budget_remaining_query(min_remaining=5000, state="VA")
results = client.get(dataset_id, query=query)
# Async with full pagination
import asyncio
async def main():
async with USACClient() as client:
async for batch in client.apaginate(C2BudgetTool.dataset_id):
print(f"Got {len(batch)} rows")
asyncio.run(main())
Query builder
from usac_data import SoQLBuilder
q = (
SoQLBuilder()
.select("entity_name", "frn", "total_authorized_disbursement")
.where(funding_year=2024, frn_status="Funded")
.where_raw("total_authorized_disbursement > 10000")
.order_by("total_authorized_disbursement DESC")
.limit(100)
)
Datasets
| Class | Dataset | Description |
|---|---|---|
Form471 |
qdmp-ygft |
FRN-level funding status |
FRNLineItems |
hbj5-2bpj |
Form 471 line-item detail: product, quantity, cost |
RecipientCommitments |
avi8-svp9 |
Recipient detail and committed amounts |
C2BudgetTool |
6brt-5pbv |
Category 2 five-year budget balances |
Consultants |
x5px-esft |
Consultant associations per application |
EntityInfo |
7i5i-83qf |
School/library demographics and details |
Each dataset class exposes field names as class attributes and convenience query methods.
Column naming differs between datasets
These feeds do not agree on column names, and the two failure modes are different. Check the class docstring before writing a filter.
FRNLineItemsusesben. It has nobilled_entity_numberand nochosen_category_of_service; filtering on either returns HTTP 400query.soql.no-such-column, a hard failure.RecipientCommitmentsusesbilled_entity_number. The post-discount committed amount ispost_discount_extended_eligible_line_item_costs(there is nototal_authorized_disbursement), and the discount percentage isdis_pct, notdiscount_pct_c2. Reading an absent field returnsNonesilently, because Socrata omits absent fields from row JSON rather than rejecting the request.
from usac_data import USACClient, FRNLineItems, RecipientCommitments
with USACClient() as client:
items = client.get(
FRNLineItems.dataset_id,
query=FRNLineItems.for_ben_year("123881", 2024),
)
commitments = client.get(
RecipientCommitments.dataset_id,
query=RecipientCommitments.for_ben_year("123881", 2024),
)
Helpers
c2_budget_remaining_query()- entities with unspent C2 budgetentities_without_consultant_query()- filings with no consultantfrn_history_query()- entity FRN history across yearsconsultant_portfolio_query()- entities served by a consultant
Development
pip install -e ".[dev]"
pytest
ruff check .
mypy src/
License
Apache 2.0 — see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file usac_data-0.1.6.tar.gz.
File metadata
- Download URL: usac_data-0.1.6.tar.gz
- Upload date:
- Size: 30.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdc78ed341e5ed7f915443ef4a1b61701b9631bbd891414ef70a2d650581c867
|
|
| MD5 |
bc67b44ea9f3d874a52547f395308e11
|
|
| BLAKE2b-256 |
2cdb258cb32c27a6e41865fefdc83054b6c30d1c9bee59ce6b3227591224c3c8
|
Provenance
The following attestation bundles were made for usac_data-0.1.6.tar.gz:
Publisher:
release.yml on sgentzen/usac-data
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
usac_data-0.1.6.tar.gz -
Subject digest:
bdc78ed341e5ed7f915443ef4a1b61701b9631bbd891414ef70a2d650581c867 - Sigstore transparency entry: 2254708557
- Sigstore integration time:
-
Permalink:
sgentzen/usac-data@0c13edfc412f64426a771f0d418ebd01ded31ec9 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/sgentzen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0c13edfc412f64426a771f0d418ebd01ded31ec9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file usac_data-0.1.6-py3-none-any.whl.
File metadata
- Download URL: usac_data-0.1.6-py3-none-any.whl
- Upload date:
- Size: 21.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
968714b46535f63b13f6ab88a8067a21883352ecc007d968192e7e5db81b0dac
|
|
| MD5 |
488bfaf4f98d3e11ad5b83f5b1f4ee0c
|
|
| BLAKE2b-256 |
75b8c8c460b9c3b1af894b5c8a09ae28966460c48287d09ab1c18160e71bb36f
|
Provenance
The following attestation bundles were made for usac_data-0.1.6-py3-none-any.whl:
Publisher:
release.yml on sgentzen/usac-data
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
usac_data-0.1.6-py3-none-any.whl -
Subject digest:
968714b46535f63b13f6ab88a8067a21883352ecc007d968192e7e5db81b0dac - Sigstore transparency entry: 2254708614
- Sigstore integration time:
-
Permalink:
sgentzen/usac-data@0c13edfc412f64426a771f0d418ebd01ded31ec9 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/sgentzen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0c13edfc412f64426a771f0d418ebd01ded31ec9 -
Trigger Event:
release
-
Statement type: