You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This tutorial will show you how you can call our APIs using Python. For sending sample get API request in python 3 then install the requests library using pip install requests or pip3 install requests. Create a new filename with python extension i.e callapi.py.
# importing the requests library importrequests# api-endpoint URL="https://treasurejsapi.herokuapp.com/api/v1/search"# defining a params dict for the parameters to be sent to the API PARAMS= {'find': 'as'}
# sending get request and saving the response as response object r=requests.get(url=URL, params=PARAMS)
# extracting data in json format data=r.json()
print(data)
OUTPUT
For output run the file using command python callapi.py. Then you will get the output like below:
[{'description': 'Official React bindings for Redux','docs': 'http://caolan.github.io/async/docs.html','github': 'https://github.com/caolan/async','name': 'ASYNC','other': [],'website': 'http://caolan.github.io/async/'},{'description': 'astroturf lets you write CSS in your JavaScript files without adding any runtime layer, and with your existing CSS processing pipeline.','docs': '','github': 'https://github.com/4Catalyzer/astroturf','name': 'ASTROTURF','other': [],'website': ''}]