Skip to main content

Library for zenmoney.ru API

Project description

ZenMoney Python Library

A Python library for interacting with the ZenMoney API. This library provides a simple and intuitive interface to work with ZenMoney's financial management platform.

Features

  • OAuth2 authentication
  • Synchronization with ZenMoney server
  • Support for all ZenMoney API endpoints
  • Type-safe models for request/response data
  • Error handling and exception management

Installation

You can install the library using pip:

pip install zenmoney-py

Requirements

  • Python 3.10 or higher
  • requests >= 2.32.3

Quick Start

Here's a simple example of how to use the library:

import time
from zenmoney import ZenmoneyOAuth2, ZenmoneyRequest
from zenmoney.models import Diff

# Initialize OAuth2 client
oauth = ZenmoneyOAuth2(
    consumer_key='your_consumer_key',
    consumer_secret='your_consumer_secret',
    username='your_username',
    password='your_password'
)

# Create API client
zenmoney_client = ZenmoneyRequest(oauth.token.access_token)

# Prepare synchronization parameters
server_timestamp = 0
current_timestamp = int(time.time())
params = Diff(
    server_timestamp=server_timestamp,
    current_client_timestamp=current_timestamp,
)

# Get data from ZenMoney
data = zenmoney_client.diff(params=params)

Authentication

The library uses OAuth2 for authentication. You'll need to provide:

  • Consumer Key
  • Consumer Secret
  • Username
  • Password

These credentials can be obtained from your ZenMoney account settings.

Available Endpoints

The library supports the two main ZenMoney API endpoints:

Diff Endpoint

The diff endpoint is used for synchronization with the ZenMoney server. It allows you to:

  • Get the latest changes from the server
  • Send your local changes to the server
  • Maintain data consistency between client and server

Example usage:

# Get server changes
data = zenmoney_client.diff(params=Diff(
    server_timestamp=0,
    current_client_timestamp=int(time.time())
))

Suggest Endpoint

The suggest endpoint helps with transaction categorization and payee suggestions. It can:

  • Suggest categories for transactions
  • Recommend payees based on transaction details
  • Help with transaction tagging

Example usage:

# Get suggestions for a transaction
suggestions = zenmoney_client.raw_suggest({
    "payee": "McDonalds"
})

Development

To set up the development environment:

  1. Install uv if you haven't already.

  2. Clone the repository:

git clone https://github.com/cooper30/zenmoney_lib.git
cd zenmoney_lib
  1. Install dependencies and create virtual environment:
uv sync
  1. Run tests:
uv run pytest
  1. Lint and format code:
uv run ruff check .
uv run ruff format .
  1. Install pre-commit hooks (optional, but recommended):
uv run pre-commit install

After that, ruff and pytest will run automatically on each commit.

CI

GitHub Actions workflows:

  • codestyle — ruff check + ruff format (on PR to develop/master)
  • test — pytest on Python 3.10, 3.11, 3.12 (on PR and push to develop/master)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

zenmoney_py-2.0.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

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

zenmoney_py-2.0.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file zenmoney_py-2.0.0.tar.gz.

File metadata

  • Download URL: zenmoney_py-2.0.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for zenmoney_py-2.0.0.tar.gz
Algorithm Hash digest
SHA256 6b9c64953b7eec0cf6ccd8882e3324395b3e876ac5e06090174749d2cbbc578b
MD5 8d73468a942c306af60d30d81a18eda7
BLAKE2b-256 80698783e316939586b2db4842a7512f9a8f087e8edbadd40392d6697440c6f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for zenmoney_py-2.0.0.tar.gz:

Publisher: publish.yml on nzvekov/zenmoney_lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zenmoney_py-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: zenmoney_py-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for zenmoney_py-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3387f3b2ed84529daaa694035648d1a9e4eb2e2d94ee82752bb1eda396756d77
MD5 8a93a058b5b6f75e45d9adf7747df178
BLAKE2b-256 bb9b6a1563fde1b889ebd0563906b4c54d4ed737b513aba2af6d16b8a46a2773

See more details on using hashes here.

Provenance

The following attestation bundles were made for zenmoney_py-2.0.0-py3-none-any.whl:

Publisher: publish.yml on nzvekov/zenmoney_lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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