The requests
library is the de facto standard for making HTTP requests in Python. It abstracts the complexities of making requests behind a beautiful, simple API so that you can focus on interacting with services and consuming data in your application.
https://realpython.com/python-requests/
$ pip install requests
import requests
import json
def get_json():
url = 'http://myurl.com/api.json')
r = requests.request("GET", url)
return(r.json())
if __name__ == '__main__':
data = get_json()
print(data)
import requests
import json
def json_post():
payload = {
"data01": "hello",
"data02": "world",
}
url = 'http://myurl.com/api/')
r = requests.post(url, data=json.dumps(payload))
print(r.status_code)
if __name__ == '__main__':
json_post()