QIWI API#

class glQiwiApi.qiwi.clients.wrapper.QiwiWrapper(api_access_token: Optional[str] = None, phone_number: Optional[str] = None, secret_p2p: Optional[str] = None, cache_time_in_seconds: Union[float, int] = 0, *args: Any, **kwargs: Any)[source]#

Bases: object

For backward compatibility with glQiwiApi <= 1.1.4

__init__(api_access_token: Optional[str] = None, phone_number: Optional[str] = None, secret_p2p: Optional[str] = None, shim_server_url: Optional[str] = None) None[source]#
async get_balance(*, account_number: int = 1) glQiwiApi.types.amount.AmountWithCurrency[source]#
async get_nickname() glQiwiApi.qiwi.clients.wallet.types.nickname.NickName[source]#
async transactions(rows: int = 50, operation: glQiwiApi.qiwi.clients.wallet.types.transaction.TransactionType = TransactionType.ALL, sources: Optional[List[glQiwiApi.qiwi.clients.wallet.types.transaction.Source]] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, next_txn_date: Optional[datetime.datetime] = None, next_txn_id: Optional[int] = None) glQiwiApi.qiwi.clients.wallet.types.transaction.History[source]#

Method for receiving transactions on the account More detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/?http#payments_list

Parameters
  • rows – number of transactions you want to receive

  • operation – The type of operations in the report for selection.

  • sources – List of payment sources, for filter

  • start_date – The starting date for searching for payments. Used only in conjunction with end_date.

  • end_date – the end date of the search for payments. Used only in conjunction with start_date.

  • next_txn_id

  • next_txn_date

async transaction_info(transaction_id: Union[str, int], transaction_type: glQiwiApi.qiwi.clients.wallet.types.transaction.TransactionType) glQiwiApi.qiwi.clients.wallet.types.transaction.Transaction[source]#

Method for obtaining complete information about a transaction

Detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/?python#txn_info

Parameters
  • transaction_id

  • transaction_type – only IN or OUT

Returns

Transaction object

async get_restriction() List[glQiwiApi.qiwi.clients.wallet.types.restriction.Restriction][source]#

Method to check limits on your qiwi wallet Detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/?python#restrictions

Returns

List where the dictionary is located with restrictions, if there are no restrictions, it returns an empty list

async get_identification() glQiwiApi.qiwi.clients.wallet.types.identification.Identification[source]#

This method allows get your wallet identification data More detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/?http#ident

async check_transaction(amount: Union[int, float], transaction_type: glQiwiApi.qiwi.clients.wallet.types.transaction.TransactionType = TransactionType.IN, sender: Optional[str] = None, rows_num: int = 50, comment: Optional[str] = None) bool[source]#

[ NON API METHOD ]

Method for verifying a transaction. This method uses self.transactions (rows = rows) “under the hood” to check payment.

For a little optimization, you can decrease rows by setting it, however, this does not guarantee the correct result

Possible values for the transaction_type parameter:
  • ‘IN’

  • ‘OUT’

  • ‘QIWI_CARD’

Parameters
  • amount – amount of payment

  • transaction_type – type of payment

  • sender – number of receiver

  • rows_num – number of payments to be checked

  • comment – comment by which the transaction will be verified

async check_whether_transaction_exists(check_fn: Callable[[glQiwiApi.qiwi.clients.wallet.types.transaction.Transaction], bool], rows_num: int = 50) bool[source]#
async get_limits(limit_types: List[str] = ['TURNOVER', 'REFILL', 'PAYMENTS_P2P', 'PAYMENTS_PROVIDER_INTERNATIONALS', 'PAYMENTS_PROVIDER_PAYOUT', 'WITHDRAW_CASH']) Dict[str, glQiwiApi.qiwi.clients.wallet.types.limit.Limit][source]#

Function for getting limits on the qiwi wallet account Returns wallet limits as a list, if there is no limit for a certain country, then it does not include it in the list Detailed documentation:

https://developer.qiwi.com/ru/qiwi-wallet-personal/?http#limits

async get_list_of_cards() List[glQiwiApi.qiwi.clients.wallet.types.qiwi_master.Card][source]#
async authenticate(birth_date: str, first_name: str, last_name: str, middle_name: str, passport: str, oms: Optional[str] = None, inn: Optional[str] = None, snils: Optional[str] = None) Dict[str, Any][source]#

