reformatted/tweaked and added the examples from example.py in the yelpapi package
[yelp-api-cdsw] / yelp2.py
1 from yelpapi import YelpAPI
2 from yelp_authentication import CONSUMER_KEY, CONSUMER_SECRET, TOKEN, TOKEN_SECRET
3
4 yelp_api = YelpAPI(CONSUMER_KEY, CONSUMER_SECRET, TOKEN, TOKEN_SECRET)
5
6 # Example search by bounding box and category. See
7 # http://www.yelp.com/developers/documentation/v2/all_category_list
8 # for an official list of Yelp categories. The bounding box definition
9 # comes from
10 # http://isithackday.com/geoplanet-explorer/index.php?woeid=12587707.
11
12 print('***** 5 bike rentals in San Francisco county *****')
13
14 response = yelp_api.search_query(category_filter='bikerentals', bounds='37.678799,-123.125740|37.832371,-122.356979', limit=5)
15     
16 for business in response['businesses']:
17     print('%s\n\tYelp ID: %s\n\trating: %g (%d reviews)\n\taddress: %s' % (business['name'], business['id'], business['rating'],
18                                                                            business['review_count'], ', '.join(business['location']['display_address'])))

Benjamin Mako Hill || Want to submit a patch?