forked from abduhbm/python-qaym
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
executable file
·71 lines (53 loc) · 1.45 KB
/
Copy pathexample.py
File metadata and controls
executable file
·71 lines (53 loc) · 1.45 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from qaym.api import Api
import os
# getting the API key
QAYM_KEY = os.environ.get('QAYM_KEY')
api = Api(key=QAYM_KEY)
# retrieve a list of countries
countries = api.GetCountries()
print repr(countries[0])
# retrieve a country information
info = api.GetCountryInfo(230)
print repr(info)
# retrieve a list cities for a given country
cities = api.GetCities(178)
print cities
# retrieve a city information
city = api.GetCityInfo(290)
print repr(city)
# retrieve a list of restaurants in a city
items = api.GetItems(290)
for item in items:
print repr(item)
# retrieve the top 50 restaurants in a city
top_items = api.GetItems(290, top=True)
for item in top_items:
print item.item_name, item.item_id, item.score
top = [(item.item_name, int(item.score), item.item_id) for item in top_items]
for i in sorted(top, key=lambda x: x[1], reverse=True):
print i[0], i[1], i[2]
i = api.GetItem(43)
print repr(i)
# retrieve locations of a restaurant
l = api.GetLocations(43)
print l
# retrieve reviews of a restaurant
r = api.GetReviews(43)
print r
# retrieve uploaded images of a restaurant
images = api.GetImages(43)
print images
print len(images)
# retrieve (up/down) votes of a restaurant
votes = api.GetVotes(43)
print votes
print len(votes['up']), len(votes['down'])
# retrieve tags
tags = api.GetTags()
print tags
# retrieve a list of tagged restaurant
items = api.GetItemsByTag(59)
print items
print len(items)