Skip to content

Latest commit

 

History

History
316 lines (253 loc) · 9.14 KB

_balance_en.html.md

File metadata and controls

316 lines (253 loc) · 9.14 KB

Wallet Balances API {#balance}

API provides methods to control balances of your QIWI wallet.

List of balances {#balances_list}

Provides current balances of your QIWI Wallet.

Interactive API

Request → GET

curl "https://edge.qiwi.com/funding-sources/v2/persons/<wallet>/accounts" \
  --header "Accept: application/json" \
  --header "Authorization: Bearer <API token>"
GET /funding-sources/v2/persons/<wallet>/accounts HTTP/1.1
Accept: application/json
Authorization: Bearer <API token>
Host: edge.qiwi.com
import requests

# QIWI Wallet balances
def balance(login, api_access_token):
    s = requests.Session()
    s.headers['Accept']= 'application/json'
    s.headers['authorization'] = 'Bearer ' + api_access_token  
    b = s.get('https://edge.qiwi.com/funding-sources/v2/persons/' + login + '/accounts')
    return b.json()
  • URL /funding-sources/v2/persons/personId/accounts

    • personId - your wallet number (without + sign)
  • HEADERS

    • Accept: application/json
    • Authorization: Bearer ***

Response ←

HTTP/1.1 200 OK
Content-Type: application/json

{
    "accounts": [
        {
            "alias": "mc_beeline_rub",
            "fsAlias": "qb_mc_beeline",
            "bankAlias": "QIWI",
            "title": "MC",
            "type": {
                "id": "MC",
                "title": "Счет мобильного кошелька"
            },
            "hasBalance": false,
            "balance": null,
            "currency": 643
        },
        {
            "alias": "qw_wallet_rub",
            "fsAlias": "qb_wallet",
            "bankAlias": "QIWI",
            "title": "WALLET",
            "type": {
                "id": "WALLET",
                "title": "QIWI Wallet"
            },
            "hasBalance": true,
            "balance": {
                "amount": 8.74,
                "currency": 643
            },
            "currency": 643
        }
    ]
}
# wallet number as 79992223344
mylogin = '79999999999'
api_access_token = '975efd8e8376xxxb95fa7cb213xxx04'

# All balances
balances = balance(mylogin,api_access_token)['accounts']

# Ruble account balance
rubAlias = [x for x in balances if x['alias'] == 'qw_wallet_rub']
rubBalance = rubAlias[0]['balance']['amount']

Repeated request when you got empty "balance" object and "hasBalance": true in response

GET /funding-sources/v2/persons/79115221133/accounts?timeout=1000&alias=qw_wallet_rub HTTP/1.1
Accept: application/json
Authorization: Bearer YUu2qw048gtdsvlk3iu
Host: edge.qiwi.com

Successful response is JSON array of all active balances of your QIWI wallet used for payment funding:

Response field Type Description
accounts Array[Object] Array of balances
accounts[].alias String User balance alias
accounts[].fsAlias String Bank account alias
accounts[].bankAlias String Bank alias
accounts[].title String Wallet account name
accounts[].hasBalance Boolean Flag of actual QIWI Wallet balance (not a linked card or cell phone balance or something like that)
accounts[].currency Number(3) Currency of the balance (ISO-4217). Only balances in following currencies are returned: 643 - Russian ruble, 840 - USD, 978 - Euro
accounts[].type Object Account information
type.id, type.title String Account title
accounts[].balance Object Balance data.
If null is returned and accounts[].hasBalance is true, repeat the request with additional parameters:
timeout=1000 and alias="accounts[].alias" (alias of that balance)
balance.amount Number Текущий баланс данного счета
balance.currency Number(3) Код валюты баланса (ISO-4217)

Creating balance {#balance_create}

Creates a new account and its balance in your QIWI wallet. List of account types which you can create is provided by other request.

Interactive API

Request → POST

curl -X POST \
  "https://edge.qiwi.com/funding-sources/v2/persons/<wallet/accounts" \
  --header "Accept: application/json" \
  --header "Content-Type: application/json" \
  --header "Authorization: Bearer <API token>" \
  -d '{  "alias": "qw_wallet_eur"}'
POST /funding-sources/v2/persons/<wallet>/accounts HTTP/1.1
Accept: application/json
Authorization: Bearer <API token>
Content-type: application/json
Host: edge.qiwi.com

{ "alias": "qw_wallet_eur" }
  • URL /funding-sources/v2/persons/personId/accounts

    • personId - your wallet number without + sign
  • HEADERS

    • Accept: application/json
    • Content-type: application/json
    • Authorization: Bearer ***
  • Parameters

    In JSON body of the request:
Name Type Description
alias String Alias of the new account (taken from Available accounts)

Response ←

HTTP/1.1 201 Created

Successful response contains HTTP code 201.

Available accounts {#funding_offer}

Provides all possible account aliases for your QIWI wallet.

Interactive API

Request → GET

curl -X GET \
  "https://edge.qiwi.com/funding-sources/v2/persons/<wallet>/accounts/offer" \
  --header "Accept: application/json" \
  --header "Authorization: Bearer <API token>"
GET /funding-sources/v2/persons/<wallet>/accounts/offer HTTP/1.1
Accept: application/json
Authorization: Bearer <API token>
Host: edge.qiwi.com
  • URL /funding-sources/v2/persons/personId/accounts/offer

    • personId - your wallet number without + sign
  • HEADERS

    • Accept: application/json
    • Authorization: Bearer ***

Response ←

HTTP/1.1 200 OK
Content-Type: application/json

{ { "alias": "qw_wallet_eur", "currency": 978 }, {} }

Successful JSON response contains a list of accounts available for creation:

Response field Type Description
{} Object List of accounts
Object.alias String Alias of the account
Object.currency Number(3) Account's currency code (ISO-4217)

Default balance {#default_balance}

Sets up default account in your QIWI wallet for funding all payments. The account must be in the list of available accounts

Interactive API

Request → PATCH

curl -X PATCH \
  "https://edge.qiwi.com/funding-sources/v2/persons/<wallet>/accounts/qw_wallet_usd" \
  --header "Accept: application/json" \
  --header "Content-Type: application/json" \
  --header "Authorization: Bearer <API token>" \
  -d '{ "defaultAccount": true }'
PATCH /funding-sources/v2/persons/<wallet>/accounts/qw_wallet_usd HTTP/1.1
Accept: application/json
Authorization: Bearer <API token>
Content-type: application/json
Host: edge.qiwi.com

{ "defaultAccount": true }
  • URL /funding-sources/v2/persons/personId/accounts/accountAlias

    • personId - your wallet number without + sign
    • accountAlias - account's alias in the wallet, from a list (see parameter accounts[].alias in response)
  • HEADERS

    • Accept: application/json
    • Content-type: application/json
    • Authorization: Bearer ***
  • Parameters

    Parameter in JSON body:
Name Type Description
defaultAccount Boolean Flag of default account

Response ←

HTTP/1.1 204 Modified

Successful response has HTTP code 204.