This request allows you to transfer_money data to identify your QIWI wallet. It is allowed to identify no more than 5 wallets per owner

To identify the wallet, you must transfer_money your full name, passport series number and date of birth. If the data has been verified, then the response will display your TIN and simplified wallet identification will be installed. If the data has not been verified, the wallet remains in the “Minimum” status.

Parameters
  • birth_date – Date of birth as a format string 1998-02-11

  • first_name – First name

  • last_name – Last name

  • middle_name – Middle name

  • passport – Series / Number of the passport. Ex: 4400111222

  • oms

  • snils

  • inn

async get_receipt(transaction_id: Union[str, int], transaction_type: glQiwiApi.qiwi.clients.wallet.types.transaction.TransactionType, file_format: str = 'PDF') glQiwiApi.types.arbitrary.file.File[source]#

Method for receiving a receipt in byte format or file.

Possible transaction_type values:
  • ‘IN’

  • ‘OUT’

  • ‘QIWI_CARD’

Parameters
  • transaction_id – transaction id, can be obtained by calling the transfer_money method, transfer_money_to_card

  • transaction_type – type of transaction: ‘IN’, ‘OUT’, ‘QIWI_CARD’

  • file_format – format of file

async get_account_info() glQiwiApi.qiwi.clients.wallet.types.account_info.UserProfile[source]#
async fetch_statistics(start_date: datetime.datetime, end_date: datetime.datetime, operation: glQiwiApi.qiwi.clients.wallet.types.transaction.TransactionType = TransactionType.ALL, sources: Optional[List[str]] = None) glQiwiApi.qiwi.clients.wallet.types.stats.Statistic[source]#

This query is used to get summary statistics by the amount of payments for a given period. More detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/?http#payments_list

:param start_date:The start date of the statistics period. :param end_date: End date of the statistics period. :param operation: The type of operations taken into account when calculating statistics.

Allowed values:

ALL - все операции, IN - только пополнения, OUT - только платежи, QIWI_CARD - только платежи по картам QIWI (QVC, QVP). По умолчанию ALL.

Parameters

sources – The sources of payments QW_RUB - рублевый счет кошелька, QW_USD - счет кошелька в долларах, QW_EUR - счет кошелька в евро, CARD - привязанные и непривязанные к кошельку банковские карты, MK - счет мобильного оператора. Если не указан, учитываются все источники платежа.

async list_of_balances() List[glQiwiApi.qiwi.clients.wallet.types.balance.Balance][source]#

The request gets the current account balances of your QIWI Wallet. More detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/?http#balances_list

async create_new_balance(currency_alias: str) Dict[str, bool][source]#

The request creates a new account and balance in your QIWI Wallet

Parameters

currency_alias – New account alias

async available_balances() List[glQiwiApi.qiwi.clients.wallet.types.balance.AvailableBalance][source]#

The request displays account aliases, available for creation in your QIWI Wallet

async set_default_balance(currency_alias: str) Dict[Any, Any][source]#

The request sets up an account for your QIWI Wallet, whose balance will be used for funding all payments by default. The account must be contained in the list of accounts, you can get the list by calling get_list_of_balances method

Parameters

currency_alias

to_wallet(to_number: str, amount: Union[int, float, str], currency: str = '643', comment: Optional[str] = None) glQiwiApi.qiwi.clients.wallet.types.payment_info.PaymentInfo[source]#
async transfer_money(to_phone_number: str, amount: Union[int, float, str], comment: Optional[str] = None) glQiwiApi.qiwi.clients.wallet.types.payment_info.PaymentInfo[source]#

Method for transferring funds to wallet

Detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/?python#p2p

Parameters
  • to_phone_number – recipient number

  • amount – the amount of money you want to transfer

  • comment – payment comment

to_card(trans_sum: Union[float, int], to_card: str) glQiwiApi.qiwi.clients.wallet.types.payment_info.PaymentInfo[source]#
async transfer_money_to_card(card_number: str, *, amount: Union[int, float]) glQiwiApi.qiwi.clients.wallet.types.payment_info.PaymentInfo[source]#

Method for sending funds to the card.

More detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/#cards

