From 68c4daf6728e72ce894e5292d613454f41f34ed5 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Wed, 3 Apr 2019 16:22:06 +0530 Subject: First Commit --- LICENSE | 21 ++++++++++++++++++++ PyAto/__init__.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 2 ++ 3 files changed, 82 insertions(+) create mode 100644 LICENSE create mode 100644 PyAto/__init__.py create mode 100644 README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..aac0057 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Navan Chauhan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/PyAto/__init__.py b/PyAto/__init__.py new file mode 100644 index 0000000..4757eaf --- /dev/null +++ b/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'] + diff --git a/README.md b/README.md new file mode 100644 index 0000000..99c920d --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# PyAto +A Python Wrapper for the Zomato API -- cgit v1.2.3