aboutsummaryrefslogtreecommitdiff
path: root/pythonProgram/function-specific-programs/zomato.py
blob: 26b4c43f52622e1755cfc1af85da7200d9a84be2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import requests
import simplejson as sjson
import json

res = []

def getRes():
	headers = {
	    'Accept': 'application/json',
	    'user-key': 'a530c1424d9abe5442fa22f77ce03d25',
	}

	params = (
	    ('lat', '28.546519'),
	    ('lon', '77.179248'),
	)

	response = requests.get('https://developers.zomato.com/api/v2.1/geocode', headers=headers, params=params)
	res = response.json()['popularity']['nearby_res']
	return res

def getDetails(res):
	headers = {
	    'Accept': 'application/json',
	    'user-key': 'a530c1424d9abe5442fa22f77ce03d25',
	}
	url = "https://developers.zomato.com/api/v2.1/restaurant?res_id=" + str(res[0])
	newResponse = requests.get(url, headers=headers)
	newRes = []
	resName = newResponse.json()['name']
	resAddress = newResponse.json()['location']['address']
	print("You are feeling sleepy, why don't you take a break?\n")
	print("Your nearest eatery is " + resName,"\n")
	print(resName + " is at " + resAddress,"\n")
def zomato():

	res = getRes()
	getDetails(res)
zomato()