async predict_commission(to_account: str, pay_sum: Union[int, float]) glQiwiApi.qiwi.clients.wallet.types.commission.Commission[source]#

Full calc_commission of QIWI Wallet is refunded for payment in favor of the specified provider taking into account all tariffs for a given set of payment details.

Parameters
  • to_account

  • pay_sum

Returns

Commission object

async get_cross_rates() List[glQiwiApi.qiwi.clients.wallet.types.other.CrossRate][source]#

The method returns the current exchange rates and cross-rates of the QIWI Bank’s currencies.

async payment_by_payment_details(payment_sum: glQiwiApi.types.amount.AmountWithCurrency, payment_method: glQiwiApi.qiwi.clients.wallet.types.other.PaymentMethod, fields: glQiwiApi.qiwi.clients.wallet.types.other.PaymentDetails, payment_id: Optional[str] = None) glQiwiApi.qiwi.clients.wallet.types.payment_info.PaymentInfo[source]#

Payment for services of commercial organizations according to their bank details.

Parameters
  • payment_id – payment id, if not transmitted, is used uuid4 by default

  • payment_sum – a Sum object, which indicates the amount of the payment

  • payment_method – payment method

  • fields – payment details

async buy_qiwi_master() glQiwiApi.qiwi.clients.wallet.types.payment_info.PaymentInfo[source]#

Method for buying QIWI Master package To call API methods, you need the QIWI Wallet API token with permissions to do the following: 1. Management of virtual cards, 2. Request information about the wallet profile, 3. View payment history, 4. Making payments without SMS. You can choose these rights when creating a new api token, to use api QIWI Master

async issue_qiwi_master_card(card_alias: str = 'qvc-cpa') Optional[glQiwiApi.qiwi.clients.wallet.types.qiwi_master.OrderDetails][source]#

Issuing a new card using the Qiwi Master API

When issuing a card, 3, and possibly 3 requests are made, namely, according to the following scheme:

  • _create_card_purchase_order - this method creates a request

  • _confirm_qiwi_master_purchase_order - confirms the issue of the card

  • _buy_new_qiwi_master_card - buys a new card, if such a card is not free

Detailed documentation: https://developer.qiwi.com/ru/qiwi-wallet-personal/#qiwi-master-issue-card

async register_webhook(web_url: str, txn_type: int = 2) glQiwiApi.qiwi.clients.wallet.types.webhooks.WebhookInfo[source]#

This method register a new webhook

Parameters
  • web_url – service endpoint

  • txn_type – 0 => incoming, 1 => outgoing, 2 => all

Returns

Active Hooks

async get_current_webhook() glQiwiApi.qiwi.clients.wallet.types.webhooks.WebhookInfo[source]#

List of active (active) notification handlers, associated with your wallet can be obtained with this request. Since now only one type of hook is used - webhook, then the response contains only one data object

async send_test_notification() Dict[str, Any][source]#

Use this request to test your webhooks handler. Test notification is sent to the address specified during the call register_webhook

async get_webhook_secret_key(hook_id: str) str[source]#

Each notification contains a digital signature of the message, encrypted with a key. To obtain a signature verification key, use this request.

Parameters

hook_id – UUID of webhook

Returns

Base64 encoded key

async delete_current_webhook() Dict[str, Any][source]#

Method to delete webhook

async change_webhook_secret(hook_id: str) str[source]#

Use this request to change the encryption key for notifications.

Parameters

hook_id – UUID of webhook

Returns

Base64 encoded key

async bind_webhook(url: Union[str, WebhookURL], transactions_type: int = 2, *, send_test_notification: bool = False, delete_old: bool = False) Tuple[glQiwiApi.qiwi.clients.wallet.types.webhooks.WebhookInfo, str][source]#

[NON-API] EXCLUSIVE method to register new webhook or get old

Parameters
  • url – service endpoint

  • transactions_type – 0 => incoming, 1 => outgoing, 2 => all

  • send_test_notification – test_qiwi will transfer_money you test webhook update

  • delete_old – boolean, if True - delete old webhook

Returns

Tuple of Hook and Base64-encoded key

async detect_mobile_operator(phone_number: str) glQiwiApi.qiwi.clients.wallet.types.mobile_operator.MobileOperator[source]#
async reject_bill_by_id(bill_id: str) glQiwiApi.qiwi.clients.p2p.types.Bill[source]#

