1
1
1grand2019-08-21 14:39:32
Python
1grand, 2019-08-21 14:39:32

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

1 answer(s)
L
lightmanLP, 2019-08-21
@1grand

The for loop is helpful.

for i in tmp['data']:
 print(i['comment'])
#выведет все коментарии

Or through len and while raising the value from 0 to len(list) (in this case 10)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question