For sake of simplicity, maybe you should consider using the Requests library.
An example with json response content would be something like:
import requests
r = requests.get(‘https://github.com/timeline.json’)
r.json()
If you look for further information, in the Quickstart section, they have lots of working examples.
EDIT:
For your specific curl translation:
import requests
url = ‘https://www.googleapis.com/qpxExpress/v1/trips/search?key=mykeyhere’
payload = open(“request.json”)
headers = {‘content-type’: ‘application/json’, ‘Accept-Charset’: ‘UTF-8’}
r = requests.post(url, data=payload, headers=headers)
Just use this website. It’ll convert any curl command into Python, Node.js, PHP, R, or Go.
Example:
curl -X POST -H ‘Content-type: application/json’ –data ‘{“text”:”Hello, World!”}’ https://hooks.slack.com/services/asdfasdfasdf
Becomes this in Python,
import requests
headers = {
‘Content-type’: ‘application/json’,
}
data = ‘{“text”:”Hello, World!”}’
response = requests.post(‘https://hooks.slack.com/services/asdfasdfasdf’, headers=headers, data=data)