Use this method to cancel unpaid invoice.

async reject_bill(bill: glQiwiApi.qiwi.clients.p2p.types.Bill) glQiwiApi.qiwi.clients.p2p.types.Bill[source]#
async check_p2p_bill_status(bill_id: str) str[source]#

Method for checking the status of a p2p transaction.

Possible transaction types:

WAITING Bill is waiting for pay

PAID Bill was paid

REJECTED Bill was rejected

EXPIRED The bill has expired. Invoice not paid

Docs: https://developer.qiwi.com/ru/p2p-payments/?shell#invoice-status

Parameters

bill_id

Returns

status of bill

async check_if_bill_was_paid(bill: glQiwiApi.qiwi.clients.p2p.types.Bill) bool[source]#
async create_p2p_bill(amount: Union[int, float], bill_id: Optional[str] = None, comment: Optional[str] = None, life_time: Optional[datetime.datetime] = None, theme_code: Optional[str] = None, pay_source_filter: Optional[List[str]] = None, customer: Optional[glQiwiApi.qiwi.clients.p2p.types.Customer] = None) glQiwiApi.qiwi.clients.p2p.types.Bill[source]#

It is the reliable method for integration. Parameters are sent by means of server2server requests with authorization. Method allows you to issue an invoice, successful

response contains payUrl link to redirect client on Payment Form.

Possible values of pay_source_filter:
  • ‘qw’

  • ‘card’

  • ‘mobile’

Parameters
  • amount – amount of payment

  • bill_id – unique transaction number, if not transmitted, generated automatically,

  • life_time – the date until which the invoice will be available for payment.

  • comment

  • theme_code

  • pay_source_filter – When you open the form, the following will be displayed only the translation methods specified in this parameter

  • customer

async retrieve_bills(rows: int, statuses: str = 'READY_FOR_PAY') List[glQiwiApi.qiwi.clients.p2p.types.Bill][source]#

A method for getting a list of your wallet’s outstanding bills.

The list is built in reverse chronological order.

By default, the list is paginated with 50 items each, but you can specify a different number of elements (no more than 50).

Filters by billing time can be used in the request, the initial account identifier.

async pay_the_invoice(invoice_uid: str, currency: str) glQiwiApi.qiwi.clients.p2p.types.InvoiceStatus[source]#

Execution of unconditional payment of the invoice without SMS-confirmation.

! Warning ! To use this method correctly you need to tick “Проведение платежей без SMS” when registering QIWI API and retrieve token

Parameters
  • invoice_uid – Bill ID in QIWI system

  • currency

async refund_bill(bill_id: Union[str, int], refund_id: Union[str, int], json_bill_data: Union[glQiwiApi.types.amount.PlainAmount, Dict[str, Union[str, int]]]) glQiwiApi.qiwi.clients.p2p.types.RefundedBill[source]#
The method allows you to make a refund on a paid invoice.

in the JSON body of the request for the json_bill_data parameter: amount.value - refund amount. amount.currency - return currency.

Can be a dictionary or an OptionalSum object

Dictionary example: {

“amount”: {

“currency”: “RUB”, “value”: 1 }

}

Parameters
  • bill_id – unique account identifier in the merchant’s system

  • refund_id – unique identifier of the refund in the merchant’s system.

  • json_bill_data

Returns

RefundBill object

async create_p2p_keys(key_pair_name: str, server_notification_url: Optional[str] = None) glQiwiApi.qiwi.clients.p2p.types.PairOfP2PKeys[source]#

Creates a new pair of P2P keys to interact with P2P QIWI API

Parameters
  • key_pair_name – P2P token pair name

  • server_notification_url – endpoint for webhooks

create_shim_url(invoice_uid: str) str[source]#
async close() None[source]#
class glQiwiApi.qiwi.clients.wallet.client.QiwiWallet(api_access_token: str, phone_number: Optional[str] = None, request_service_factory: Optional[Callable[[...], Union[Awaitable[RequestServiceProto], RequestServiceProto]]] = None)[source]#

Bases: glQiwiApi.core.abc.base_api_client.BaseAPIClient

__init__(api_access_token: str, phone_number: Optional[str] = None, request_service_factory: Optional[Callable[[...], Union[Awaitable[RequestServiceProto], RequestServiceProto]]] = None) None[source]#
Parameters
  • api_access_token – QIWI API token received from https://qiwi.com/api

  • phone_number – your phone number starting with +

