Uber API PHP client with OAuth authentication

1.0.0 2014-12-29 20:01 UTC

This package is not auto-updated.

Last update: 2020-03-30 18:36:52 UTC


Build Status Scrutinizer Code Quality

TLDR; Uber API PHP client with OAuth authentication

In this GitHub repository you can find the PHP implementation of the Uber API. The current version of UberPHP combines the V1 Uber API with a proper OAuth authentication.

"We believe that any app with a map is a potential Uber API partner. To kick things off, we’re launching with 11 fantastic companies, all of whom have already integrated with the API and are rolling out in cities around the world: Expensify, Hinge, Hyatt Hotels & Resorts, Momento, OpenTable, Starbucks Coffee Company, Tempo Smart Calendar, Time Out, TripAdvisor, TripCase and United Airlines[...]"

Getting started

Get your API key

All calls to the Uber API require an user or server token. Any registered Uber user can obtain an access token by first creating an application at

Composer package

Use composer to install this UberPHP package.

    "require": {
        "basvandorst/UberPHP": "1.0.0"

UberPHP usage

Example without user authorisation

include 'vendor/autoload.php';

use Pest;
use Uber\API\Client;

try {
    $adapter = new Pest('');
    $client = new Client($adapter, $token, false); // define SERVER token here
    $products = $client->products(38.9059540,-77.0419260);
    $estimatesPrice = $client->estimatesPrice(38.9059540,-77.0419260,37.9059540,-76.0419260);
    $estimatesTime = $client->estimatesTime(38.9059540,-77.0419260,37.9059540,-76.0419260);
} catch(Exception $e) {
    print $e->getMessage();

Example with OAuth user authorisation

First, authorisation and authentication
include 'vendor/autoload.php';

use Pest;
use Uber\API\OAuth;

try {
    $options = array(
        'clientId'     => 12345, 
        'clientSecret' => 'CLIENT_SECRET',
        'redirectUri'  => 'CALLBACK_URI'
    $oauth = new OAuth($options);

    if (!isset($_GET['code'])) {
        print '<a href="'.$oauth->getAuthorizationUrl().'">connect</a>';
    } else {
        $token = $oauth->getAccessToken('authorization_code', array(
            'code' => $_GET['code']
        print $token;
} catch(\Exception $e) {
    print $e->getMessage();
Then, call the API method!
include 'vendor/autoload.php';

use Pest;
use Uber\API\Client;

try {
    $adapter = new Pest('');
    $client = new Client($adapter, $token, true); // define USER token here
    $profile = $client->userProfile(false);
    $activities = $client->userActivity();
} catch(Exception $e) {
    print $e->getMessage();

Accepted methods

OAuth user authorisation required

$client->userActivity($lite = false);

Only server authorisation required

$client->products($latitude, $longitude);
$client->promotions($start_latitude, $start_longitude, $end_latitude, $end_longitude); (not working)
$client->estimatesPrice($start_latitude, $start_longitude, $end_latitude, $end_longitude)
$client->estimatesTime($start_latitude, $start_longitude, $end_latitude, $end_longitude)

About UberPHP

Used libraries


The UberPHP library was created by Bas van Dorst, software engineer.


All issues and pull requests should be filled on the basvandorst/UberPHP repository.


The UberPHP library is open-source software licensed under MIT license.