Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
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']
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))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question