Skip to main content

Client for US Treasury Fiscal Data API

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

usfiscaldata-0.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

usfiscaldata-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file usfiscaldata-0.1.0.tar.gz.

File metadata

  • Download URL: usfiscaldata-0.1.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for usfiscaldata-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c72db47f0a01d4eec91f0c4ac679f0cdf1b08a33a6ec7790a70ca69097d09c46
MD5 95c6ff6afefd15946226151491a35de7
BLAKE2b-256 182d4b50351fcc97d9b65aa86f05bb477d5c762ed4c42164da3abbc259931888

See more details on using hashes here.

File details

Details for the file usfiscaldata-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: usfiscaldata-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for usfiscaldata-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 10749f0189091fdb1b246ce8a2e60fa8674da585b8f4d484041886f9a97871a2
MD5 96c9029d79627e4cee8db54c88d53e5a
BLAKE2b-256 ccee96d2395a8f6c3d7a0258e9f50ed3c035fdab4312dcdbdb6429389736942e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page