async get_profile(*args: Any, **kw: Any) Any#
async authenticate(*args: Any, **kw: Any) Any#
async get_identification(*args: Any, **kw: Any) Any#
async get_limits(*args: Any, **kw: Any) Any#
async get_restrictions(*args: Any, **kw: Any) Any#
async history(*args: Any, **kw: Any) Any#
async check_whether_transaction_exists(*args: Any, **kw: Any) Any#
async fetch_statistics(*args: Any, **kw: Any) Any#
async get_transaction_info(*args: Any, **kw: Any) Any#
async get_receipt(*args: Any, **kw: Any) Any#
async get_list_of_balances(*args: Any, **kw: Any) Any#
async get_balance(*args: Any, **kw: Any) Any#
async create_new_balance(*args: Any, **kw: Any) Any#
async detect_mobile_operator(*args: Any, **kw: Any) Any#
async get_list_of_cards(*args: Any, **kw: Any) Any#
async get_available_balances(*args: Any, **kw: Any) Any#
async set_default_balance(*args: Any, **kw: Any) Any#
async transfer_money(*args: Any, **kw: Any) Any#
async transfer_money_to_card(*args: Any, **kw: Any) Any#
async detect_card_id(*args: Any, **kw: Any) Any#
async predict_commission(*args: Any, **kw: Any) Any#
async get_cross_rates(*args: Any, **kw: Any) Any#
async payment_by_payment_details(*args: Any, **kw: Any) Any#
async buy_qiwi_master_package(*args: Any, **kw: Any) Any#
async issue_qiwi_master_card(*args: Any, **kw: Any) Any#
async get_qiwi_master_card_statement(*args: Any, **kw: Any) Any#
async block_qiwi_master_card(*args: Any, **kw: Any) Any#
async unblock_qiwi_master_card(*args: Any, **kw: Any) Any#
async get_qiwi_master_card_requisites(*args: Any, **kw: Any) Any#
async rename_qiwi_master_card(*args: Any, **kw: Any) Any#
async get_nickname(*args: Any, **kw: Any) Any#
async list_of_invoices(*args: Any, **kw: Any) Any#
async pay_the_invoice(*args: Any, **kw: Any) Any#
async register_webhook(*args: Any, **kw: Any) Any#
async get_current_webhook(*args: Any, **kw: Any) Any#
async send_test_webhook_notification(*args: Any, **kw: Any) Any#
async get_webhook_secret_key(*args: Any, **kw: Any) Any#
async delete_current_webhook(*args: Any, **kw: Any) Any#
async generate_new_webhook_secret(*args: Any, **kw: Any) Any#
async bind_webhook(*args: Any, **kw: Any) Any#
property phone_number_without_plus_sign: str#
class glQiwiApi.qiwi.clients.p2p.client.QiwiP2PClient(secret_p2p: str, request_service_factory: Optional[Callable[[...], Union[Awaitable[glQiwiApi.core.request_service.RequestServiceProto], glQiwiApi.core.request_service.RequestServiceProto]]] = None, shim_server_url: Optional[str] = None)[source]#

Bases: glQiwiApi.core.abc.base_api_client.BaseAPIClient

__init__(secret_p2p: str, request_service_factory: Optional[Callable[[...], Union[Awaitable[glQiwiApi.core.request_service.RequestServiceProto], glQiwiApi.core.request_service.RequestServiceProto]]] = None, shim_server_url: Optional[str] = None) None[source]#
Parameters
async get_bill_by_id(*args: Any, **kw: Any) Any#
async check_if_bill_was_paid(*args: Any, **kw: Any) Any#
async get_bill_status(*args: Any, **kw: Any) Any#
async create_p2p_bill(*args: Any, **kw: Any) Any#
async reject_bill(*args: Any, **kw: Any) Any#
async reject_p2p_bill(*args: Any, **kw: Any) Any#
async create_pair_of_p2p_keys(*args: Any, **kw: Any) Any#
async refund_bill(*args: Any, **kw: Any) Any#
create_shim_url(bill_or_invoice_uid: Union[glQiwiApi.qiwi.clients.p2p.types.Bill, str]) str[source]#