SDKs overview
The Uber Developer Platform offers SDKs and API access to enable third-party applications to integrate core Uber functionalities. These integrations primarily allow users to request rides or deliveries directly from external applications. The official SDKs are designed for mobile development environments, specifically iOS and Android, providing native interfaces and streamlined authentication processes for these platforms. Beyond official offerings, the developer community has created various libraries in languages such as Python, Node.js, Ruby, and Java, which wrap the Uber API to facilitate server-side or web-based integrations.
Access to the Uber API generally requires developers to register their applications and receive approval for specific integration use cases. This approach ensures that integrations align with Uber's platform policies and maintain a consistent user experience. The SDKs and libraries abstract away direct HTTP requests and authentication flows, allowing developers to focus on the application logic rather than the underlying API communication protocols, which often follow patterns like OAuth 2.0 for secure access delegation, as described by the OAuth 2.0 Authorization Framework. The Uber Developer documentation provides detailed guides for setting up and using both official SDKs and direct API integrations.
Official SDKs by language
Uber maintains official SDKs for major mobile platforms to simplify the integration of ride-requesting capabilities into native applications. These SDKs are designed to handle authentication, manage ride requests, and provide real-time updates within the context of an iOS or Android application. They abstract the complexities of direct API calls, offering platform-specific methods and UI components where applicable.
| Language/Platform | Package/Module | Installation Command (Example) | Maturity |
|---|---|---|---|
| iOS (Swift/Objective-C) | UberRides | pod 'UberRides' (via Cocoapods) |
Stable, Actively maintained |
| Android (Java/Kotlin) | com.uber.sdk:rides-android | implementation 'com.uber.sdk:rides-android:[LATEST_VERSION]' (via Gradle) |
Stable, Actively maintained |
Installation
Installing Uber's official SDKs involves using standard package managers for iOS and Android development environments. For iOS, CocoaPods is the recommended dependency manager, while for Android, Gradle is used to include the necessary libraries. These tools automate the process of downloading and linking the SDK into your project.
iOS SDK Installation (using CocoaPods)
To integrate the UberRides SDK into an iOS project, you typically begin by initializing CocoaPods in your project directory if not already done. Then, you add the UberRides pod to your Podfile:
# Podfile
platform :ios, '10.0'
use_frameworks!
target 'YourAppTarget' do
pod 'UberRides' # Replace with the latest version if specified
end
After saving the Podfile, navigate to your project directory in the terminal and run:
pod install
This command downloads and integrates the SDK into your Xcode workspace. Further configuration in Xcode, such as setting up URL schemes for callback, is detailed in the Uber iOS SDK setup guide.
Android SDK Installation (using Gradle)
For Android projects, the Uber Rides Android SDK is added as a dependency in your app's build.gradle file. Ensure you are adding it to the module-level build.gradle, not the project-level.
// app/build.gradle
dependencies {
implementation 'com.uber.sdk:rides-android:0.5.0' // Check Uber docs for latest version
implementation 'com.uber.sdk:rides-requests:0.5.0' // Optional: for the Ride Request Button
implementation 'com.uber.sdk:core:0.5.0' // Core utilities
}
After adding these lines, sync your Gradle project. The Uber Android SDK setup guide provides additional steps for manifest configuration and obtaining necessary API keys.
Quickstart example
A common use case for the Uber SDKs is to allow users to request a ride directly from a third-party application. The following examples illustrate a simplified quickstart for both iOS and Android to initiate a ride request. These snippets assume prior SDK setup and authentication.
iOS Quickstart (Swift)
This example demonstrates how to present the Uber ride request interface using the official iOS SDK. It typically involves configuring product parameters like pickup/dropoff locations and then launching the Uber app or a web view to complete the request.
import UIKit
import UberRides
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Ensure the SDK is initialized, typically in AppDelegate
}
func requestUberRide() {
let rideParameters = RideParametersBuilder()
.setPickupLocation(latitude: 37.7758, longitude: -122.4180, nickname: "Uber HQ")
.setDropoffLocation(latitude: 37.7844, longitude: -122.4046, nickname: "Salesforce Tower")
.setProductID("uberx") // Optional: specify a product ID (e.g., uberX, uberXL)
.build()
let rideRequestViewController = RideRequestViewController(rideParameters: rideParameters)
rideRequestViewController.delegate = self
// Present the Uber ride request view controller
present(rideRequestViewController, animated: true, completion: nil)
}
}
extension ViewController: RideRequestViewControllerDelegate {
func rideRequestViewController(_ rideRequestViewController: RideRequestViewController, didReceiveError error: RidesError) {
print("Ride request error: \(error.localizedDescription)")
// Handle the error, e.g., show an alert to the user
}
}
Android Quickstart (Java)
For Android, a common approach is to use the RideRequestButton provided by the SDK, which simplifies the process of setting ride parameters and launching the Uber app or a deep link. Alternatively, developers can programmatically construct a RideParameters object and use an intent to launch the Uber app.
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.uber.sdk.rides.client.ServerTokenSession;
import com.uber.sdk.rides.client.SessionConfiguration;
import com.uber.sdk.rides.client.error.ApiError;
import com.uber.sdk.rides.client.model.RideRequestParameters;
import com.uber.sdk.rides.request.RideRequestButton;
public class MainActivity extends AppCompatActivity {
private static final String CLIENT_ID = "YOUR_CLIENT_ID";
private static final String SERVER_TOKEN = "YOUR_SERVER_TOKEN";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SessionConfiguration config = new SessionConfiguration.Builder()
.setClientId(CLIENT_ID)
.setServerToken(SERVER_TOKEN)
.setRedirectUri("YOUR_REDIRECT_URI") // Required for OAuth
.setEnvironment(SessionConfiguration.Environment.SANDBOX) // Or PRODUCTION
.build();
RideRequestButton requestButton = findViewById(R.id.ride_request_button);
if (requestButton != null) {
RideRequestParameters rideParams = new RideRequestParameters.Builder()
.setPickupLocation(37.7758, -122.4180, "Uber HQ")
.setDropoffLocation(37.7844, -122.4046, "Salesforce Tower")
.setProductId("uberx")
.build();
requestButton.setRideRequestParameters(rideParams);
requestButton.setSession(new ServerTokenSession(config)); // Or OAuth2Session for user auth
requestButton.loadRideInformation(); // Fetches initial estimates
}
}
}
These examples illustrate the basic process. Real-world applications require handling authentication, error conditions, and user interface feedback, as described in the Uber API reference documentation.
Community libraries
While Uber provides official SDKs for mobile platforms, the developer community has extended support to various other programming languages, creating client libraries that wrap the Uber API. These libraries simplify interaction with the API by handling HTTP requests, JSON parsing, and authentication token management, similar to how official SDKs function. They allow developers to integrate Uber's services into web applications, backend services, or scripting environments that are not directly supported by the official mobile SDKs. The availability of these libraries can reduce development time for server-side integrations.
Some prominent community-contributed libraries include:
- Python: A popular library for Python developers, often found on PyPI, allows for programmatic access to Uber's API endpoints. It typically supports authentication flows and offers methods corresponding to various API calls, such as requesting ride estimates, viewing user activity, or managing payments. Python's versatility makes it a common choice for backend development and data processing, and libraries like these facilitate seamless integration with platforms like Google Cloud's Python developer tools.
- Node.js: JavaScript developers can utilize npm packages that abstract the Uber API, enabling server-side Node.js applications to interact with Uber. These libraries are often designed with asynchronous operations in mind, fitting well with Node.js's event-driven architecture, and are frequently used in building real-time applications or microservices.
- Ruby: For applications built with Ruby on Rails or other Ruby frameworks, community gems provide an interface to the Uber API. These libraries adhere to Ruby's conventions, offering an idiomatic way to handle API interactions, making it easier for Ruby developers to integrate ride-sharing or delivery functionalities into their projects.
- Java: Beyond the official Android SDK, general-purpose Java libraries exist for server-side applications. These libraries typically manage API requests and responses, allowing Java enterprise applications or standalone services to leverage Uber's platform.
Developers should consult the respective library's documentation and community repositories (e.g., GitHub) for installation instructions, usage examples, and information regarding maintenance status and compatibility with the latest Uber API versions. Community libraries may vary in terms of feature completeness and support compared to official SDKs.