Last active
February 23, 2022 01:54
-
-
Save Shrestha7/7cc880dea2d6e8572848b8cb866c1fc1 to your computer and use it in GitHub Desktop.
consume api in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import pprint | |
url='https://' | |
response = request.get(url) | |
pprint.pprint(response.json()) | |
// structure way | |
url ='' | |
parameters ={ | |
'id:1 | |
} | |
headers = { | |
'Accepts':'application/json', | |
} | |
response = request.get(url,params=parameters, headers=headers) | |
print(response.json()) | |
pprint.pprint(response.json().get('data',{}).get('',{})) | |
//after creating function | |
print(get_price('bc')) | |
response= input ("enter :") | |
get_price(response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment