Unofficial YooMoney API python library
Project description
YooMoney API
Unofficial Python library for the YooMoney API
Introduction
This library provides a convenient Python wrapper around the YooMoney Wallet API. Both synchronous (Client) and asynchronous (AsyncClient) clients are included out of the box.
Features
Method |
Description |
|---|---|
Obtain an OAuth access token. |
|
Retrieve the current status of the user account. |
|
View the full or partial history of operations (paginated, reverse-chronological order). |
|
Get detailed information about a single operation. |
|
Generate a payment form that can be embedded into any website or blog. |
Installation
From PyPI (recommended):
pip install yoomoney --upgrade
Or with uv:
uv add yoomoney
From source:
git clone https://github.com/AlekseyKorshuk/yoomoney-api --recursive
cd yoomoney-api
uv sync
Quick start
Access token
First of all you need to receive an access token.
Log in to your YooMoney wallet. If you do not have one, create it.
Go to the App registration page.
Set the application parameters. Save CLIENT_ID and REDIRECT_URI for the next steps.
Click Confirm.
Replace the placeholders below with your real credentials, choose the required scopes, and run the code.
Follow the on-screen instructions.
from yoomoney import Authorize
Authorize(
client_id="YOUR_CLIENT_ID",
redirect_uri="YOUR_REDIRECT_URI",
client_secret="YOUR_CLIENT_SECRET",
scope=[
"account-info",
"operation-history",
"operation-details",
"incoming-transfers",
"payment-p2p",
"payment-shop",
],
)
You are done with the most difficult part!
Account information
Replace YOUR_TOKEN and run:
from yoomoney import Client
client = Client("YOUR_TOKEN")
user = client.account_info()
print("Account number:", user.account)
print("Account balance:", user.balance)
print("Currency (ISO 4217):", user.currency)
print("Account status:", user.account_status)
print("Account type:", user.account_type)
print("Extended balance information:")
for key, value in vars(user.balance_details).items():
print(f" {key}: {value}")
print("Linked bank cards:")
if user.cards_linked:
for card in user.cards_linked:
print(f" {card.pan_fragment} — {card.type}")
else:
print(" No cards linked")
Account number: 410019014512803
Account balance: 999999999999.99
Currency (ISO 4217): 643
Account status: identified
Account type: personal
Extended balance information:
total: 999999999999.99
available: 999999999999.99
deposition_pending: None
blocked: None
debt: None
hold: None
Linked bank cards:
No cards linked
Operation history
Replace YOUR_TOKEN and run:
from yoomoney import Client
client = Client("YOUR_TOKEN")
history = client.operation_history()
print("List of operations:")
print("Next page starts with:", history.next_record)
for op in history.operations:
print()
print(f"Operation: {op.operation_id}")
print(f" Status : {op.status}")
print(f" Datetime : {op.datetime}")
print(f" Title : {op.title}")
print(f" Pattern id : {op.pattern_id}")
print(f" Direction : {op.direction}")
print(f" Amount : {op.amount}")
print(f" Label : {op.label}")
print(f" Type : {op.type}")
List of operations:
Next page starts with: None
Operation: 670278348725002105
Status : success
Datetime : 2021-10-10 10:10:10
Title : Пополнение с карты ****4487
Pattern id : None
Direction : in
Amount : 100500.0
Label : 3784030974
Type : deposition
Operation: 670244335488002313
Status : success
Datetime : 2021-10-10 10:10:10
Title : Перевод от 410019014512803
Pattern id : p2p
Direction : in
Amount : 100500.0
Label : 7920963969
Type : incoming-transfer
Operation details
Replace YOUR_TOKEN and OPERATION_ID (e.g. 670244335488002312) and run:
from yoomoney import Client
client = Client("YOUR_TOKEN")
details = client.operation_details(operation_id="OPERATION_ID")
for key, value in vars(details).items():
if not key.startswith("_"):
print(f"{key:20s} : {str(value).replace(chr(10), ' ')}")
operation_id : 670244335488002312
status : success
pattern_id : p2p
direction : in
amount : 100500.0
amount_due : None
fee : None
datetime : 2021-10-10 10:10:10
title : Перевод от 410019014512803
sender : 410019014512803
recipient : None
recipient_type : None
message : Justtext
comment : None
codepro : False
protection_code : None
expires : None
answer_datetime : None
label : 7920963969
details : Justtext
type : incoming-transfer
digital_goods : None
Quickpay forms
from yoomoney import Quickpay
quickpay = Quickpay(
receiver="410019014512803",
quickpay_form="shop",
targets="Sponsor this project",
paymentType="SB",
sum=150,
)
print(quickpay.base_url)
print(quickpay.redirected_url)
https://yoomoney.ru/quickpay/confirm.xml?receiver=410019014512803&quickpay-form=shop&targets=Sponsor%20this%20project&paymentType=SB&sum=150
https://yoomoney.ru/transfer/quickpay?requestId=343532353937313933395f66326561316639656131626539326632616434376662373665613831373636393537613336383639
Async client
An asynchronous client (AsyncClient) exposes the same API as the synchronous Client, but every method is a coroutine. Use it as an async with context manager so the underlying connection pool is closed properly.
Async account information
import asyncio
from yoomoney import AsyncClient
async def main():
async with AsyncClient("YOUR_TOKEN") as client:
user = await client.account_info()
print("Account number:", user.account)
print("Account balance:", user.balance)
print("Currency (ISO 4217):", user.currency)
print("Account status:", user.account_status)
print("Account type:", user.account_type)
print("Extended balance information:")
for key, value in vars(user.balance_details).items():
print(f" {key}: {value}")
print("Linked bank cards:")
if user.cards_linked:
for card in user.cards_linked:
print(f" {card.pan_fragment} — {card.type}")
else:
print(" No cards linked")
asyncio.run(main())
Async operation history
import asyncio
from yoomoney import AsyncClient
async def main():
async with AsyncClient("YOUR_TOKEN") as client:
history = await client.operation_history()
print("List of operations:")
print("Next page starts with:", history.next_record)
for op in history.operations:
print()
print(f"Operation: {op.operation_id}")
print(f" Status : {op.status}")
print(f" Datetime : {op.datetime}")
print(f" Title : {op.title}")
print(f" Pattern id : {op.pattern_id}")
print(f" Direction : {op.direction}")
print(f" Amount : {op.amount}")
print(f" Label : {op.label}")
print(f" Type : {op.type}")
asyncio.run(main())
Async operation details
import asyncio
from yoomoney import AsyncClient
async def main():
async with AsyncClient("YOUR_TOKEN") as client:
details = await client.operation_details(operation_id="OPERATION_ID")
for key, value in vars(details).items():
if not key.startswith("_"):
print(f"{key:20s} : {str(value).replace(chr(10), ' ')}")
asyncio.run(main())
License
This project is licensed under the GPL-3.0.
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 yoomoney-2.0.0.tar.gz.
File metadata
- Download URL: yoomoney-2.0.0.tar.gz
- Upload date:
- Size: 23.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d0b4ac9f51d6b02cd6f8df64d98e54e3dcaca6d22ff15b0cecae5821eff0af3
|
|
| MD5 |
d792615989060bec0f9c2e62744d8e6b
|
|
| BLAKE2b-256 |
2b9ed65086be063138d5ec148db1de9a30a2cba809e7274b5c7f964483bc2eeb
|
File details
Details for the file yoomoney-2.0.0-py3-none-any.whl.
File metadata
- Download URL: yoomoney-2.0.0-py3-none-any.whl
- Upload date:
- Size: 28.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb02070e3d07ae96299329dcf7b1c62b9d006e7138968f38fa52134b598c91d6
|
|
| MD5 |
ced1ee0a4ca12de2071d140b5f066c01
|
|
| BLAKE2b-256 |
7ef45efd642de7cdc799f71a2fd20161681d4710d355d553dbb4142f62b6a9bc
|