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:
-
Install uv if you haven't already.
-
Clone the repository:
git clone https://github.com/cooper30/zenmoney_lib.git
cd zenmoney_lib
- Install dependencies and create virtual environment:
uv sync
- Run tests:
uv run pytest
- Lint and format code:
uv run ruff check .
uv run ruff format .
- 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
- Nikita Zvekov (hassler494@gmail.com)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b9c64953b7eec0cf6ccd8882e3324395b3e876ac5e06090174749d2cbbc578b
|
|
| MD5 |
8d73468a942c306af60d30d81a18eda7
|
|
| BLAKE2b-256 |
80698783e316939586b2db4842a7512f9a8f087e8edbadd40392d6697440c6f6
|
Provenance
The following attestation bundles were made for zenmoney_py-2.0.0.tar.gz:
Publisher:
publish.yml on nzvekov/zenmoney_lib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zenmoney_py-2.0.0.tar.gz -
Subject digest:
6b9c64953b7eec0cf6ccd8882e3324395b3e876ac5e06090174749d2cbbc578b - Sigstore transparency entry: 1181883363
- Sigstore integration time:
-
Permalink:
nzvekov/zenmoney_lib@c0cec325782ddd347cc5f6fc0b2720682e29787e -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/nzvekov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c0cec325782ddd347cc5f6fc0b2720682e29787e -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3387f3b2ed84529daaa694035648d1a9e4eb2e2d94ee82752bb1eda396756d77
|
|
| MD5 |
8a93a058b5b6f75e45d9adf7747df178
|
|
| BLAKE2b-256 |
bb9b6a1563fde1b889ebd0563906b4c54d4ed737b513aba2af6d16b8a46a2773
|
Provenance
The following attestation bundles were made for zenmoney_py-2.0.0-py3-none-any.whl:
Publisher:
publish.yml on nzvekov/zenmoney_lib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zenmoney_py-2.0.0-py3-none-any.whl -
Subject digest:
3387f3b2ed84529daaa694035648d1a9e4eb2e2d94ee82752bb1eda396756d77 - Sigstore transparency entry: 1181883368
- Sigstore integration time:
-
Permalink:
nzvekov/zenmoney_lib@c0cec325782ddd347cc5f6fc0b2720682e29787e -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/nzvekov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c0cec325782ddd347cc5f6fc0b2720682e29787e -
Trigger Event:
push
-
Statement type: