Unofficial YooMoney API python library

Overview

API Yoomoney - unofficial python library

This is an unofficial YooMoney API python library.

Summary

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 yoomoney --upgrade

You can install from source with:

git clone https://github.com/AlekseyKorshuk/yoomoney-api --recursive
cd yoomoney-api
python setup.py 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 and REDIRECT_URI insted of YOUR_CLIENT_ID and YOUR_REDIRECT_URI. Choose scopes and run code.
  6. Follow all steps from the program.
from yoomoney import Authorize

Authorize(
      client_id="YOUR_CLIENT_ID",
      redirect_uri="YOUR_REDIRECT_URI",
      scope=["account-info",
             "operation-history",
             "operation-details",
             "incoming-transfers",
             "payment-p2p",
             "payment-shop",
             ]
      )

You are done with the most difficult part!

Account information

Paste YOUR_TOKEN and run this code:

from yoomoney import Client

token = "YOUR_TOKEN"

client = Client(token)

user = client.account_info()

print("Account number:", user.account)
print("Account balance:", user.balance)
print("Account currency code in ISO 4217 format:", user.currency)
print("Account status:", user.account_status)
print("Account type:", user.account_type)

print("Extended balance information:")
for pair in vars(user.balance_details):
    print("\t-->", pair, ":", vars(user.balance_details).get(pair))

print("Information about linked bank cards:")
cards = user.cards_linked

if len(cards) != 0:
    for card in cards:
        print(card.pan_fragment, " - ", card.type)
else:
    print("No card is linked to the account")

Output:

Account number: 410019014512803
Account balance: 999999999999.99
Account currency code in ISO 4217 format: 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
Information about linked bank cards:
No card is linked to the account

Operation history

Paste YOUR_TOKEN and run this code:

from yoomoney import Client

token = "YOUR_TOKEN"

client = Client(token)

history = client.operation_history()

print("List of operations:")
print("Next page starts with: ", history.next_record)

for operation in history.operations:
    print()
    print("Operation:",operation.operation_id)
    print("\tStatus     -->", operation.status)
    print("\tDatetime   -->", operation.datetime)
    print("\tTitle      -->", operation.title)
    print("\tPattern id -->", operation.pattern_id)
    print("\tDirection  -->", operation.direction)
    print("\tAmount     -->", operation.amount)
    print("\tLabel      -->", operation.label)
    print("\tType       -->", operation.type)

Output:

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

Paste YOUR_TOKEN with an OPERATION_ID (example: 670244335488002312) from previous example output and run this code:

from yoomoney import Client

token = "YOUR_TOKEN"

client = Client(token)

details = client.operation_details(operation_id="OPERATION_ID")

properties = [i for i in details.__dict__.keys() if i[:1] != '_']

max_size = len(max(properties, key=len))

for prop in properties:
    print(prop, " " * (max_size - len(prop)), "-->", str(details.__getattribute__(prop)).replace('\n', ' '))

Output:

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

Run this code:

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)

Output:

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
You might also like...
TeslaPy - A Python implementation based on unofficial documentation of the client side interface to the Tesla Motors Owner API
TeslaPy - A Python implementation based on unofficial documentation of the client side interface to the Tesla Motors Owner API

TeslaPy - A Python implementation based on unofficial documentation of the client side interface to the Tesla Motors Owner API, which provides functiona

Unofficial instagram API, give you access to ALL instagram features (like, follow, upload photo and video and etc)! Write on python.

Instagram-API-python Unofficial Instagram API to give you access to ALL Instagram features (like, follow, upload photo and video, etc)! Written in Pyt

An unofficial Python wrapper for the 'Binance exchange REST API'

Welcome to binex_f v0.1.0 many interfaces are heavily used by myself in product environment, the websocket is reliable (re)connected. Latest version:

Unofficial Coinbase Python Library

Unofficial Coinbase Python Library Python Library for the Coinbase API for use with three legged oAuth2 and classic API key usage Version 0.3.0 Requir

✖️ Unofficial API of 1337x.to
✖️ Unofficial API of 1337x.to

✖️ Unofficial Python API Wrapper of 1337x This is the unofficial API of 1337x. It supports all proxies of 1337x and almost all functions of 1337x. You

This is a simple unofficial async Api-wrapper for tio.run

Async-Tio This is a simple unofficial async Api-wrapper for tio.run

Unofficial API wrapper for seedr.cc

Seedr API Unofficial API wrapper for seedr.cc Inspired by theabbie's seedr-api Powered by @harp_tech (Telegram) How to use You can install lib via git

Easy Google Translate: Unofficial Google Translate API

easygoogletranslate Unofficial Google Translate API. This library does not need an api key or something else to use, it's free and simple. You can eit

Clash of Clans developer unofficial api Wrapper to generate ip based token

Clash of Clans developer unofficial api Wrapper to generate ip based token

Comments
  • Response token is empty. Repeated request for an authorization token

    Response token is empty. Repeated request for an authorization token

    Hi, how can I fix this exception? yoomoney.exceptions.EmptyToken: Response token is empty. Repeated request for an authorization token

    I have already another project where I did everything similar and token came. Now I need to change account so I authorize new application.

    opened by progerg 8
  • maximum recursion depth exceeded

    maximum recursion depth exceeded

    привет, такая проблема, когда запускаю твой код как в примере все работает, когда пытаюсь запихнуть тот же код в aiogram начинаются ошибки переполнения, не подскажешь как поправить? еще вот такие ошибки: RecursionError: maximum recursion depth exceeded ERROR:asyncio:Task exception was never retrieved

    opened by chkyratov 3
  • TypeError: string indices must be integers

    TypeError: string indices must be integers

    При запросе token = "xxx" client = Client(token) history = client.operation_history(label="ххххх") Получаю ошибку Traceback (most recent call last): File "/x/x/x/x.py", line 70, in ym_get history = client.operation_history() File "/usr/local/lib/python3.8/site-packages/yoomoney/client.py", line 44, in operation_history return History(base_url=self.base_url, File "/usr/local/lib/python3.8/site-packages/yoomoney/history/history.py", line 96, in __init__ for operation_data in data["operations"]: TypeError: string indices must be integers

    opened by VReunov 3
  • ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

    ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

    It throws an error when I try to check payments status. It was stable for 3-4 days, now it throws such an error.

    urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
    Sep 07 11:50:45 localhost python3.7[29515]: During handling of the above exception, another exception occurred:
    Sep 07 11:50:45 localhost python3.7[29515]: Traceback (most recent call last):
    Sep 07 11:50:45 localhost python3.7[29515]:   File "/usr/local/lib/python3.7/dist-packages/aiogram/dispatcher/dispatcher.py", line 409, in _process_polling_updates
    Sep 07 11:50:45 localhost python3.7[29515]:     for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
    Sep 07 11:50:45 localhost python3.7[29515]:   File "/usr/local/lib/python3.7/dist-packages/aiogram/dispatcher/dispatcher.py", line 238, in process_updates
    Sep 07 11:50:45 localhost python3.7[29515]:     return await asyncio.gather(*tasks)
    Sep 07 11:50:45 localhost python3.7[29515]:   File "/usr/local/lib/python3.7/dist-packages/aiogram/dispatcher/handler.py", line 116, in notify
    Sep 07 11:50:45 localhost python3.7[29515]:     response = await handler_obj.handler(*args, **partial_data)
    Sep 07 11:50:45 localhost python3.7[29515]:   File "/usr/local/lib/python3.7/dist-packages/aiogram/dispatcher/dispatcher.py", line 286, in process_update
    Sep 07 11:50:45 localhost python3.7[29515]:     return await self.callback_query_handlers.notify(update.callback_query)
    Sep 07 11:50:45 localhost python3.7[29515]:   File "/usr/local/lib/python3.7/dist-packages/aiogram/dispatcher/handler.py", line 116, in notify
    Sep 07 11:50:45 localhost python3.7[29515]:     response = await handler_obj.handler(*args, **partial_data)
    Sep 07 11:50:45 localhost python3.7[29515]:   File "/root/{}/handlers/general.py", line 199, in check_payment
    Sep 07 11:50:45 localhost python3.7[29515]:     if payment.is_paid():
    Sep 07 11:50:45 localhost python3.7[29515]:   File "/root/{}/models.py", line 91, in is_paid
    Sep 07 11:50:45 localhost python3.7[29515]:     if api.is_paid(self.label):
    Sep 07 11:50:45 localhost python3.7[29515]:   File "/root/{}/yandex_api.py", line 31, in is_paid
    Sep 07 11:50:45 localhost python3.7[29515]:     history = client.operation_history(label=label)
    Sep 07 11:50:45 localhost python3.7[29515]:   File "/usr/local/lib/python3.7/dist-packages/yoomoney/client.py", line 53, in operation_history
    Sep 07 11:50:45 localhost python3.7[29515]:     details=details,
    Sep 07 11:50:45 localhost python3.7[29515]:   File "/usr/local/lib/python3.7/dist-packages/yoomoney/history/history.py", line 72, in __init__
    Sep 07 11:50:45 localhost python3.7[29515]:     data = self._request()
    Sep 07 11:50:45 localhost python3.7[29515]:   File "/usr/local/lib/python3.7/dist-packages/yoomoney/history/history.py", line 177, in _request
    Sep 07 11:50:45 localhost python3.7[29515]:     response = requests.request("POST", url, headers=headers, data=payload)
    Sep 07 11:50:45 localhost python3.7[29515]:   File "/usr/local/lib/python3.7/dist-packages/requests/api.py", line 61, in request
    Sep 07 11:50:45 localhost python3.7[29515]:     return session.request(method=method, url=url, **kwargs)
    Sep 07 11:50:45 localhost python3.7[29515]:   File "/usr/local/lib/python3.7/dist-packages/requests/sessions.py", line 542, in request
    Sep 07 11:50:45 localhost python3.7[29515]:     resp = self.send(prep, **send_kwargs)
    Sep 07 11:50:45 localhost python3.7[29515]:   File "/usr/local/lib/python3.7/dist-packages/requests/sessions.py", line 655, in send
    Sep 07 11:50:45 localhost python3.7[29515]:     r = adapter.send(request, **kwargs)
    Sep 07 11:50:45 localhost python3.7[29515]:   File "/usr/local/lib/python3.7/dist-packages/requests/adapters.py", line 498, in send
    Sep 07 11:50:45 localhost python3.7[29515]:     raise ConnectionError(err, request=request)
    Sep 07 11:50:45 localhost python3.7[29515]: requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
    
    
    opened by bekha-io 1
Releases(v0.1.0)
Owner
Aleksey Korshuk
Telegram: https://t.me/goodimpression
Aleksey Korshuk
An API wrapper for Henrik's Unofficial VALORANT API

ValorantAPI.py An API wrapper for Henrik's Unofficial VALORANT API Warning!! This project is still in beta and only contains barely anything yet. If y

Jakkaphat Chalermphanaphan 0 Feb 4, 2022
This package accesses nitrotype's official api along with its unofficial user api

NitrotypePy This package accesses nitrotype's official api along with its unofficial user api. Currently still in development. Install To install, run

The Moon That Rises 2 Sep 4, 2022
The unofficial Amazon search CLI & Python API

amzSear The unofficial Amazon Product CLI & API. Easily search the amazon product directory from the command line without the need for an Amazon API k

Asher Silvers 95 Nov 11, 2022
🔍 Google Search unofficial API for Python with no external dependencies

Python Google Search API Unofficial Google Search API for Python. It uses web scraping in the background and is compatible with both Python 2 and 3. W

Avi Aryan 204 Dec 28, 2022
Unofficial Python wrapper for official Hacker News API

haxor Unofficial Python wrapper for official Hacker News API. Installation pip install haxor Usage Import and initialization: from hackernews import H

null 147 Sep 18, 2022
Unofficial Medium Python Flask API and SDK

PyMedium - Unofficial Medium API PyMedium is an unofficial Medium API written in python flask. It provides developers to access to user, post list and

Engine Bai 157 Nov 11, 2022
(unofficial) Googletrans: Free and Unlimited Google translate API for Python. Translates totally free of charge.

Googletrans Googletrans is a free and unlimited python library that implemented Google Translate API. This uses the Google Translate Ajax API to make

Suhun Han 3.2k Jan 4, 2023
Unofficial Python API client for Notion.so

notion-py Unofficial Python 3 client for Notion.so API v3. Object-oriented interface (mapping database tables to Python classes/attributes) Automatic

Jamie Alexandre 3.9k Jan 3, 2023
An Unofficial TikTok API Wrapper In Python

This is an unofficial api wrapper for TikTok.com in python. With this api you are able to call most trending and fetch specific user information as well as much more.

David Teather 2.9k Jan 8, 2023
Unofficial python api for MicroBT Whatsminer ASICs

whatsminer-api Unofficial python api for MicroBT Whatsminer ASICs Code adapted from a python file found in the Whatsminer Telegram group that is credi

Satoshi Anonymoto 16 Dec 23, 2022