PHP Class for the Strava API (v3)
Clone or download
Latest commit 22fabb5 Jul 2, 2018

Build Status Minimum PHP Version Packagist Packagist Downloads


The class simply houses methods to help send data to and recieve data from the API. Please read the API documentation to see what endpoints are available.

There is currently no file upload support at this time


With Composer

$ composer require iamstuartwilson/strava


Add iamstuartwilson/strava to your composer.json:

    "require" : {
        "iamstuartwilson/strava" : "~1.3"


Copy StravaApi.php to your project and require it in your application as described in the next section.

Getting Started

Include the class and instantiate with your client_id and client_secret from your registered app:

require_once 'StravaApi.php';

$api = new Iamstuartwilson\StravaApi(

You will then need to authenticate your strava account by requesting an access code1. You can generate a URL for authentication using the following method:

$api->authenticationUrl($redirect, $approvalPrompt = 'auto', $scope = null, $state = null);

When a code is returned you must then exchange it for an access token for the authenticated user:


Before making any requests you must set the access token as returned from your token exchange or via your own private token from Strava:


Example Requests

Get the most recent 100 KOMs from any athlete

$api->get('athletes/:id/koms', ['per_page' => 100]);

Post a new activity2

$api->post('activities', [
    'name'             => 'API Test',
    'type'             => 'Ride',
    'start_date_local' => date( 'Y-m-d\TH:i:s\Z'),
    'elapsed_time'     => 3600

Update a athlete's weight2

$api->put('athlete', ['weight' => 70]);

Delete an activity2



1. The account you register your app will give you an access token, so you can skip this step if you're just testing endpoints/methods.

2. These actions will need the scope set to write when authenticating a user


Latest version 1.3.0

Previous version 1.2.2

  • Possibility to access the HTTP response headers
  • PHP 7 compatibility
  • Basic PHPUnit test cases for Auth URL generation