Skip to main content

Python SDK for the TaxApex Tax Notice Management API

Project description

TaxApex Python SDK

Official Python client library for the TaxApex Tax Notice Management API.

Installation

pip install taxapex

Quick Start

from taxapex import TaxApexClient

# Initialize the client
client = TaxApexClient(api_key="your-api-key")

# Extract data from a tax notice
result = client.extract.from_file("notice.pdf")
print(f"Notice Type: {result.notice_type}")
print(f"Amount Due: ${result.amount_due}")
print(f"Due Date: {result.due_date}")

Features

Document Extraction

Extract structured data from IRS and state tax notices:

# From a local file
result = client.extract.from_file("cp2000_notice.pdf")

# From raw bytes
with open("notice.pdf", "rb") as f:
    result = client.extract.from_bytes(f.read(), filename="notice.pdf")

# From a URL
result = client.extract.from_url("https://example.com/notice.pdf")

# Access extracted data
print(f"Notice Type: {result.notice_type}")
print(f"Issuing Agency: {result.issuing_agency}")
print(f"Amount Due: ${result.amount_due}")
print(f"Due Date: {result.due_date}")
print(f"Taxpayer: {result.taxpayer_name}")
print(f"Tax Year: {result.tax_year}")
print(f"Confidence: {result.confidence_score:.2%}")

Audit Risk Analysis

Analyze audit risk for clients:

# Analyze audit risk
risk = client.audit_risk.analyze(
    client_id="client-12345",
    tax_year=2023,
    income_data={
        "wages": 150000,
        "self_employment": 50000,
        "investments": 25000,
        "rental": 12000,
    },
    deduction_data={
        "mortgage_interest": 18000,
        "state_taxes": 10000,
        "charitable": 15000,
        "home_office": 5000,
    },
    industry="technology"
)

# Review results
print(f"Overall Risk Score: {risk.overall_score}/100")
print(f"Risk Level: {risk.risk_level}")
print(f"\nCategory Scores:")
print(f"  Income: {risk.income_score}/100")
print(f"  Deductions: {risk.deductions_score}/100")
print(f"  Credits: {risk.credits_score}/100")
print(f"  Compliance: {risk.compliance_score}/100")

print(f"\nRisk Factors:")
for factor in risk.risk_factors:
    print(f"  - {factor.description} ({factor.severity})")

print(f"\nRecommendations:")
for rec in risk.recommendations:
    print(f"  - {rec}")

Semantic Search

Search across your document repository:

# Search documents
results = client.search.query(
    "IRS penalty abatement procedures",
    document_type="IRS_NOTICE",
    limit=5,
    min_similarity=0.7
)

print(f"Found {results.total_results} results:")
for item in results.results:
    print(f"\n{item.title}")
    print(f"  Similarity: {item.similarity_score:.2%}")
    print(f"  Snippet: {item.content_snippet[:100]}...")

# Index a new document
client.search.index_document(
    document_id="doc-123",
    content="Full text content of the document...",
    title="CP2000 Response Letter",
    document_type="RESPONSE_LETTER",
    tax_year=2023
)

Tax Research

Get AI-powered answers to tax questions:

# Research a tax question
result = client.research.query(
    "What are the requirements for claiming the home office deduction?",
    include_citations=True,
    max_sources=5
)

print(f"Answer:\n{result.answer}")
print(f"\nConfidence: {result.confidence:.2%}")
print(f"\nSources:")
for source in result.sources:
    print(f"  - {source.title}")
    print(f"    {source.url}")

Usage Statistics

Monitor your API usage:

usage = client.get_usage()

print(f"Billing Period: {usage.period_start} to {usage.period_end}")
print(f"Document Extractions: {usage.document_extractions}")
print(f"AI Analysis Calls: {usage.ai_analysis_calls}")
print(f"Search Queries: {usage.search_queries}")
print(f"Audit Risk Assessments: {usage.audit_risk_assessments}")
print(f"Total API Calls: {usage.total_api_calls}")

Configuration

Environment Variables

export TAXAPEX_API_KEY="your-api-key"
export TAXAPEX_BASE_URL="https://api.taxapex.com/v1"  # Optional

Client Options

client = TaxApexClient(
    api_key="your-api-key",
    base_url="https://api.taxapex.com/v1",  # Custom API URL
    timeout=120,  # Request timeout in seconds
    max_retries=5,  # Retry attempts for failed requests
    retry_delay=2.0,  # Base delay between retries
)

Context Manager

with TaxApexClient(api_key="your-api-key") as client:
    result = client.extract.from_file("notice.pdf")
    # Session is automatically closed

Error Handling

from taxapex import (
    TaxApexClient,
    APIError,
    AuthenticationError,
    RateLimitError,
    ValidationError,
)

try:
    result = client.extract.from_file("notice.pdf")
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after} seconds")
except ValidationError as e:
    print(f"Invalid request: {e.message}")
except APIError as e:
    print(f"API error: {e.message} (status: {e.status_code})")

Data Models

ExtractionResult

Field Type Description
id str Unique extraction ID
notice_type NoticeType Type of notice (CP2000, CP501, etc.)
issuing_agency str IRS or state agency
notice_date datetime Date on the notice
due_date datetime Response due date
amount_due float Amount owed
taxpayer_name str Taxpayer name
taxpayer_id str SSN/EIN (masked)
tax_year int Tax year
fields List[ExtractedField] All extracted fields
confidence_score float Extraction confidence (0-1)

AuditRiskAssessment

Field Type Description
id str Assessment ID
client_id str Client identifier
tax_year int Tax year analyzed
overall_score float Overall risk score (0-100)
risk_level RiskLevel low, medium, high, critical
income_score float Income risk score
deductions_score float Deductions risk score
credits_score float Credits risk score
compliance_score float Compliance risk score
risk_factors List[RiskFactor] Identified risk factors
recommendations List[str] Mitigation recommendations

Support

License

MIT License - see LICENSE file for details.

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

taxapex-1.0.1.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

taxapex-1.0.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file taxapex-1.0.1.tar.gz.

File metadata

  • Download URL: taxapex-1.0.1.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0rc1

File hashes

Hashes for taxapex-1.0.1.tar.gz
Algorithm Hash digest
SHA256 8ad39b2aac855887334db57ccc5de4bf0c9d11c075694ea4c42a50f7574e7bdb
MD5 a8f726577147d2ba17ccd2ca2eb809ce
BLAKE2b-256 8dbd9f8648a7ff6e47ad6216e865dbbcc2d797b9841f11b84041ca41d7c84400

See more details on using hashes here.

File details

Details for the file taxapex-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: taxapex-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0rc1

File hashes

Hashes for taxapex-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 850e2ffad0ffb7b51a94f9ffc808710ec891ac353623e58b8382d5fe58ec754c
MD5 82b5f62c3ec89f66534b05a208f2690a
BLAKE2b-256 5e535be4eaccfa9b9f1a19c8249c092fa5659778910e2c5aa8eee9aa9d078128

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