-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
137 lines (111 loc) · 4.13 KB
/
README
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
Making this very rudimentary for basic use. I tried to keep this very well commented so look through the code.
Docs now available here:
Epydoc-generated (my fav): /doc/index.html
Sphinx-generated : /docs/index.html
** Look at test.py for more examples of how to use this wrapper
Try this to test: >> python test.py your_api_key
[INSTALL]
$ python setup.py install
[BASIC EXAMPLE]
# after already navigating into the directory that holds yipit.py
import yipit
api = yipit.Api(api_key = "mykeyasdfasdfasdfasdfasd9fa9sfa9s")
''' DEALS API '''
deals = api.get_deals(lat=-100.2,
lon=144.444,
radius=20,
divison=["new-york"],
source=["groupon","living-social"],
phone=[2123335555],
tag=['restaurants','bar-club'],
paid=True,
limit=5000) # all are optional params
individ_deal = api.get_deal_by_id(deal_id = 16721)
for deal in deals:
print deal._title
print deal._url
print deal._yipit_title
print deal._yipit_url
print deal._active
print deal._business # dictionary with the business information
print deal._date_added
print deal._division # dictionary with division information
print deal._end_date
print deal._id
print deal._images # dictionary with 'image_big' and 'image_small'
print deal._mobile_url
print deal._discount # dictionary with 'formatted' and 'raw'
print deal._price # dictionary with 'formatted' and 'raw'
print deal._value # dictionary with 'formatted' and 'raw'
print deal._purchased
print deal._source # will be a dictionary of the source
print deal._tags # will be a list of tag dictionaries
''' SOURCES API '''
sources = api.get_sources(division=['new-york','atlanta'],
paid=False,
limit=10)
for source in sources:
print source._name
print source._slug
print source._paid
print source._url
''' DIVISIONS API '''
api.get_divisions(source=['groupon', 'living-social']
lat=40.7654629,
lon=-73.97724,
radius=25,
limit=10)
for division in divisions:
print division._slug
print division._name
print division._active
print division._time_zone_diff # based off UTC
print division._lat
print division._lon
print division._url
''' TAGS API '''
tags = api.get_tags() # there are no filters
for tag in tags:
print tag._name
print tag._slug
print tag._url
''' BUSINESSES API '''
businesses = api.get_businesses(lat=40.7654629,
lon=-73.97724,
radius=25,
phone=222111333,
division=['new-york'])
for business in businesses:
print business._id
print business._name
print business._url
print business._locations
location = business._locations[0] # a list of location dictionaries
print location['id']
print location['address']
print location['locality']
print location['phone']
print location['lat']
print location['lon']
***************************************************************************
TODO Make stdin work for test.py
goal (this should work eventually): >> python test.py the_api_key
***************************************************************************
BUGS
****RESOLVED: Yipit server goes down periodically, added error catching****
# shows up once in a while... no idea why
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "yipit.py", line 180, in get_deals
**parameters)
File "yipit.py", line 238, in get_yipit_list_by_params
data = self.parse_and_check_yipit(json)
File "yipit.py", line 472, in parse_and_check_yipit
data = simplejson.loads(json)
File "/usr/lib/python2.6/json/__init__.py", line 307, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.6/json/decoder.py", line 319, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.6/json/decoder.py", line 338, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded