Answer the question
In order to leave comments, you need to log in
How to get all comments from Json, QIWI Api?
There is a code from QIWI Api that returns the last 10 transactions in Json. I wrote a code that gets the amount and comment of the last payment, but I need to get the comment and the amount of all (10) transactions.
The code:
import config
import requests
import json
import os
import sys
api_access_token = config.tokenq # токен qiwi
my_login = config.my_login # номер QIWI Кошелька
login = config.login
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))
tmp = json.loads(h.text)
comment = tmp['data'][0]['comment']
sum = tmp['data'][0]['sum']['amount']
print (comment,sum)
Answer the question
In order to leave comments, you need to log in
The for loop is helpful.
for i in tmp['data']:
print(i['comment'])
#выведет все коментарии
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question