This software is licensed under the BSD 3-Clause License. Please refer to the separate LICENSE file for the exact text of the license. You are obligated to give attribution if you use this code.
yelpapi is a pure Python implementation of Yelp's public REST APIs, including the Yelp Places API, the Yelp AI API, Yelp Insights, and the Home Services API. It is simple, fast, and robust to any changes Yelp may make to its APIs in the future.
This code requires Python 3.11 or higher and requests.
yelpapi is available on PyPI at https://pypi.org/project/yelpapi/.
Install using pip:
pip install yelpapi
This API is demonstrated more thoroughly in examples.py, but the following chunk of code demonstrates basic use of yelpapi:
from yelpapi import YelpAPI
with YelpAPI(api_key) as yelp_api:
search_results = yelp_api.search_query(term='ice cream', location='austin, tx')You can also set timeouts so API calls do not block indefinitely in degraded network conditions:
from yelpapi import YelpAPI
with YelpAPI(api_key, timeout_s=3.0) as yelp_api:
search_results = yelp_api.search_query(term='ice cream', location='austin, tx')Under the covers, this module uses a requests.Session object for issuing all API calls, which offers potentially significant performance benefits over issuing separate API calls outside of a session. You should be sure to close the underlying session when all API interactions are complete. The above examples demonstrate using the class as a context manager, which will automatically close the connection when you're done and is the preferred way of using the class, but you can also manually close it like this if a context manager won't work for your use case:
from yelpapi import YelpAPI
yelp_api = YelpAPI(api_key)
try:
search_results = yelp_api.search_query(term='ice cream', location='austin, tx')
finally:
yelp_api.close()- AI Chat API -
ai_chat_query(...) - Autocomplete API -
autocomplete_query(...) - Business API -
business_query(...) - Business Engagement Metrics API -
business_engagement_query(...) - Business Food & Drinks Insights API -
business_food_and_drinks_insights_query(...) - Business Insights API -
business_insights_query(...) - Business Match API -
business_match_query(...) - Business Request a Phone Call API -
business_rapc_enabledness_query(...) - Business Risk Signal Insights API -
business_risk_signals_insights_query(...) - Business Service Offerings API -
business_service_offerings_query(...)(deprecated by Yelp in favor of "Jobs offered" on the Business API) - Categories API -
categories_query(...) - Category API -
category_query(...) - Event Lookup API -
event_lookup_query(...) - Event Search API -
event_search_query(...) - Featured Event API -
featured_event_query(...) - Job Survey API -
job_survey_query(...) - Jobs API -
jobs_query(...) - Phone Search API -
phone_search_query(...) - Request a Quote API -
request_a_quote_query(...) - Review Highlights API -
review_highlights_query(...) - Reviews API -
reviews_query(...) - Search API -
search_query(...) - Transaction Search API -
transaction_search_query(...)
Yelp's GraphQL API is not wrapped, since it uses GraphQL queries rather than REST parameters.