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.1.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.1-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: janus_ledger-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 280f6f1cc7593c7b6ed2b516c00fa26d148b4f911e8fdfcfdcaebfe6cb838210
MD5 02cf8818bc3ca1b0c791883d445c367a
BLAKE2b-256 a42c701f4d5d228be6acd0fd07b766dee9dc7440cf1534acac7603671b12d723

See more details on using hashes here.

File details

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

File metadata

  • Download URL: janus_ledger-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bf2da7d5adff347cd1604218dcfc1d3a903decc96634fdeeaf423ce128e689c1
MD5 e1c86d600967f4f3d84d0c2d0da432c9
BLAKE2b-256 b482b0996306c2a08d992d9e0470174ddd820f01bb4b7f08bca4866178e8117c

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