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

Uploaded Python 3

File details

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

File metadata

  • Download URL: janus_ledger-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 39a222a6f49bec16cc097a53b5903eed4868310e7d9185ed861d659b697ff878
MD5 3081c0dbf4fd3a2eab56ba6373689fd4
BLAKE2b-256 32b0aa67eba13e34401ac65cd9fc45757424544e5e93d2a4ef8c30789dfcbe5f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: janus_ledger-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2833204452c6ea9d2d36699bfc0699b7baa7208a93594f6c8d88651ea0fbf96f
MD5 79594925813984e08c07aab278203d3a
BLAKE2b-256 d0fc9a00b423618f7af62f86a7c58154f95cfff96818bce57fd11235a8d6ed6e

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