forked from wesleyzhao/python-yipit-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
A Python wrapper for the Yipit API
License
triplec1988/python-yipit-wrapper
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
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
About
A Python wrapper for the Yipit API
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- Python 54.5%
- JavaScript 45.5%