PHPackages                             jordanpartridge/strava-client - 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. jordanpartridge/strava-client

ActiveLibrary

jordanpartridge/strava-client
=============================

This is my package strava-client

v0.5.0(10mo ago)1376↓100%[6 PRs](https://github.com/jordanpartridge/strava-client/pulls)MITPHPPHP ^8.2CI failing

Since Oct 28Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/jordanpartridge/strava-client)[ Packagist](https://packagist.org/packages/jordanpartridge/strava-client)[ Docs](https://github.com/jordanpartridge/strava-client)[ GitHub Sponsors](https://github.com/JordanPartridge)[ RSS](/packages/jordanpartridge-strava-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (13)Versions (24)Used By (0)

Laravel Strava Client
=====================

[](#laravel-strava-client)

A thoughtfully crafted Strava API integration for Laravel developers who value clean, maintainable code. Stop wrestling with OAuth and start building features that matter.

[![Latest Version on Packagist](https://camo.githubusercontent.com/d23db83157d3b0c4871637b3a9dc163202c839ee19dfd053835e9666f1fc9c9a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6f7264616e7061727472696467652f7374726176612d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jordanpartridge/strava-client)[![GitHub Tests Action Status](https://camo.githubusercontent.com/c64e7666c5c909a7d4be9842e09be4616f8b6c9a4e8598faca8b72c412faa7e6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a6f7264616e7061727472696467652f7374726176612d636c69656e742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/jordanpartridge/strava-client/actions?query=workflow%3Arun-tests+branch%3Amain)[![Code Coverage](https://camo.githubusercontent.com/eed8b8513756215340519332f02febbd8933c3d14f03b85f60ef78449282017c/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6a6f7264616e7061727472696467652f7374726176612d636c69656e743f7374796c653d666c61742d737175617265)](https://app.codecov.io/gh/jordanpartridge/strava-client)[![Total Downloads](https://camo.githubusercontent.com/155145c2927bcb32d63e1ff30e0cd943cdd697cfc3d19d3af9fab2e5b86be71f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6f7264616e7061727472696467652f7374726176612d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jordanpartridge/strava-client)

This package reflects my belief that developer tools should be both powerful and pleasant to use. Built with Laravel best practices and a focus on developer experience.

✨ Why Choose This Package?
--------------------------

[](#-why-choose-this-package)

- 🔌 **True Plug &amp; Play**: OAuth flow that just works, because you shouldn't need a degree in authentication
- 🔄 **Intelligent Token Handling**: Automatic refresh handling - set it and forget it
- 🏃‍♂️ **Activity Ready**: Fetch athlete activities with eloquent simplicity
- 🔒 **Security First**: Encrypted token storage and robust error handling out of the box
- 🎯 **Laravel Native**: Built the way Laravel packages should be
- 📦 **Production Ready**: Scales from personal projects to multi-user applications

🚀 Quick Start
-------------

[](#-quick-start)

### 1. Install the package

[](#1-install-the-package)

```
composer require jordanpartridge/strava-client
```

### 2. Run the installer

[](#2-run-the-installer)

```
php artisan strava-client:install
```

### 3. Set up your User model

[](#3-set-up-your-user-model)

Add the `HasStravaTokens` trait and `HasStravaToken` interface to your User model:

```
use JordanPartridge\StravaClient\Contracts\HasStravaToken;
use JordanPartridge\StravaClient\Concerns\HasStravaTokens;

class User extends Authenticatable implements HasStravaToken
{
    use HasStravaTokens;
}
```

### 4. Add your Strava credentials to `.env`

[](#4-add-your-strava-credentials-to-env)

```
STRAVA_CLIENT_ID=your-client-id
STRAVA_CLIENT_SECRET=your-client-secret
```

### 5. Connect to Strava

[](#5-connect-to-strava)

Visit `/strava/authorize` as an authenticated user to start the OAuth flow.

### 6. Start building!

[](#6-start-building)

```
use JordanPartridge\StravaClient\Facades\StravaClient;

// Clean, intuitive API for fetching activities
$activities = StravaClient::activityForAthlete(page: 1, per_page: 10);

// Direct access to specific activities
$activity = StravaClient::getActivity($activityId);
```

🔄 Behind the Scenes
-------------------

[](#-behind-the-scenes)

The package handles all the complex OAuth interactions so you don't have to:

1. Secure authorization initiation via `/strava/authorize`
2. Automated OAuth callback processing
3. Encrypted token storage
4. Automatic token refresh handling
5. Clean user token associations

🔧 Configuration
---------------

[](#-configuration)

Fine-tune the package behavior through `config/strava-client.php`:

```
return [
    // Customize the Strava access scope
    'scope' => env('STRAVA_CLIENT_SCOPE', 'read,activity:read_all'),

    // Adjust token refresh behavior
    'max_refresh_attempts' => env('STRAVA_CLIENT_MAX_REFRESH_ATTEMPTS', 3),

    // Set your post-connection redirect
    'redirect_after_connect' => env('STRAVA_CLIENT_REDIRECT_AFTER_CONNECT', '/admin'),
];
```

⚡️ Professional Error Handling
------------------------------

[](#️-professional-error-handling)

Handle API interactions with confidence using custom exception types:

```
use JordanPartridge\StravaClient\Exceptions\Request\BadRequestException;
use JordanPartridge\StravaClient\Exceptions\Request\RateLimitExceededException;
use JordanPartridge\StravaClient\Exceptions\Request\ResourceNotFoundException;
use JordanPartridge\StravaClient\Exceptions\Request\StravaServiceException;

try {
    $activity = StravaClient::getActivity($id);
} catch (BadRequestException $e) {
    // Handle malformed requests
} catch (RateLimitExceededException $e) {
    // Handle API rate limits
} catch (ResourceNotFoundException $e) {
    // Handle missing activities
} catch (StravaServiceException $e) {
    // Handle server errors (500, 502, 504)
}
```

### 🔄 Automatic Retry Logic

[](#-automatic-retry-logic)

The package intelligently handles temporary service outages:

- **503 Service Unavailable**: Automatically retries up to 3 times with exponential backoff (1s, 2s, 4s delays)
- **Token Expiration**: Automatically refreshes expired tokens and retries the original request
- **Other Server Errors**: Throws `StravaServiceException` immediately for proper error handling

This means your application stays resilient even when Strava experiences temporary issues.

#### Production Considerations

[](#production-considerations)

When handling 503 errors in production, consider:

1. **Queue Jobs**: For non-critical operations, queue jobs with delay:

    ```
    use App\Jobs\SyncStravaActivities;

    try {
        $activities = StravaClient::activityForAthlete(1, 50);
    } catch (\RuntimeException $e) {
        if (str_contains($e->getMessage(), 'service unavailable')) {
            // Retry in 15 minutes
            SyncStravaActivities::dispatch($user)->delay(now()->addMinutes(15));
        }
    }
    ```
2. **User Feedback**: Inform users about temporary issues:

    ```
    try {
        $activity = StravaClient::getActivity($id);
    } catch (\RuntimeException $e) {
        if ($e->getCode() === 503) {
            return back()->with('error', 'Strava is temporarily unavailable. Please try again in a few minutes.');
        }
    }
    ```
3. **Monitoring**: Log retry attempts for visibility into API health

🧪 Quality Assurance
-------------------

[](#-quality-assurance)

Run the test suite:

```
composer test
```

🔄 Compatibility
---------------

[](#-compatibility)

This package supports:

- PHP 8.2 or higher
- Laravel 10.x and 11.x
- Laravel 12.x (in development)

📝 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

👤 About the Author
------------------

[](#-about-the-author)

Hi! I'm Jordan Partridge, and I build packages like this with a focus on developer experience and clean, maintainable code. If you appreciate the attention to detail in this package and my approach to solving problems, I'm available for hire on Laravel and PHP projects.

**[Visit my website](https://jordanpartridge.us) to learn more about my work and how we might collaborate on your next project.**

Need help with this package or want to discuss a project? Reach me at .

❤️ Support
----------

[](#️-support)

If you find this package helpful, please consider:

- Starring the repo on GitHub
- Sharing it with other developers
- Checking out [my other packages](https://jordanpartridge.us)

---

Made with ♥️ in Laravel by a developer who cares about your experience

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance73

Regular maintenance activity

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 72.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 ~20 days

Recently: every ~55 days

Total

13

Last Release

314d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a6bb27de88a541a632427686306c8fc56366d72582f6a3316d20500efe7971f3?d=identicon)[conduit-ui](/maintainers/conduit-ui)

---

Top Contributors

[![jordanpartridge](https://avatars.githubusercontent.com/u/9040417?v=4)](https://github.com/jordanpartridge "jordanpartridge (39 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

laravelJordanPartridgestrava-client

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1221.1k](/packages/codebar-ag-laravel-docuware)[codebar-ag/laravel-zammad

Zammad integration with Laravel

106.1k](/packages/codebar-ag-laravel-zammad)

PHPackages © 2026

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