PHPackages                             sportlog/garmin-connect - 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. sportlog/garmin-connect

ActiveLibrary[API Development](/categories/api)

sportlog/garmin-connect
=======================

Authenticate to Garmin Connect and query data.

v0.9.2(4mo ago)0117MITPHPPHP &gt;=8.2CI passing

Since Nov 22Pushed 4mo agoCompare

[ Source](https://github.com/sportlog/garmin-connect)[ Packagist](https://packagist.org/packages/sportlog/garmin-connect)[ RSS](/packages/sportlog-garmin-connect/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (3)Versions (3)Used By (0)

Garmin-connect
==============

[](#garmin-connect)

A PHP (&gt;= PHP 8.2 with OAuth PECL) library to connect to the Garmin API. This is a port of [garth](https://github.com/matin/garth/).

Install via Composer
--------------------

[](#install-via-composer)

You can install sportlog/garmin-connect using Composer.

```
$ composer require sportlog/garmin-connect
```

Main functions
--------------

[](#main-functions)

### GarminConnect

[](#garminconnect)

- GarminConnect::login(...): Login to garmin connect API. If MFA is enabled, you need a subsequent call to GarminConnect::resumeLogin(...).
- GarminConnect::resumeLogin(...): In case MFA is enabled, you must resume login by providing the received MFA-code.
- GarminConnect::connectApi(...): Try to connect with previously fetched token. This refreshes an invalid token, if possible. If false is returned, a call to GarminConnect::login(...) is required. This function is a convenient function to not require passing the password all the time in case a valid token exists.

### GarminConnectApi

[](#garminconnectapi)

- GarminConnectApi::runQuery(...): Run query against Garmin connect Api. You can use the factories for getting predefined queries or pass a custom query.

The tokens are saved to the filesystem in folder "./storage" of the current directory. However you can provide your own implementation of TokenStorageInterface, if you want to save the tokens to database, for instance.

How to use
----------

[](#how-to-use)

```
