Skip to main content

Official Python SDK for HelloLedger API

Project description

HelloLedger Python SDK

Official Python SDK for the HelloLedger API. This SDK enables developers to integrate HelloLedger programmatically using API keys.

Installation

pip install helloledger

Quick Start

from helloledger import HelloLedger

# Production (default)
client = HelloLedger(
    client_id="hl_live_abc123",
    secret_token="sk_live_xyz789",
    api_base="https://api.helloledger.ai"  # Optional, defaults to production
)

# Sandbox/Development
client = HelloLedger(
    client_id="hl_test_abc123",
    secret_token="sk_test_xyz789",
    api_base="https://devhlapi.azurewebsites.net"  # Use for testing
)

# List all companies accessible by your API key
companies = client.companies.list()

# Get a specific company
company = client.companies.get(company_id=123)

# List transactions for a company
transactions = client.transactions.list(company_id=123)

# Optional: Filter transactions by date
transactions = client.transactions.list(
    company_id=123,
    start_date="2025-01-01",
    end_date="2025-12-31"
)

Authentication

The SDK uses HTTP Basic Authentication with your API key credentials. You need to:

  1. Sign up for a HelloLedger account
  2. Generate an API key (client_id + secret_token)
  3. Initialize the client with your credentials

Important: Keep your secret_token secure and never commit it to version control.

API Environments

The SDK supports two environments:

  • Production: https://api.helloledger.ai (default)

    • Use for live/production applications
    • Requires production API keys
  • Sandbox: https://devhlapi.azurewebsites.net

    • Use for testing and development
    • Requires sandbox/test API keys

Example:

# Production
client = HelloLedger(
    client_id="hl_live_abc123",
    secret_token="sk_live_xyz789"
    # api_base defaults to https://api.helloledger.ai
)

# Sandbox
client = HelloLedger(
    client_id="hl_test_abc123",
    secret_token="sk_test_xyz789",
    api_base="https://devhlapi.azurewebsites.net"
)

Error Handling

The SDK raises custom exceptions for different error scenarios:

from helloledger import HelloLedger
from helloledger.exceptions import (
    AuthenticationError,
    PermissionError,
    NotFoundError,
    APIError
)

client = HelloLedger(client_id="...", secret_token="...")

try:
    company = client.companies.get(company_id=123)
except NotFoundError:
    print("Company not found or not accessible")
except PermissionError:
    print("Your API key doesn't have access to this company")
except AuthenticationError:
    print("Invalid API credentials")
except APIError as e:
    print(f"API error: {e.message} (Status: {e.status_code})")

Available Methods (Phase 1 - MVP)

Companies

  • client.companies.list() - List all accessible companies
  • client.companies.get(company_id) - Get a specific company

Transactions

  • client.transactions.list(company_id, **kwargs) - List transactions for a company
    • Optional parameters: start_date, end_date, limit, offset

Context Manager

You can use the client as a context manager to ensure proper cleanup:

with HelloLedger(client_id="...", secret_token="...") as client:
    companies = client.companies.list()
    # Client is automatically closed when exiting the context

Requirements

  • Python 3.8+
  • httpx >= 0.24.0

License

MIT

Support

For issues, questions, or feature requests:

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

helloledger-0.1.1.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

helloledger-0.1.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file helloledger-0.1.1.tar.gz.

File metadata

  • Download URL: helloledger-0.1.1.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for helloledger-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0aec218e5c01b3985a1bd5845f97d65965214efeca056fe28240956cd5d7f866
MD5 6eecc8aa78f13a350c02f2e8b28aa2a0
BLAKE2b-256 1d4c2937a4894edf915b22f19207929161904cfea5a342f6b200ee28a6563585

See more details on using hashes here.

File details

Details for the file helloledger-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: helloledger-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for helloledger-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8593c5720852516b48b35f261c54694ea6a285e341d8fae1f869305c471e2db0
MD5 ea329cd64b24881835b98f2db747fc2d
BLAKE2b-256 76d9ec01d8b5ed5f74fcd7c8b4c081d087530477d99c70ee6a947af3fc58e981

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