A Python library for accessing Texas Comptroller of Public Accounts tax and financial data
Project description
Compytroller
A Python library for accessing Texas Comptroller of Public Accounts tax and financial data.
Overview
Compytroller provides a clean, type-safe interface to Texas Comptroller data from multiple sources:
- Socrata Open Data API (data.texas.gov)
- Texas Comptroller web forms
- CSV data exports
The library supports:
- Sales tax data (rates, permits, allocations, quarterly sales)
- Franchise tax data (permit holders)
- Mixed beverage tax data (receipts, allocations)
Installation
From PyPI (Recommended)
pip install compytroller
From Source
git clone https://github.com/zactax/compytroller.git
cd compytroller
pip install -e .
Development Installation
To install with development dependencies:
pip install -e ".[dev]"
Quick Start
from compytroller import ComptrollerClient
# Initialize the client with your Socrata app token
client = ComptrollerClient(app_token="your-app-token-here")
# Get sales tax rates for a specific city
rates = (client.sales_tax()
.rates()
.for_city("Austin")
.get())
# Get active permits for a taxpayer
permits = (client.sales_tax()
.active_permits()
.for_taxpayer("12345678")
.get())
# Get franchise tax permit holders
franchise = (client.franchise_tax()
.active_permit_holders()
.for_taxpayer("12345678")
.get())
# Get mixed beverage gross receipts
receipts = (client.mixed_beverage_tax()
.gross_receipts()
.for_year(2024)
.get())
Features
Fluent Query Builder API
All data sources support method chaining for intuitive query construction:
results = (client.sales_tax()
.active_permits()
.for_city("Houston")
.in_county("Harris")
.issued_after("2024-01-01")
.sort_by("outlet_city", desc=True)
.limit(100)
.get())
Field Enums
Optional enums for sort_by() fields and categorical filters provide IDE autocompletion and eliminate magic strings:
from compytroller.fields import ActivePermitField, AuthorityType
# Sort by field enum instead of a raw string
permits = (client.sales_tax()
.active_permits()
.sort_by(ActivePermitField.OUTLET_CITY)
.limit(100)
.get())
# Categorical enum for filter values
allocations = (client.sales_tax()
.county_spd_mta_allocations()
.for_type(AuthorityType.COUNTY)
.get())
All enums inherit from str, so raw strings continue to work everywhere.
Type-Safe Responses
All responses are returned as Python dataclasses with full type hints:
from compytroller.responses.sales_tax import ActivePermitData
permits: list[ActivePermitData] = client.sales_tax().active_permits().get()
for permit in permits:
print(f"{permit.taxpayer_name} - {permit.outlet_city}")
Multiple Data Sources
- Socrata API: Primary source for most datasets
- Web Scraping: Historical allocation data via state forms
- CSV Downloads: Marketplace provider lists
Comprehensive Error Handling
Custom exceptions for clear error messages:
from compytroller.exceptions import HttpError, InvalidRequest
try:
results = client.sales_tax().rates().get()
except HttpError as e:
print(f"HTTP Error {e.status_code}: {e.url}")
except InvalidRequest as e:
print(f"Invalid request: {e}")
Available Data Sources
Sales Tax
active_permits()- Active sales tax permitsrates()- Sales tax rate changesallocation_history()- Historical allocation dataallocation_payment_details()- Detailed payment breakdownssingle_local_allocations()- Single local jurisdiction allocationsmarketplace_provider_allocations()- Marketplace provider allocationsmarketplace_provider()- Marketplace provider registrypermitted_locations()- Permitted location detailsdirect_pay_taxpayers()- Direct pay taxpayer listquarterly_sales_history()- Quarterly sales by jurisdiction/industrysingle_local_tax_rates()- Single local tax ratescity_county_comparison_summary()- City/county payment comparisonscounty_spd_mta_allocations()- County/SPD/MTA allocations
Franchise Tax
active_permit_holders()- Active franchise tax permit holders
Mixed Beverage Tax
gross_receipts()- Gross receipts by beverage typehistory()- Historical allocation data
Documentation
- API Reference - Complete API documentation
- Usage Examples - Common usage patterns
- Data Sources - Detailed data source reference
- Development Guide - Contributing and development setup
Authentication
Most data sources require a Socrata app token. Get yours by creating an account on https://data.texas.gov and then navigating to https://data.texas.gov/profile/edit/developer_settings.
Requirements
- Python 3.10+
- httpx
- pandas
- selectolax
License
See LICENSE file for details.
Contributing
Contributions are welcome! See DEVELOPMENT.md for development setup and guidelines.
Support
For issues and feature requests, please use the GitHub issue tracker.
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 compytroller-0.2.1.tar.gz.
File metadata
- Download URL: compytroller-0.2.1.tar.gz
- Upload date:
- Size: 42.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
639ff8b4d28bb97998cccc112f0bcc49f0a84ce2a1c0b631bf844b11152ae973
|
|
| MD5 |
d7dab970614dd9a7b3aad910e3eab3a9
|
|
| BLAKE2b-256 |
6b2c503a3d427f5d522d6b22b8691d65ac123e817454e638aaf1aa4c87865fe6
|
File details
Details for the file compytroller-0.2.1-py3-none-any.whl.
File metadata
- Download URL: compytroller-0.2.1-py3-none-any.whl
- Upload date:
- Size: 60.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca02ac5c68dc58dcc98839a357accf65a715f7419e21a53fae34ae11674e2024
|
|
| MD5 |
668c79a99609cc2e0281f1f6051b491c
|
|
| BLAKE2b-256 |
31e4cc05cb7fc340569dcb594a886ae23236bac4a68669dd838236216591053b
|