Skip to content

Instantly share code, notes, and snippets.

@Bersam
Last active August 29, 2015 14:12
Show Gist options
  • Save Bersam/88d85b06fb554918396c to your computer and use it in GitHub Desktop.
Save Bersam/88d85b06fb554918396c to your computer and use it in GitHub Desktop.
Allmyles Sample For Python2
import requests, json
api_key = "12345678-1234"
api_url = "http://somewhere.com"
data = json.dumps({
'fromLocation': 'BUD',
'toLocation': 'LON',
'departureDate': '2014-12-29T00:00:00Z',
'resultTypes': 'default',
'returnDate': '2014-01-07T00:00:00Z',
'persons': [{
'passengerType': 'ADT',
'quantity': 1
}],
'preferredAirlines': ['BA']
})
headers = {'X-Auth-Token': api_key,
'Content-Type': 'application/json',
'Accept': 'application/json'
}
url = "%s/flights" % api_url
r = requests.post(url, data=data, headers=headers)
print r.status_code
print r.text
print r.json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment