Created
January 27, 2016 01:04
-
-
Save wilhelmklopp/942c4b4aa6e026dc18cf to your computer and use it in GitHub Desktop.
Skyscanner API ISO-3166-1 Alpha 3 code problem
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
# The following snippet DOES NOT work | |
import requests | |
import datetime | |
tomorrow = datetime.date.today() + datetime.timedelta(days=1) | |
api_key = "YOUR-API-KEY-HERE" | |
url = "http://api.skyscanner.net/apiservices/pricing/v1.0/" | |
headers = { | |
"content-type": "application/x-www-form-urlencoded; charset=UTF-8", | |
"Accept": "application/json" | |
} | |
payload = { | |
"apiKey": api_key, | |
"country": "GER", | |
"currency": "EUR", | |
"locale": "en-US", | |
"originplace": "BRU", | |
"destinationplace": "MAD", | |
"outbounddate": str(tomorrow), | |
"adults": 1, | |
"locationschema": "Iata", | |
} | |
r = requests.post(url, headers=headers, data=payload) | |
print r.status_code | |
print r.text | |
print r.headers | |
# The following snippet DOES work | |
import requests | |
import datetime | |
tomorrow = datetime.date.today() + datetime.timedelta(days=1) | |
api_key = "YOUR-API-KEY-HERE" | |
url = "http://api.skyscanner.net/apiservices/pricing/v1.0/" | |
headers = { | |
"content-type": "application/x-www-form-urlencoded; charset=UTF-8", | |
"Accept": "application/json" | |
} | |
payload = { | |
"apiKey": api_key, | |
"country": "DE", | |
"currency": "EUR", | |
"locale": "en-US", | |
"originplace": "BRU", | |
"destinationplace": "MAD", | |
"outbounddate": str(tomorrow), | |
"adults": 1, | |
"locationschema": "Iata", | |
} | |
r = requests.post(url, headers=headers, data=payload) | |
print r.status_code | |
print r.text | |
print r.headers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ISO-3166-1 alpha 3 codes are not accepted and the API will return 500 Internal Server Error.
ISO-3166-1 alpha 2 codes are accepted.