PHPackages                             iamstuartwilson/strava - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. iamstuartwilson/strava

ActiveLibrary[API Development](/categories/api)

iamstuartwilson/strava
======================

PHP implementation of the Strava V3 API

1.4.0(6y ago)12443.1k↓43.1%25[2 issues](https://github.com/iamstuartwilson/strava/issues)[1 PRs](https://github.com/iamstuartwilson/strava/pulls)MITPHPPHP &gt;=5.5CI failing

Since Sep 4Pushed 5y ago18 watchersCompare

[ Source](https://github.com/iamstuartwilson/strava)[ Packagist](https://packagist.org/packages/iamstuartwilson/strava)[ RSS](/packages/iamstuartwilson-strava/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (1)Versions (16)Used By (0)

[![Build Status](https://camo.githubusercontent.com/18c7367de0a0a1a5ffe002eedc89aaca57ff4e0bc1c4154f397f163858411702/68747470733a2f2f7472617669732d63692e6f72672f69616d73747561727477696c736f6e2f7374726176612e737667)](https://travis-ci.org/iamstuartwilson/strava)[![Minimum PHP Version](https://camo.githubusercontent.com/735bca2bfa82bede292ead8d59049439a96c33129c23fa41da09f98bfa621316/687474703a2f2f696d672e736869656c64732e696f2f62616467652f7068702d2533453d352e352d3838393242462e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/735bca2bfa82bede292ead8d59049439a96c33129c23fa41da09f98bfa621316/687474703a2f2f696d672e736869656c64732e696f2f62616467652f7068702d2533453d352e352d3838393242462e7376673f7374796c653d666c6174)[![Packagist](https://camo.githubusercontent.com/fe6d0d64b8631996c03695e378e511aafb5bf564240d97c67619bbb6720cc190/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f69616d73747561727477696c736f6e2f7374726176612e737667)](https://camo.githubusercontent.com/fe6d0d64b8631996c03695e378e511aafb5bf564240d97c67619bbb6720cc190/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f69616d73747561727477696c736f6e2f7374726176612e737667)[![Packagist Downloads](https://camo.githubusercontent.com/53ba6f716af1bff9642ec7cd81489c47bc59eacac56d0cdb9774a1a48a0d90fa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f69616d73747561727477696c736f6e2f7374726176612e737667)](https://camo.githubusercontent.com/53ba6f716af1bff9642ec7cd81489c47bc59eacac56d0cdb9774a1a48a0d90fa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f69616d73747561727477696c736f6e2f7374726176612e737667)

StravaApi
=========

[](#stravaapi)

The class simply houses methods to help send data to and receive data from the API. Please read the [API documentation](https://developers.strava.com/docs/reference/) to see what endpoints are available.

*There is no file upload support at this time.*

Installation
------------

[](#installation)

### With Composer

[](#with-composer)

```
composer require iamstuartwilson/strava
```

Or add it manually to your `composer.json`:

```
{
    "require" : {
        "iamstuartwilson/strava" : "^1.4"
    }
}
```

### Manually

[](#manually)

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

Getting Started
---------------

[](#getting-started)

Instantiate the class with your **client\_id** and **client\_secret** from your [registered app](https://www.strava.com/settings/api):

```
require_once 'StravaApi.php';

$api = new Iamstuartwilson\StravaApi(
    $clientId,
    $clientSecret
);
```

If you're just testing endpoints/methods you can skip the authentication flow and just use the access token from your [settings page](https://www.strava.com/settings/api).

You will then need to [authenticate](https://developers.strava.com/docs/authentication/) your strava account by requesting an access code. 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 and a refresh token](http://developers.strava.com/docs/authentication/#token-exchange) for the authenticated user:

```
$result = $api->tokenExchange($code);
```

The token exchange result contains among other data the tokens. You can access them as attributes of the result object:

```
$accessToken = $result->access_token;
$refreshToken = $result->refresh_token;
$expiresAt = $result->expires_at;
```

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

```
$api->setAccessToken($accessToken, $refreshToken, $expiresAt);
```

Example oAuth2 Authentication Flow
----------------------------------

[](#example-oauth2-authentication-flow)

`examples/oauth-flow.php` demonstrates how the oAuth2 authentication flow works.

1. Choose how to load the `StravaApi.php` – either via Composer autoloader or by manually *requiring* it.
2. Replace the three config values `CALLBACK_URL`, `STRAVA_API_ID`, and `STRAVA_API_SECRET` at the top of the file
3. Place the file on your server so that it's accessible at `CALLBACK_URL`
4. Point your browser to `CALLBACK_URL` and start the authentication flow.

The scripts prints a lot of verbose information so you get an idea on how the Strava oAuth flow works.

Example Requests
----------------

[](#example-requests)

Once successfully authenticated you're able to communicate with Strava's API.

All actions that change Strava contents (`post`, `put`, `delete`) will need the **scope** set to *write* in the authentication flow.

### Get Athlete Stats

[](#get-athlete-stats)

```
$api->get('athletes/:id/stats');
```

### List Athlete Activities

[](#list-athlete-activities)

Some API endpoints support GET parameters:

```
$api->get(
    'athlete/activities',
    [
        'page' => 2,
        'per_page' => 10,
    ]
);
```

### Post a new activity

[](#post-a-new-activity)

```
$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 weight

[](#update-a-athletes-weight)

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

Releases
--------

[](#releases)

See [CHANGELOG.md](https://github.com/iamstuartwilson/strava/blob/master/CHANGELOG.md).

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 63.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~153 days

Recently: every ~292 days

Total

13

Last Release

2429d ago

Major Versions

0.1 → 1.02014-12-27

PHP version history (3 changes)0.1PHP &gt;=5.3

1.0.2PHP ~5.5

1.1.1PHP &gt;=5.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/23fadaeec8e111a2b7fa187ee3986b46e9e201830f6a07953975988a20f25670?d=identicon)[iamstuartwilson](/maintainers/iamstuartwilson)

---

Top Contributors

[![mjaschen](https://avatars.githubusercontent.com/u/328130?v=4)](https://github.com/mjaschen "mjaschen (36 commits)")[![iamstuartwilson](https://avatars.githubusercontent.com/u/3594817?v=4)](https://github.com/iamstuartwilson "iamstuartwilson (10 commits)")[![adriangibbons](https://avatars.githubusercontent.com/u/10218647?v=4)](https://github.com/adriangibbons "adriangibbons (6 commits)")[![LewisCraik](https://avatars.githubusercontent.com/u/24432037?v=4)](https://github.com/LewisCraik "LewisCraik (2 commits)")[![Niellles](https://avatars.githubusercontent.com/u/10075507?v=4)](https://github.com/Niellles "Niellles (2 commits)")[![bryant1410](https://avatars.githubusercontent.com/u/3905501?v=4)](https://github.com/bryant1410 "bryant1410 (1 commits)")

---

Tags

api-clientcyclingfitnessstrava

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/iamstuartwilson-strava/health.svg)

```
[![Health](https://phpackages.com/badges/iamstuartwilson-strava/health.svg)](https://phpackages.com/packages/iamstuartwilson-strava)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
