SDKs overview
Software Development Kits (SDKs) and client libraries for the Yelp Fusion API streamline the process of integrating Yelp's extensive business data into custom applications. While Yelp maintains official documentation and API endpoints, the developer community has contributed various language-specific libraries to facilitate interaction. These tools typically handle common tasks such as constructing API requests, managing OAuth 2.0 authentication, and parsing JSON responses, allowing developers to focus on application logic rather than low-level API communication details. The Yelp Fusion API provides access to business search, comprehensive business details, and snippets of user reviews, enabling a range of location-based services and business directory integrations Yelp Fusion API reference.
Effective use of these SDKs and libraries requires an understanding of the Yelp Fusion API's rate limits and terms of use. The API offers a free tier for up to 5,000 requests per day, with enterprise pricing available for higher volumes Yelp API terms. Developers must obtain API keys and client credentials through the Yelp developer portal to authenticate their requests. Adherence to OAuth 2.0 authorization flows is critical for secure access to user data and protected resources.
Official SDKs by language
Yelp primarily provides comprehensive API documentation and examples rather than officially supported, language-specific SDKs in the traditional sense. However, their documentation includes detailed guides and code snippets across several popular languages to assist developers in building their own clients. The community has subsequently developed and maintained libraries that closely follow these guidelines. For direct programmatic interaction with the Yelp Fusion API, developers typically use standard HTTP client libraries available in their chosen programming language and manage authentication and request/response structures manually, or leverage community-driven wrappers.
The following table outlines common approaches and community-contributed libraries frequently used for Yelp API integration:
| Language | Common Package/Approach | Installation Command (Example) | Maturity/Status |
|---|---|---|---|
| Python | yelpapi (community) |
pip install yelpapi |
Community-maintained, active |
| Node.js | yelp-fusion (community) |
npm install yelp-fusion |
Community-maintained, active |
| Ruby | yelp-fusion (community) |
gem install yelp-fusion |
Community-maintained |
| PHP | yelp/yelp-fusion (community) |
composer require yelp/yelp-fusion |
Community-maintained |
| Java | Manual HTTP client (e.g., OkHttp, Apache HttpClient) | (Add dependency to pom.xml or build.gradle) |
Official guidance via examples, community wrappers exist |
Installation
Installation methods vary depending on the programming language and whether you are using a community-contributed library or building your client from scratch. The following examples cover common package managers for widely used languages:
Python: Using yelpapi
The yelpapi library simplifies interaction with the Yelp Fusion API in Python:
pip install yelpapi
Node.js: Using yelp-fusion
For Node.js environments, the yelp-fusion package is commonly used:
npm install yelp-fusion
Ruby: Using yelp-fusion
In Ruby projects, you can add the yelp-fusion gem:
gem install yelp-fusion
Or add it to your Gemfile:
gem 'yelp-fusion'
PHP: Using yelp/yelp-fusion
PHP developers can use Composer to install a community client:
composer require yelp/yelp-fusion
Java: Manual HTTP Client
For Java, instead of a dedicated Yelp SDK, you'll typically use a general-purpose HTTP client library. Here's how to add OkHttp to a Maven project:
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.3</version>
</dependency>
For Gradle:
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
Quickstart example
This Python example demonstrates how to use the yelpapi library to search for businesses. Before running, ensure you have obtained your Yelp Fusion API Key from the Yelp developer portal.
from yelpapi import YelpAPI
import os
# Replace with your actual API key or set as environment variable
# YELP_API_KEY = os.environ.get('YELP_API_KEY')
YELP_API_KEY = 'YOUR_YELP_API_KEY'
if not YELP_API_KEY:
print("Error: YELP_API_KEY not set. Please get your key from https://www.yelp.com/developers/documentation/v3/get_started")
exit(1)
yelp_api = YelpAPI(YELP_API_KEY)
try:
# Search for 'coffee' shops near 'San Francisco'
search_results = yelp_api.search_query(term='coffee', location='San Francisco', limit=5)
print(f"Found {search_results['total']} coffee shops in San Francisco.")
print("Top 5 results:")
for business in search_results['businesses']:
print(f"- {business['name']} (Rating: {business['rating']}) - {business['url']}")
# Example: Get details for a specific business (replace with an actual business ID)
# business_id = search_results['businesses'][0]['id'] if search_results['businesses'] else None
# if business_id:
# business_details = yelp_api.business_query(id=business_id)
# print(f"\nDetails for {business_details['name']}: {business_details['display_phone']}")
except Exception as e:
print(f"An error occurred: {e}")
print("Ensure your API key is correct and you're within rate limits.")
This example initializes the YelpAPI client with your API key, then performs a search query for coffee shops in San Francisco, printing the names and ratings of the top five results. Remember to replace 'YOUR_YELP_API_KEY' with your actual key.
Community libraries
Due to the RESTful nature of the Yelp Fusion API and its clear documentation, many developers opt to use standard HTTP client libraries in their preferred language to interact with the API directly. However, the community has developed several wrapper libraries that abstract away common tasks like request signing, URL construction, and response parsing. These community-contributed libraries can accelerate development by providing a more idiomatic interface for each language.
- Python:
yelpapi(PyPI) is a popular, actively maintained library that provides a Pythonic interface to the Yelp Fusion API. It handles authentication and request building, making it straightforward to perform searches and retrieve business details. - Node.js:
yelp-fusion(npm) is widely used in the Node.js ecosystem, offering a clean API for making requests to Yelp. It supports promises and async/await syntax, aligning with modern JavaScript development practices. - Ruby: The
yelp-fusiongem (RubyGems) provides a Ruby client for the API, simplifying HTTP requests and JSON parsing for Ruby applications. - PHP: Composer packages like
yelp/yelp-fusion(Packagist) offer PHP developers a client to interact with the Yelp Fusion API, handling the underlying cURL requests and data serialization. - Java: While less prevalent for a dedicated Yelp SDK, Java developers often use robust HTTP clients like OkHttp or Apache HttpClient, combined with JSON parsing libraries such as Jackson or Gson, to build their API interactions. Community projects may exist, but developers often prefer direct integration for full control.
When using community libraries, it is advisable to check their maintenance status, documentation, and open issues on platforms like GitHub to ensure they are suitable for production environments and compatible with the latest Yelp API versions. Always refer to the official Yelp developer documentation for the most up-to-date API specifications and best practices.