Treaury Fiscal Data API Client for Python
Python client for accessing the U.S. Treasury Fiscal Data API.
Installation
python -m pip install usfiscaldata
Usage
Example
from usfiscaldata import FiscalData, Filter
client = FiscalData()
endpoint = client.v1.accounting.od.auctions_query
filter_ = Filter()
filter_["record_date"] <= "1984-01-01"
response = endpoint.all(filter=filter_)
df = response.df
print(df.shape)
print(df.head())
Endpoints
The client implements a generic dot-accessor interface for the endpoints, so you need to know the full endpoint path. The endpoint can also be specified as a string.
from usfiscaldata import FiscalData
client = FiscalData()
endpoint = client.v2.debt.tror.data_act_compliance
endpoint = client("v2/debt/tror/data_act_compliance")
Filters
Filters are specified using a dictionary-like Filter object.
from fiscaldata import Filter
filter_ = Filter()
filter_["record_date"] <= "2000-01-01"
filter_["amount"] > 1000
filter_["fiscal_year"].isin([1999, 2000, 2001])
Response Pagination
The response object contains a meta attribute with pagination information, and a next_page method to retrieve the next page of results.
When there are no more pages, next_page returns None.
You can also just call .all() as in above example.
Release files for usfiscaldata 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| usfiscaldata-0.1.0.tar.gz | 6.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| usfiscaldata-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.0 kB
Release files / usfiscaldata-0.1.0.tar.gz
| Download URL | usfiscaldata-0.1.0.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c72db47f0a01d4eec91f0c4ac679f0cdf1b08a33a6ec7790a70ca69097d09c46
|
|
BLAKE2b-256 checksum How to use checksums |
182d4b50351fcc97d9b65aa86f05bb477d5c762ed4c42164da3abbc259931888
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Release files / usfiscaldata-0.1.0-py3-none-any.whl
| Download URL | usfiscaldata-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10749f0189091fdb1b246ce8a2e60fa8674da585b8f4d484041886f9a97871a2
|
|
BLAKE2b-256 checksum How to use checksums |
ccee96d2395a8f6c3d7a0258e9f50ed3c035fdab4312dcdbdb6429389736942e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|