Skip to main content

PyDOGE API is an advanced, Python wrapper for interacting with the public-facing API of the Department of Government Efficiency (DOGE)

Project description

PyDOGE Logo

A Python library to interact with Department of Government Efficiency (DOGE) API.


🧾 Table of Contents
  1. About The Project
  2. Highlights
  3. Getting Started
  4. Usage
  5. Contributors
  6. Acknowledgements

🐍 About The Project

PyDOGE API is an advanced, Python wrapper for interacting with the public-facing API of the Department of Government Efficiency (DOGE) — a federal initiative aimed at increasing transparency and fiscal accountability by sharing detailed datasets on:

  • 💸 Cancelled grants
  • 📑 Contract terminations
  • 🏢 Lease reductions
  • 🧾 Payment transactions

🚀 Features

  • Auto-pagination (sync or async, fetch all pages if needed)
  • .export() to CSV, Excel, or JSON with timestamped filenames
  • .to_dataframe() for Pandas users
  • .summary() with analytics (rows, nulls, dtypes, stats)
  • summary(save_as="...") for file logging
  • Returns Pydantic models & dict output
  • Retry-safe client with 429 handling

This package enables data scientists and analysts to programmatically access and analyze the data with ease.

📌 Getting Started

Installation

Install:

pip install pydoge-api

Upgrade:

pip install --upgrade pydoge-api

Documentation

Full developer docs with API reference, usage, and model schema:

📚 Usage

Get Grants and sorted by savings

from pydoge_api import DogeAPI

with DogeAPI(fetch_all=True, run_async=False) as api:
    grants = api.savings.get_grants(sort_by="savings")
    df = grants.to_dataframe()
    print(df.head())

    # Export to CSV
    grants.export("grants_q1", format="csv")
    
    # Show summary in terminal
    grants.summary(verbose=True)
    
    # Save the summary as markdown
    grants.summary(save_as="logs/grants_summary.md")

Get Contracts and sorted by agency

with DogeAPI(fetch_all=True, run_async=False) as api:
    contracts = api.savings.get_contracts(sort_by="agency")
    df = contracts.to_dataframe()
    print(df.head())

    # Export to CSV
    contracts.export("contracts_q1", format="csv")
    
    # Show summary in terminal
    contracts.summary(verbose=True)
    
    # Save the summary as markdown
    contracts.summary(save_as="logs/contracts_summary.md")

Get Leases

with DogeAPI(fetch_all=True, run_async=False) as api:
    leases = api.savings.get_leases()
    df = leases.to_dataframe()
    print(df.head())
    
    # Export to CSV
    leases.export("leases_q1", format="csv")
    
    # Show summary in terminal
    leases.summary(verbose=True)
    
    # Save the summary as markdown
    leases.summary(save_as="logs/leases_summary.md")

Get Payments and filter payments by agency

with DogeAPI(fetch_all=True, run_async=False) as api:
    payments = api.payments.get_payments(filter="agency", filter_value="NASA")
    df =payments.to_dataframe()
    print(df.head())
    
    # Export to CSV
    payments.export("payments_q1", format="csv")
    
    # Show summary in terminal
    payments.summary(verbose=True)
    
    # Save the summary as markdown
    payments.summary(save_as="logs/payments_summary.md")

Without using Context Manager

api = DogeAPI(
    fetch_all=True, # Get all records if True. Default False
    run_async=False # For Async set this to True
)

try:
    # Get Grants and sorted by savings
    grants = api.savings.get_grants(sort_by="savings")
    
    # Get Contracts and sorted by agency
    contracts = api.savings.get_contracts(sort_by="agency")
    
    # Get Leases
    leases = api.savings.get_leases()
    
    # Get Payments and filter payments by agency
    payments = api.payments.get_payments(filter="agency", filter_value="NASA")
    
    # Export to CSV
    grants.export("grants_q1", format="csv")
    
    # Show summary in terminal
    grants.summary(verbose=True)
    
    # Save the summary as markdown
    grants.summary(save_as="logs/grants_summary.md")
    
finally:
    api.close()
    

(back to top)

👪 Contributors

All contributions are welcome. If you have a suggestion that would make this better, please fork the repo and create a merge request. You can also simply open an issue with the label 'enhancement'.

Don't forget to give the project a star! Thanks again!

👏 Acknowledgments

Inspiration, code snippets, etc.

(back to top)

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

pydoge_api-0.2.1.tar.gz (507.2 kB view details)

Uploaded Source

Built Distribution

pydoge_api-0.2.1-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file pydoge_api-0.2.1.tar.gz.

File metadata

  • Download URL: pydoge_api-0.2.1.tar.gz
  • Upload date:
  • Size: 507.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for pydoge_api-0.2.1.tar.gz
Algorithm Hash digest
SHA256 74bc3c958093cdc2ad7ae2f7302d1f75e0593a6d3e689fa9c6f0f67619179967
MD5 6e04c225937fa908e9235ea7f62ae5eb
BLAKE2b-256 0864680e8f3a3b495a922e469549c67681f3a99c104f4dd8d24261caa8c23bff

See more details on using hashes here.

File details

Details for the file pydoge_api-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pydoge_api-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for pydoge_api-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce3ae007850a81420916f90e64ef15de49b65ab66ad928e5fcaf90a206e92574
MD5 e016713c3917c525d0cda56f473818e6
BLAKE2b-256 4bda96a5b27823a5e5da6c5bcb0d5d5f714a34211cc5f377e7d0684ab7bed648

See more details on using hashes here.

Supported by

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