Skip to main content

Async Yoomoney API

Project description

API Yoomoney (async) - unofficial python library

This is an unofficial YooMoney API python library.

This repository was taken as a basis.

Introduction

This repository is based on the official documentation of YooMoney.

Features

Implemented methods:

  • Access token - Getting an access token
  • Account information - Getting information about the status of the user account.
  • Operation history - This method allows viewing the full or partial history of operations in page mode. History records are displayed in reverse chronological order (from most recent to oldest).
  • Operation details - Provides detailed information about a particular operation from the history.
  • Quickpay forms - The YooMoney form is a set of fields with information about a transfer. You can embed payment form into your interface (for instance, a website or blog). When the sender pushes the button, the details from the form are sent to YooMoney and an order for a transfer to your wallet is initiated.

Installation

You can install with:

pip install aioyoomoney-api

You can install from source with:

git clone https://github.com/Kokokoshmar/aioyoomoney-api
cd aioyoomoney-api
pip install .

Quick start

Access token

First of all we need to receive an access token.

  1. Log in to your YooMoney wallet with your username. If you do not have a wallet, create it.
  2. Go to the App registration page.
  3. Set the application parameters. Save CLIENT_ID and YOUR_REDIRECT_URI for net steps
  4. Click the Confirm button.
  5. Paste CLIENT_ID, REDIRECT_URI and CLIENT_SECRET insted of YOUR_CLIENT_ID, YOUR_REDIRECT_URI and YOUR_CLIENT_SECRET. Choose scopes and run code.
  6. Follow all steps from the program.
from aioyoomoney import authorize

token = authorize(
    client_id=CLIENT_ID,
    redirect_uri=REDIRECT_URI,
    client_secret=CLIENT_SECRET,
    scope=[
        "account-info",
        "operation-history",
        "operation-details",
        "incoming-transfers",
        "payment-p2p",
    ]
)

print(token)

You are done with the most difficult part!

Account information

Paste YOUR_TOKEN and run this code:

import asyncio

from aioyoomoney import Client


async def client_info():
    client = Client(YOUR_TOKEN)

    account = await client.account_info()

    print(f"Account: {account.id}")
    print(f"Balance: {account.balance}")
    print(f"Currency: {account.currency}")
    print(f"Account Status: {account.account_status}")
    print(f"Account Type: {account.account_type}")
    print(f"Balance Details: {account.balance_details}")
    print(f"Cards Linked: {account.cards_linked}")


asyncio.run(client_info())

Operation history

Paste YOUR_TOKEN and run this code:

import asyncio

from aioyoomoney import Client
from dataclasses import fields


async def get_operation_history():
    client = Client(YOUR_TOKEN)

    history = await client.operation_history()
    print("Next record:", history.next_record)
    for operation in history.operations:
        for field in fields(operation):
            if field.name != "kwargs":
                print(field.name, '->', operation[field.name])

        for key, value in operation.kwargs.items():
            print(key, '->', value)

        print("================================")


asyncio.run(get_operation_history())

Operation details

Paste YOUR_TOKEN with an OPERATION_ID (example: 670244335488002312):

import asyncio
from aioyoomoney import Client
from dataclasses import fields


async def get_operation_details():
    client = Client(YOUR_TOKEN)

    operation = await client.operation_details(OPERATION_ID)
    for field in fields(operation):
        if field.name != "kwargs":
            print(field.name, '->', operation[field.name])

    for key, value in operation.kwargs.items():
        print(key, '->', value)


asyncio.run(get_operation_details())

Quickpay forms

Run this code:

import asyncio
from aioyoomoney import Quickpay


async def quickpay():
    async with Quickpay(
        receiver="899999999999999",
        quickpay_form="shop",
        targets="Sponsor this project",
        payment_type="SB",
        sum=10,
        form_comment='test',
        label="label"
    ) as quickpay:
        print(quickpay.redirected_url)
        print(quickpay.base_url)
        print(quickpay.payload)


asyncio.run(quickpay())

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

aioyoomoney_api-0.0.9.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

aioyoomoney_api-0.0.9-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file aioyoomoney_api-0.0.9.tar.gz.

File metadata

  • Download URL: aioyoomoney_api-0.0.9.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for aioyoomoney_api-0.0.9.tar.gz
Algorithm Hash digest
SHA256 a1d4eccf844488cc50a4ee7a58ea736266a685bb032b52cab3478eb62e70d4f2
MD5 8bf3feebca55d5843a4708de58d5b981
BLAKE2b-256 0a980bdcc1ae05f6433154e57af916429dbadbad56645468f32868ec59a30524

See more details on using hashes here.

File details

Details for the file aioyoomoney_api-0.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for aioyoomoney_api-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 ec3e0601377f8ed0173e06c8ad4fbdd3665b3bcbd3a7a15f7b5d4a48f8986742
MD5 9568ccbca63fc0cd377c31d79dd096ec
BLAKE2b-256 aa7e7879c83c276c1e7c2ed6b08f023f2d79171882c8be4984cf4b514cb4f1ca

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