X-Git-Url: https://projects.mako.cc/source/yelp-api-cdsw/blobdiff_plain/780a521a94cb490636e3cd296b9ce339db1517bc..5632f1d30d231449e6174f3f9860cda6ab5ae4d2:/yelp1.py diff --git a/yelp1.py b/yelp1.py new file mode 100644 index 0000000..454f54d --- /dev/null +++ b/yelp1.py @@ -0,0 +1,18 @@ +from yelpapi import YelpAPI +from yelp_authentication import CONSUMER_KEY, CONSUMER_SECRET, TOKEN, TOKEN_SECRET + +yelp_api = YelpAPI(CONSUMER_KEY, CONSUMER_SECRET, TOKEN, TOKEN_SECRET) + +# Example search by location text and term. Take a look at +# http://www.yelp.com/developers/documentation/v2/search_api for +# the various options available. + +print('***** 5 best rated ice cream places in Austin, TX *****') + +response = yelp_api.search_query(term='ice cream', location='austin, tx', sort=2, limit=5) + +print('region center (lat,long): %s,%s\n' % (response['region']['center']['latitude'], response['region']['center']['longitude'])) + +for business in response['businesses']: + print('%s\n\tYelp ID: %s\n\trating: %g (%d reviews)\n\taddress: %s' % (business['name'], business['id'], business['rating'], business['review_count'], ', '.join(business['location']['display_address']))) +