Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to get data from json web api in python

import requests
import simplejson as json

url = "api_url"
response = requests.get(url)
x = json.loads(response.text)

#Note the {} get auto replace by the data you were looking for
print('protocol: {}'.format(x.get('protocol'))) #replace 'protocol' with the data specific you need like 'id'
print('responseTime: {}'.format(x.get('responseTime')))
print('reputation: {}'.format(x.get('reputation')))
 
PREVIOUS NEXT
Tagged: #data #json #web #api #python
ADD COMMENT
Topic
Name
8+7 =