Need help with StravaPHP?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

146 Stars 57 Forks MIT License 235 Commits 0 Opened issues


Strava API REST client with OAuth authentication

Services available


Need anything else?

Contributors list


Build Status Code Coverage Scrutinizer Code Quality

TLDR; Strava V3 API PHP client with OAuth authentication

The Strava V3 API is a publicly available interface allowing developers access to the rich Strava dataset. The interface is stable and currently used by the Strava mobile applications. However, changes are occasionally made to improve performance and enhance features. See the changelog for more details.

In this GitHub repository you can find the PHP implementation of the Strava V3 API. The current version of StravaPHP combines the V3 API with a proper OAuth authentication.

Getting started

Get your API key

All calls to the Strava API require an access token defining the athlete and application making the call. Any registered Strava user can obtain an access token by first creating an application at

Composer package

Use composer to install this StravaPHP package.

    "require": {
        "basvandorst/stravaphp": "1.5.0"

StravaPHP usage

First, authorisation and authentication

use Strava\API\OAuth;
use Strava\API\Exception;

try { $options = [ 'clientId' => 1234, 'clientSecret' => 'APP-TOKEN', 'redirectUri' => 'http://my-app/callback.php' ]; $oauth = new OAuth($options);

if (!isset($_GET['code'])) {
    print '<a href="'.%24oauth-&gt;getAuthorizationUrl(%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20//%20Uncomment%20required%20scopes.%0A%20%20%20%20%20%20%20%20%20%20%20%20'scope'%20=&gt;%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20'read',%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20//%20'read_all',%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20//%20'profile:read_all',%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20//%20'profile:write',%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20//%20'activity:read',%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20//%20'activity:read_all',%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20//%20'activity:write',%0A%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%5D).'">Connect</a>';
} else {
    $token = $oauth-&gt;getAccessToken('authorization_code', [
        'code' =&gt; $_GET['code']
    print $token-&gt;getToken();

} catch(Exception $e) { print $e->getMessage(); }

Then, call your API method!

use Strava\API\Client;
use Strava\API\Exception;
use Strava\API\Service\REST;

try { $adapter = new \GuzzleHttp\Client(['base_uri' => '']); $service = new REST($token->getToken(), $adapter); // Define your user token here. $client = new Client($service);

$athlete = $client-&gt;getAthlete();

$activities = $client-&gt;getAthleteActivities();

$club = $client-&gt;getClub(9729);

} catch(Exception $e) { print $e->getMessage(); }

Class documentation



use Strava\API\Factory;

// Configure your app ID, app token and callback uri $factory = new Factory(); $OAuthClient = $factory->getOAuthClient(1234, 'APP-TOKEN', 'http://my-app/callback.php');


$factory->getOAuthClient($client_id, $client_secret, $redirect_uri);



use Strava\API\OAuth;

// Parameter information: $options = [ 'clientId' => 1234, 'clientSecret' => 'APP-TOKEN', 'redirectUri' => 'http://my-app/callback.php' ]; $oauth = new OAuth($options);

// The OAuth authorization procces (1st; let the user approve, 2nd; token exchange with Strava) if (!isset($_GET['code'])) { print 'Connect'; } else { $token = $oauth->getAccessToken('authorization_code', [ 'code' => $_GET['code'] ]); print $token->getToken(); }


$oauth->getAuthorizationUrl($options = []);
$oauth->getAccessToken($grant = 'authorization_code', $params = []);



// REST adapter (We use `Guzzle` in this project)
use GuzzleHttp\Client as GuzzleClient;
use Strava\API\Service\REST;
use Strava\API\Client;

$adapter = new GuzzleClient(['base_uri' => '']); // Service to use (Service\Stub is also available for test purposes) $service = new REST('RECEIVED-TOKEN', $adapter);

// Receive the athlete! $client = new Client($service); $athlete = $client->getAthlete(); print_r($athlete);


$client->getAthlete($id = null);
$client->getAthleteRoutes($id, $type = null, $after = null, $page = null, $per_page = null);
$client->getAthleteActivities($before = null, $after = null, $page = null, $per_page = null);
$client->getAthleteFriends($id = null, $page = null, $per_page = null);
$client->getAthleteFollowers($id = null, $page = null, $per_page = null);
$client->getAthleteBothFollowing($id, $page = null, $per_page = null);
$client->getAthleteKom($id, $page = null, $per_page = null);
$client->getAthleteStarredSegments($id = null, $page = null, $per_page = null);
$client->updateAthlete($city, $state, $country, $sex, $weight);
$client->getActivityFollowing($before = null, $page = null, $per_page = null); 
$client->getActivity($id, $include_all_efforts = null);
$client->getActivityComments($id, $markdown = null, $page = null, $per_page = null);
$client->getActivityKudos($id, $page = null, $per_page = null);
$client->getActivityPhotos($id, $size = 2048, $photo_sources = 'true');
$client->createActivity($name, $type, $start_date_local, $elapsed_time, $description = null, $distance = null);
$client->uploadActivity($file, $activity_type = null, $name = null, $description = null, $private = null, $commute = null, $trainer = null, $data_type = null, $external_id = null);
$client->updateActivity($id, $name = null, $type = null, $private = false, $commute = false, $trainer = false, $gear_id = null, $description = null);
$client->getClubMembers($id, $page = null, $per_page = null);
$client->getClubActivities($id, $page = null, $per_page = null);
$client->getSegmentLeaderboard($id, $gender = null, $age_group = null, $weight_class = null, $following = null, $club_id = null, $date_range = null, $page = null, $per_page = null);
$client->getSegmentExplorer($bounds, $activity_type = 'riding', $min_cat = null, $max_cat = null);
$client->getSegmentEffort($id, $athlete_id = null, $start_date_local = null, $end_date_local = null, $page = null, $per_page = null);
$client->getStreamsActivity($id, $types, $resolution = null, $series_type = 'distance');
$client->getStreamsEffort($id, $types, $resolution = null, $series_type = 'distance');
$client->getStreamsSegment($id, $types, $resolution = null, $series_type = 'distance');

UML diagrams

Class diagram


Sequence diagram


About StravaPHP

Used libraries


The StravaPHP library was created by Bas van Dorst, software engineer and cyclist enthusiast. And of course, special thanks to all contributors


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


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

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.