diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2019-04-03 16:23:51 +0530 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2019-04-03 16:25:19 +0530 |
commit | 0c70b5c6842444cee8ec25f091a4b85ec378cc88 (patch) | |
tree | 2cca103f0a27421a381420d403767a865c7a896e /build/lib | |
parent | 68c4daf6728e72ce894e5292d613454f41f34ed5 (diff) |
Adding Files
Diffstat (limited to 'build/lib')
-rw-r--r-- | build/lib/PyAto/PyAto.py | 59 | ||||
-rw-r--r-- | build/lib/PyAto/__init__.py | 59 |
2 files changed, 118 insertions, 0 deletions
diff --git a/build/lib/PyAto/PyAto.py b/build/lib/PyAto/PyAto.py new file mode 100644 index 0000000..08d05f8 --- /dev/null +++ b/build/lib/PyAto/PyAto.py @@ -0,0 +1,59 @@ +import requests + +#We set the headers globally as the header remains the same for almmost all requests +def setAPIKey(secret): + apikey = secret + global headers + headers = { + 'Accept': 'application/json', + 'user-key': apikey, + } + + +# Get Categories Function + +def getCategories(): + response = requests.get('https://developers.zomato.com/api/v2.1/categories', headers=headers) + return response.json() + +# Get Cities function. Only takes City Name. Returns JSON + +def getCities(name): + params = (('q', name),) + response = requests.get('https://developers.zomato.com/api/v2.1/cities', headers=headers, params=params) + return response.json()['location_suggestions'][0] + +# Get Collections Function. Only takes City ID. Returns JSON + +def getCollections(city_id): + params = (('city_id', city_id),) + response = requests.get('https://developers.zomato.com/api/v2.1/collections', headers=headers, params=params) + return response.json() + +# Get Cuisines Function. Only takes City ID. Returns JSON + +def getCuisines(city_id): + params = (('city_id', city_id),) + response = requests.get('https://developers.zomato.com/api/v2.1/cuisines', headers=headers, params=params) + return response.json() + +# Get Establishments Function. Only takes City ID. Returns JSON + +def getEstablishments(city_id): + params = (('city_id', '1'),) + response = requests.get('https://developers.zomato.com/api/v2.1/establishments', headers=headers, params=params) + return response.json() + +# Geocoding Function. Takes Latitude and Longitude. Returns JSON + +def getGeocode(lat, lon): + params = (('lat', lat),('lon', lon),) + response = requests.get('https://developers.zomato.com/api/v2.1/geocode', headers=headers, params=params) + return response.json() + +# Gets the City ID, Takes City Name and returns integer + +def getCityID(name): + params = (('q', name),) + response = requests.get('https://developers.zomato.com/api/v2.1/cities', headers=headers, params=params) + return response.json()['location_suggestions'][0]['id'] diff --git a/build/lib/PyAto/__init__.py b/build/lib/PyAto/__init__.py new file mode 100644 index 0000000..4757eaf --- /dev/null +++ b/build/lib/PyAto/__init__.py @@ -0,0 +1,59 @@ +name = "PyAto" + +def setAPIKey(secret): + apikey = secret + global headers + headers = { + 'Accept': 'application/json', + 'user-key': apikey, + } + + +# Get Categories Function + +def getCategories(): + response = requests.get('https://developers.zomato.com/api/v2.1/categories', headers=headers) + return response.json() + +# Get Cities function. Only takes City Name. Returns JSON + +def getCities(name): + params = (('q', name),) + response = requests.get('https://developers.zomato.com/api/v2.1/cities', headers=headers, params=params) + return response.json()['location_suggestions'][0] + +# Get Collections Function. Only takes City ID. Returns JSON + +def getCollections(city_id): + params = (('city_id', city_id),) + response = requests.get('https://developers.zomato.com/api/v2.1/collections', headers=headers, params=params) + return response.json() + +# Get Cuisines Function. Only takes City ID. Returns JSON + +def getCuisines(city_id): + params = (('city_id', city_id),) + response = requests.get('https://developers.zomato.com/api/v2.1/cuisines', headers=headers, params=params) + return response.json() + +# Get Establishments Function. Only takes City ID. Returns JSON + +def getEstablishments(city_id): + params = (('city_id', '1'),) + response = requests.get('https://developers.zomato.com/api/v2.1/establishments', headers=headers, params=params) + return response.json() + +# Geocoding Function. Takes Latitude and Longitude. Returns JSON + +def getGeocode(lat, lon): + params = (('lat', lat),('lon', lon),) + response = requests.get('https://developers.zomato.com/api/v2.1/geocode', headers=headers, params=params) + return response.json() + +# Gets the City ID, Takes City Name and returns integer + +def getCityID(name): + params = (('q', name),) + response = requests.get('https://developers.zomato.com/api/v2.1/cities', headers=headers, params=params) + return response.json()['location_suggestions'][0]['id'] + |