aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2019-04-03 16:22:06 +0530
committerNavan Chauhan <navanchauhan@gmail.com>2019-04-03 16:25:19 +0530
commit68c4daf6728e72ce894e5292d613454f41f34ed5 (patch)
tree4764d3a477427b12482b92e9034393120720891a
parentd97f90c1db161626764a8f63dd8918cff0447f7e (diff)
First Commit
-rw-r--r--LICENSE21
-rw-r--r--PyAto/__init__.py59
-rw-r--r--README.md2
3 files changed, 82 insertions, 0 deletions
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