M
M
MaximMRX2017-07-01 23:23:39
API
MaximMRX, 2017-07-01 23:23:39

How to work with QIWI API?

Good day. The question is that I need to get a list of the last payments to the account using the QIWI API. How can it be implemented? Maybe someone has an example of working with the QIWI API?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
OrangeXD, 2017-07-12
@GM_pAnda

Python 2 example, getting all transactions from history:

l = login[1:]
    s = requests.Session()
    header = {'Content-type': 'application/json',
              'X-Requested-With': 'XMLHttpRequest',
              'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'
              }
    s.headers = header
    r = s.post('https://auth.qiwi.com/cas/tgts', json={'login': login, 'password': password})
    tgt_ticket = json.loads(r.text)['entity']['ticket']
    header = {'Content-type': 'application/json',
              'Accept': 'application/vnd.qiwi.sso-v1+json',
              'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'
              }
    s.headers = header
    r = s.post('https://auth.qiwi.com/cas/sts',
               json={'service': 'https://qiwi.com/j_spring_cas_security_check', 'ticket': tgt_ticket})
    st_ticket = json.loads(r.text)['entity']['ticket']
    r = s.get('https://qiwi.com/j_spring_cas_security_check?ticket=' + st_ticket)
    cookies = r.cookies
    r = s.post('https://auth.qiwi.com/cas/sts',
               json={'service': 'http://t.qiwi.com/j_spring_cas_security_check', 'ticket': tgt_ticket}, cookies=cookies)
    st_ticket_2 = json.loads(r.text)['entity']['ticket']
    s.headers = {'Accept': 'application/json', 'Authorization': 'Token ' + st_ticket_2,
                 'Content-type': 'application/json'}
    p = s.get('https://edge.qiwi.com/payment-history/v1/persons/' + l + '/payments?rows=50', cookies=cookies)
    payments = json.loads(p.text)['data']

API Documentation Here

D
d_garmashev, 2017-08-14
@d_garmashev

With the new API it can be made easier, requests to get tgtTicket and stTicket are now needed.
Example for getting the last 10 transactions for Python 3.

import requests
import json

api_access_token = '' # токен можно получить здесь https://qiwi.com/api
my_login = '' # номер QIWI Кошелька в формате +79991112233

s = requests.Session()
s.headers['authorization'] = 'Bearer ' + api_access_token  
parameters = {'rows': '10'}
h = s.get('https://edge.qiwi.com/payment-history/v1/persons/'+my_login+'/payments', params = parameters)
print(json.loads(h.text))

You can also upload individual transactions or the amount of payments for a period limited by dates https://developer.qiwi.com/qiwiwallet/qiwicom_ru.h...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question