Skip to content
mattbasta edited this page Jul 21, 2011 · 9 revisions

Yelp API Python Client

A simple (but complete) Yelp API implementation

About

Pure python implementation of a fully-functional Yelp API client.
Yelp http://www.yelp.com provides a localized businesses and user reviews directory.
Yelp API http://www.yelp.com/developers/documentation exposes some core functionality to search for businesses and reviews based on various criteria.

Usage

Usage is pretty straightforward, based on the Yelp API documentation as well as inline code documentation. Example usage:

from yelp import ReviewSearchApi

results = ReviewSearchApi(client_key=<my_ywsid_key>).by_location("Mission, San Francisco CA")

rows = results["businesses"]
for row in rows:
    print row["name"]

Note that you will need a YWSID (Yelp Web Services ID) to use the Yelp API. see http://www.yelp.com/developers/documentation/faq

Current feature set:

  • Supports the 3 published Yelp APIs: Review Search API, Phone API, Neighborhood API.
  • Easily installable/distributable using setuptools/distutils
  • Complete set of unit tests
  • Based on the excellent httplib2 module
  • Uses Python2.6 builtin json module for parsing or simplejson for pre-2.6.

Dependencies

Building

Download the source distribution tar file, extract archive file, and type: python setup.py install thats it!

Testing

To run the unit-test suite enclosed, you have two options:

  • If setuptools is available, you may simply run: python setup.py test
  • Otherwise, you can run the test suite manually: python test_yelp.py

TODO/Roadmap

  • Implement Business objects (no pun intended) to parse out Result (currently its simply the parsed raw JSON result set)
  • See if any reason to use pickled python instead of json output format?
  • Implement request timeout and standardized error handling (YelpException) for API requests

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.