Skip to main content

Python gRPC client for Janus

Project description

janus-ledger

Python gRPC client for the Janus double-entry accounting engine.

Install

pip install janus-ledger

Quick Start

from janus import Janus

ledger = Janus(server_url="your-janus-server:50051")

# Create an entity — every book belongs to an entity
entity = ledger.create_entity(external_id="org-1", name="Acme Corp")

# Create books
ledger.create_book(name="Cash", book_type="asset", currency="USD", entity_external_id="org-1")
ledger.create_book(name="Revenue", book_type="liability", currency="USD", entity_external_id="org-1")

entry = ledger.create_journal_entry(
    idempotency_key="sale-001",
    book_entries=[
        {"book": "cash", "debit": 10000},
        {"book": "revenue", "credit": 10000},
    ],
)

balance = ledger.get_balance("cash")
print(f"Cash balance: {balance.balance} {balance.currency}")
# => Cash balance: 10000 USD

Configuration

Parameter Description
server_url gRPC server address (e.g., your-janus-server:50051)

API Reference

Janus(server_url)

Create a client connected to your Janus server.

Entities

Method Description
create_entity(external_id, name, description?, metadata?) Create a new entity. Returns Entity.
get_entity(external_id_or_id) Get an entity by external ID or UUID. Returns Entity or None.
list_entities() List all entities. Returns list[Entity].

Books

Method Description
create_book(name, book_type, currency, entity_external_id, metadata?) Create a new book. Returns Book.
get_book(type_or_id) Get a book by type or ID. Returns Book or None.
list_books(book_type?, limit?, offset?) List books with optional filters. Returns list[Book].

Journal Entries

Method Description
create_journal_entry(idempotency_key, book_entries, ...) Create a journal entry. Returns JournalEntry.
reverse_journal_entry(entry_id, idempotency_key, reason?) Reverse a journal entry. Returns JournalEntry.
get_journal_entry(entry_id) Get a journal entry by ID. Returns JournalEntry or None.
get_journal_entry_by_key(idempotency_key) Get by idempotency key. Returns JournalEntry or None.

Balances

Method Description
get_balance(book, as_of?) Get the balance of a book. Returns BalanceResult.
get_balances(books, as_of?) Get balances for multiple books. Returns list[BalanceResult].

License

MIT

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

janus_ledger-0.1.2.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

janus_ledger-0.1.2-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file janus_ledger-0.1.2.tar.gz.

File metadata

  • Download URL: janus_ledger-0.1.2.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for janus_ledger-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d737b511faa298fcc9613f02b611b047390a041ae27858613b9b5a29e9e49e9a
MD5 47f47471cf14c4a7b264b793d767e3fd
BLAKE2b-256 527c114322b459a4f74a505b3658b6b90a4bd34259255a5f5c165032e102b4d7

See more details on using hashes here.

File details

Details for the file janus_ledger-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: janus_ledger-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for janus_ledger-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 de19fe6bd870eb240e5854d3597315a356352cad5b988967386e87fc64e55792
MD5 0109c7405cfe0b9a9250f7dfd380b26e
BLAKE2b-256 208be6f8aa53fbc0021972353ce4ebe33649b8f9d562b5aaf2f3504026b29db2

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