PHPackages                             deniztezcan/laravel-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. deniztezcan/laravel-strava

ActiveLibrary[API Development](/categories/api)

deniztezcan/laravel-strava
==========================

A laravel package to access data from the Strava API.

2.0.0(5y ago)038MITPHP

Since Apr 13Pushed 5y agoCompare

[ Source](https://github.com/deniztezcan/laravel-strava)[ Packagist](https://packagist.org/packages/deniztezcan/laravel-strava)[ RSS](/packages/deniztezcan-laravel-strava/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (2)Versions (12)Used By (0)

Laravel Strava Package
======================

[](#laravel-strava-package)

A laravel package to access data from the Strava API. Compatible with `Laravel 5.0` and above. Forked from @RichieMcMullen due to his package not being able to be used on Laravel 8.

Table of Contents
-----------------

[](#table-of-contents)

- [Strava Access Credentials](https://github.com/deniztezcan/strava#strava-access-credentials)
- [Installation](https://github.com/deniztezcan/strava#installation)
- [Publish Strava Config File](https://github.com/deniztezcan/strava#publish-strava-config-file)
- [Auto Discovery](https://github.com/deniztezcan/strava#auto-discovery)
    - [Provider](https://github.com/deniztezcan/strava#provider)
    - [Facade](https://github.com/deniztezcan/strava#alias--facade)
- [Usage](https://github.com/deniztezcan/strava#usage)
    - [Initialise Facade](https://github.com/deniztezcan/strava#use-strava-facade)
    - [Authenticate User](https://github.com/deniztezcan/strava#authenticate-user)
    - [Get Access Token](https://github.com/deniztezcan/strava#get-access-token)
    - [Access Token Expiry](https://github.com/deniztezcan/strava#access-token-expiry)
    - [Unauthenticate User](https://github.com/deniztezcan/strava#unauthenticate-user)
- [Available Methods](https://github.com/deniztezcan/strava#usage)
    - [Athlete Data](https://github.com/deniztezcan/strava#athelete-data)
    - [User Activities Data](https://github.com/deniztezcan/strava#user-activities-data)
    - [User Single Activity](https://github.com/deniztezcan/strava#user-single-activity)
    - [User Single Activity Stream](https://github.com/deniztezcan/strava#user-single-activity-stream)
    - [Activity Comments](https://github.com/deniztezcan/strava#activity-comments)
    - [Activity Kudos](https://github.com/deniztezcan/strava#activity-kudos)
    - [Activity Laps](https://github.com/deniztezcan/strava#activity-laps)
    - [Activity Zones](https://github.com/deniztezcan/strava#activity-zones)
    - [Athlete Zones](https://github.com/deniztezcan/strava#athlete-zones)
    - [Athlete Stats](https://github.com/deniztezcan/strava#athlete-stats)
    - [Club](https://github.com/deniztezcan/strava#club)
    - [Club Members](https://github.com/deniztezcan/strava#club-members)
    - [Club Activities](https://github.com/deniztezcan/strava#club-activities)
    - [Club Admins](https://github.com/deniztezcan/strava#club-admins)
    - [Athlete Clubs](https://github.com/deniztezcan/strava#athlete-clubs)
    - [Gear](https://github.com/deniztezcan/strava#gear)
    - [Route](https://github.com/deniztezcan/strava#route)
    - [Athlete Routes](https://github.com/deniztezcan/strava#athlete-routes)
    - [Segment](https://github.com/deniztezcan/strava#segment)
    - [Segment Effort](https://github.com/deniztezcan/strava#segment-effort)
    - [Starred Segments](https://github.com/deniztezcan/strava#starred-segments)
- [Parameter Types](https://github.com/deniztezcan/strava#parameter-types)
- [Caching](https://github.com/deniztezcan/laravel-strava#caching)
- [Useful Links](https://github.com/deniztezcan/laravel-strava#useful-links)

Strava Access Credentials
-------------------------

[](#strava-access-credentials)

In order to use this package you will need to create an app from within your strava account. [Create Strava App](https://www.strava.com/settings/api) to access your API credentials. Click here for more information on the [Strava API](https://developers.strava.com/).

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

[](#installation)

To install the package within your laravel project use the following composer command:

```
composer require deniztezcan/laravel-strava
```

Publish Strava Config File
--------------------------

[](#publish-strava-config-file)

The `vendor:publish` commmand will publish a file named `strava.php` within your laravel project config folder `config/strava.php`. Edit this file with your Strava API credentials, generated from the Strava app you created.

```
php artisan vendor:publish --provider="DenizTezcan\Strava\StravaServiceProvider"
```

Published Config File Contents

```
'client_id' => env('STRAVA_CLIENT_ID', '')
'client_secret' => env('STRAVA_SECRET_ID', '')
'redirect_uri' => env('STRAVA_REDIRECT_URI', '')
```

Alternatively you can ignore the above publish command and add this following variables to your `.env` file. Make sure to add your Strava App credentials

```
STRAVA_CLIENT_ID=ADD-STRAVA-CLIENT-ID-HERE
STRAVA_SECRET_ID=ADD-STRAVA-SECRET-HERE
STRAVA_REDIRECT_URI=ADD-STRAVA-REDIRECT-URI-HERE

```

Auto Discovery
--------------

[](#auto-discovery)

If you're using Laravel 5.5+ you don't need to manually add the service provider or facade. This will be Auto-Discovered. For all versions of Laravel below 5.5, you must manually add the ServiceProvider &amp; Facade to the appropriate arrays within your Laravel project `config/app.php`

#### Provider

[](#provider)

```
DenizTezcan\Strava\StravaServiceProvider::class,
```

#### Alias / Facade

[](#alias--facade)

```
'Strava' => DenizTezcan\Strava\StravaFacade::class,
```

Usage
-----

[](#usage)

#### Use Strava Facade

[](#use-strava-facade)

Add the Strava facade to the top of your controller so you can access the Strava class methods.

```
use Strava;

class MyController extends Controller
{
  // Controller functions here...
}
```

#### Authenticate User

[](#authenticate-user)

Call the `Strava::authenticate()` method to redirect you to Strava. If authentication is successful the user will be redirected to the `redirect_uri` that you added to the `config` file or your `.env` file. You may now also pass `$scope` as a parameter when authenticating. You can add or remove scopes as required. Some are required, some are optional. Details on available scopes can be seen here [Strava Authentication Scopes](https://developers.strava.com/docs/authentication/)

```
public function stravaAuth()
{
  return Strava::authenticate($scope='read_all,profile:read_all,activity:read_all');
}
```

#### Obtain User Access Token

[](#obtain-user-access-token)

When returned to the redirected uri, call the `Strava::token($code)` method to generate the users Strava access token &amp; refresh token. The tokens are generated using the `code` parameter value within the redirected uri. Be sure to store the users `access_token` &amp; `refresh_token` in your database.

```
public function getToken(Request $request)
{
  $token = Strava::token($request->code);

  // Store $token->access_token & $token->refresh_token in database
}
```

Example Response

```
"token_type": "Bearer"
"expires_at": 1555165838
"expires_in": 21600 // 6 Hours
"refresh_token": "671129e56b1ce64d7e0c7e594cb6522b239464e1"
"access_token": "e105062b153da39f81a439b90b23357c741a40a0"
"athlete": ...
```

At this point you have access to the `Athlete` object that can be used to login to your website. Of course you'll need to write the logic for your login system, but the athlete name, email etc.. is contained within the object for you to verify the user against your own database data.

#### Access Token Expiry

[](#access-token-expiry)

Access tokens will now expire after 6 hours under the new flow that Strava have implemented and will need to be updated using a refresh token. In the example above you can see the response has a `refresh_token` and an `expires_at` field. When storing the user access tokens you may also want to store the `expires_at` field too. This will allow you to check when the current access token has expired.

When calling any of the Strava methods below you may want to compare the current time against the `expires_at` field in order to validate the token. If the token is expired you'll need to call the `Strava::refreshToken($refreshToken)` method in order to generate a new tokens. All you need to do is pass the users currently stored `refresh_token`, the method will then return a new set of tokens (access &amp; refresh), update the current users tokens with the new tokens from the response. Heres an example of how that might work, using the `Strava::athlete($token)` method.

```
public function myControllerFunction(Request $request)
{
  // Get the user
  $user = User::find($request->id);

  // Check if current token has expired
  if(Carbon::now() > $user->expires_at)
  {
    // Token has expired, generate new tokens using the currently stored user refresh token
    $refresh = Strava::refreshToken($user->refresh_token);

    // Update the users tokens
    User::where('id', $request->id)->update([
      'access_token' => $refresh->access_token,
      'refresh_token' => $refresh->refresh_token
    ]);

    // Call Strava Athlete Method with newly updated access token.
    $athlete = Strava::athlete($user->access_token);

    // Return $athlete array to view
    return view('strava.athlete')->with(compact('athlete'));

  }else{

    // Token has not yet expired, Call Strava Athlete Method
    $athlete = Strava::athlete($user->access_token);

    // Return $athlete array to view
    return view('strava.athlete')->with(compact('athlete'));

  }

}
```

#### Unauthenticate User

[](#unauthenticate-user)

You can allow users to unauthenticate their Strava account with your Strava app. Simply allow users to call the following method, passing the access token that has been stored for their account.

```
Strava::unauthenticate($token);
```

Available Methods
-----------------

[](#available-methods)

All methods require an access token, some methods accept additional optional parameters listed below.

- Optional Parameters
    - $page (Int - default 1)
    - $perpage (Int - default 10)
    - $before (Int/Timestamp - default = most recent)
    - $after (Int/Timestamp - default = most recent)

#### Athlete Data

[](#athlete-data)

Returns the currently authenticated athlete.

```
Strava::athlete($token);
```

#### User Activities Data

[](#user-activities-data)

Returns the activities of an athlete.

```
Strava::activities($token, $page, $perPage, $before, $after);
```

#### User Single Activity

[](#user-single-activity)

Returns the given activity that is owned by the authenticated athlete.

```
Strava::activity($token, $activityID);
```

#### User Single Activity Stream

[](#user-single-activity-stream)

Returns the given activity's streams.

```
// $keys is a string array containing required streams
// e.g. ['latlng', 'time']
Strava::activityStream($token, $activityID, $keys = '', $keyByType = true);
```

#### Activity Comments

[](#activity-comments)

Returns the comments on the given activity.

```
Strava::activityComments($token, $activityID, $page, $perPage);
```

#### Activity Kudos

[](#activity-kudos)

Returns the athletes who kudoed an activity.

```
Strava::activityKudos($token, $activityID, $page, $perPage);
```

#### Activity Laps

[](#activity-laps)

Returns the laps data of an activity.

```
Strava::activityLaps($token, $activityID);
```

#### Activity Zones

[](#activity-zones)

Summit Feature Required. Returns the zones of a given activity.

```
Strava::activityZones($token, $activityID);
```

#### Athlete Zones

[](#athlete-zones)

Returns the the authenticated athlete's heart rate and power zones.

```
Strava::athleteZones($token);
```

#### Athlete Stats

[](#athlete-stats)

Returns the activity stats of an athlete.

```
Strava::athleteStats($token, $athleteID, $page, $perPage);
```

#### Club

[](#club)

Returns a given club using its identifier.

```
Strava::club($token, $clubID);
```

#### Club Members

[](#club-members)

Returns a list of the athletes who are members of a given club.

```
Strava::clubMembers($token, $clubID, $page, $perPage);
```

#### Club Activities

[](#club-activities)

Retrieve recent activities from members of a specific club. The authenticated athlete must belong to the requested club in order to hit this endpoint. Pagination is supported. Athlete profile visibility is respected for all activities.

```
Strava::clubActivities($token, $clubID, $page, $perPage);
```

#### Club Admins

[](#club-admins)

Returns a list of the administrators of a given club.

```
Strava::clubAdmins($token, $clubID, $page, $perPage);
```

#### Athlete Clubs

[](#athlete-clubs)

Returns a list of the clubs whose membership includes the authenticated athlete.

```
Strava::athleteClubs($token, $page, $perPage);
```

#### Gear

[](#gear)

Returns equipment data using gear ID.

```
Strava::gear($token, $gearID);
```

#### Route

[](#route)

Returns a route using its route ID.

```
Strava::route($token, $routeID);
```

#### Athlete Routes

[](#athlete-routes)

Returns a list of the routes created by the authenticated athlete using their athlete ID.

```
Strava::athleteRoutes($token, $athleteID, $page, $perPage);
```

#### Segment

[](#segment)

Returns the specified segment.

```
Strava::segment($token, $segmentID);
```

#### Segment Effort

[](#segment-effort)

Returns a segment effort from an activity that is owned by the authenticated athlete.

```
Strava::segmentEffort($token, $segmentID);
```

#### Starred Segments

[](#starred-segments)

List of the authenticated athlete's starred segments.

```
Strava::starredSegments($token, $page, $perPage);
```

Parameter Types
---------------

[](#parameter-types)

```
$token        = String
$activityID   = integer
$athleteID    = integer
$clubID       = integer
$gearID       = integer
$routeID      = integer
$segmentID    = integer
$page         = integer
$perPage      = integer
$before       = integer (timestamp)
$after        = integer (timestamp)
```

Caching
-------

[](#caching)

It's highly recommended that you cache your requests made to Strava for 2 reasons.

#### (1) Rate Limiting

[](#1-rate-limiting)

Strava have quite a good API Rate Limit, 600 requests every 15 minutes, 30,000 daily. If your website has high traffic you might want to consider caching your Strava response data so you don't exceed these limits.

#### (2) Website Loading Speed

[](#2-website-loading-speed)

Caching your Strava data will drastically improve website load times.

Useful Links
------------

[](#useful-links)

- [Laravel Caching Documentation](https://laravel.com/docs/5.8/cache)
- [Strava Developers](https://developers.strava.com/)
- [Strava App Creation](https://www.strava.com/settings/api)

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 86.7% 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 ~64 days

Recently: every ~52 days

Total

10

Last Release

2006d ago

Major Versions

v1.0.9 → 2.0.02020-11-13

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10155092?v=4)[Deniz Tezcan](/maintainers/deniztezcan)[@deniztezcan](https://github.com/deniztezcan)

---

Top Contributors

[![RichieMcMullen](https://avatars.githubusercontent.com/u/8255180?v=4)](https://github.com/RichieMcMullen "RichieMcMullen (72 commits)")[![deniztezcan](https://avatars.githubusercontent.com/u/10155092?v=4)](https://github.com/deniztezcan "deniztezcan (5 commits)")[![iDemonix](https://avatars.githubusercontent.com/u/3519214?v=4)](https://github.com/iDemonix "iDemonix (3 commits)")[![chrisbarr](https://avatars.githubusercontent.com/u/357176?v=4)](https://github.com/chrisbarr "chrisbarr (1 commits)")[![johnevason](https://avatars.githubusercontent.com/u/1043811?v=4)](https://github.com/johnevason "johnevason (1 commits)")[![RosiersRobin](https://avatars.githubusercontent.com/u/5263188?v=4)](https://github.com/RosiersRobin "RosiersRobin (1 commits)")

### Embed Badge

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

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

###  Alternatives

[skagarwal/google-places-api

Google Places Api

1913.0M8](/packages/skagarwal-google-places-api)[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[smodav/mpesa

M-Pesa API implementation

16363.7k1](/packages/smodav-mpesa)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1344.8k1](/packages/jasara-php-amzn-selling-partner-api)[grantholle/powerschool-api

A Laravel package to make interacting with PowerSchool less painful.

1715.6k1](/packages/grantholle-powerschool-api)

PHPackages © 2026

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