IRS API Python Client

N/A · maintenance · verified Tue Mar 17

Unofficial Python wrapper for accessing IRS (Internal Revenue Service) public data and tax-related information programmatically. Provides convenience methods for retrieving tax forms, instructions, and other IRS public resources.

Warnings

Install

Imports

Quickstart

IRS public APIs are REST-only (no PyPI package). Endpoints vary by service. Always check Content-Type before calling .json() — some endpoints return HTML error pages on failure.

import requests

# IRS provides several public REST APIs (no key required for most)
# Forms and publications search
resp = requests.get(
    "https://www.irs.gov/api/forms-pubs/1040",
    headers={"Accept": "application/json"}
)
# IRS APIs may return HTML on error — check content-type before parsing
if resp.ok and "application/json" in resp.headers.get("Content-Type", ""):
    print(resp.json())
else:
    print(f"Status: {resp.status_code}")

view raw JSON →