Gathering detailed insights and metrics for @gooin/garmin-connect
Gathering detailed insights and metrics for @gooin/garmin-connect
Gathering detailed insights and metrics for @gooin/garmin-connect
Gathering detailed insights and metrics for @gooin/garmin-connect
Makes it simple to interface with Garmin Connect to get or set any data point.
npm install @gooin/garmin-connect
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
157 Stars
161 Commits
68 Forks
10 Watchers
2 Branches
13 Contributors
Updated on Jun 04, 2025
Latest Version
1.6.12
Package Id
@gooin/garmin-connect@1.6.12
Unpacked Size
151.58 kB
Size
36.08 kB
File Count
58
NPM Version
10.9.0
Node Version
22.11.0
Published on
Dec 19, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
TODO:
garmin.cn
and garmin.com
If something is not working, please check https://connect.garmin.com/status/ first.
Currently, most of previous features are working, but some of Rest API are not added, such as Gear
,Workout
,Badge
etc. So if you need these features, please add a PR.
All of above work inspired by https://github.com/matin/garth. Many thanks.
A powerful JavaScript library for connecting to Garmin Connect for sending and receiving health and workout data. It comes with some predefined methods to get and set different kinds of data for your Garmin account, but also have the possibility to make custom requests GET
, POST
and PUT
are currently supported. This makes it easy to implement whatever may be missing to suite your needs.
This library will require you to add a configuration file to your project root called garmin.config.json
containing your username and password for the Garmin Connect service.
1{ 2 "username": "my.email@example.com", 3 "password": "MySecretPassword" 4}
1$ npm install garmin-connect
1const { GarminConnect } = require('garmin-connect');
2// Create a new Garmin Connect Client
3const GCClient = new GarminConnect({
4 username: 'my.email@example.com',
5 password: 'MySecretPassword'
6});
7// Uses credentials from garmin.config.json or uses supplied params
8await GCClient.login();
9const userProfile = await GCClient.getUserProfile();
Now you can check userProfile.userName
to verify that your login was successful.
1GCClient.saveTokenToFile('/path/to/save/tokens');
Result:
1$ ls /path/to/save/tokens 2oauth1_token.json oauth2_token.json
Reuse token:
1GCClient.loadTokenByFile('/path/to/save/tokens');
1const oauth1 = GCClient.client.oauth1Token; 2const oauth2 = GCClient.client.oauth2Token; 3// save to db or other storage 4...
Reuse token:
1GCClient.loadToken(oauth1, oauth2);
This is an experimental feature and might not yet provide full stability.
After a successful login the sessionJson
getter and setter can be used to export and restore your session.
1// Exporting the session
2const session = GCClient.sessionJson;
3
4// Use this instead of GCClient.login() to restore the session
5// This will throw an error if the stored session cannot be reused
6GCClient.restore(session);
The exported session should be serializable and can be stored as a JSON string.
A stored session can only be reused once and will need to be stored after each request. This can be done by attaching some storage to the sessionChange
event.
1GCClient.onSessionChange((session) => {
2 /*
3 Your choice of storage here
4 node-persist will probably work in most cases
5 */
6});
To make sure to use a stored session if possible, but fallback to regular login, one can use the restoreOrLogin
method.
The arguments username
and password
are both optional and the regular .login()
will be
called if session restore fails.
1await GCClient.restoreOrLogin(session, username, password);
sessionChange
will trigger on a change in the current sessionJson
To attach a listener to an event, use the .on()
method.
1GCClient.on('sessionChange', (session) => console.log(session));
There's currently no way of removing listeners.
Receive basic user information
1GCClient.getUserInfo();
Receive social user information
1GCClient.getSocialProfile();
Get a list of all social connections
1GCClient.getSocialConnections();
Get a list of all registered devices including model numbers and firmware versions.
1GCClient.getDeviceInfo();
getActivities(start: number, limit: number, activityType?: ActivityType, subActivityType?: ActivitySubType): Promise<IActivity[]>
Retrieves a list of activities based on specified parameters.
start
(number, optonal): Index to start fetching activities.limit
(number, optonal): Number of activities to retrieve.activityType
(ActivityType, optional): Type of activity (if specified, start must be null).subActivityType
(ActivitySubType, optional): Subtype of activity (if specified, start must be null).Promise<IActivity[]>
: A Promise that resolves to an array of activities.1const activities = await GCClient.getActivities( 2 0, 3 10, 4 ActivityType.Running, 5 ActivitySubType.Outdoor 6);
getActivity(activity: { activityId: GCActivityId }): Promise<IActivity>
Retrieves details for a specific activity based on the provided activityId
.
activity
(object): An object containing the activityId
property.
activityId
(GCActivityId): Identifier for the desired activity.Promise<IActivity>
: A Promise that resolves to the details of the specified activity.1const activityDetails = await GCClient.getActivity({
2 activityId: 'exampleActivityId'
3});
To get a list of activities in your news feed, use the getNewsFeed
method. This function takes two arguments, start and limit, which is used for pagination. Both are optional and will default to whatever Garmin Connect is using. To be sure to get all activities, use this correctly.
1// Get the news feed with a default length with most recent activities
2GCClient.getNewsFeed();
3// Get activities in feed, 10 through 15. (start 10, limit 5)
4GCClient.getNewsFeed(10, 5);
Use the activityId to download the original activity data. Usually this is supplied as a .zip file.
1const [activity] = await GCClient.getActivities(0, 1);
2// Directory path is optional and defaults to the current working directory.
3// Downloads filename will be supplied by Garmin.
4GCClient.downloadOriginalActivityData(activity, './some/path/that/exists');
Uploads an activity file as a new Activity. The file can be a gpx
, tcx
, or fit
file. If the activity already exists, the result will have a status code of 409.
Upload fixed in 1.4.4, Garmin changed the upload api, the response detailedImportResult
doesn't contain the new activityId.
1const upload = await GCClient.uploadActivity('./some/path/to/file.fit'); 2// not working 3const activityId = upload.detailedImportResult.successes[0].internalId; 4const uploadId = upload.detailedImportResult.uploadId;
Uploads an image to activity
1const [latestActivty] = await GCClient.getActivities(0, 1);
2
3const upload = await GCClient.uploadImage(
4 latestActivty,
5 './some/path/to/file.jpg'
6);
Delete an image from activity
1const [activity] = await GCClient.getActivities(0, 1);
2const activityDetails = await GCClient.getActivityDetails(activity.activityId);
3
4await GCClient.deleteImage(
5 activity,
6 activityDetails.metadataDTO.activityImages[0].imageId
7);
getSteps(date?: Date): Promise<number>
Retrieves the total steps for a given date.
date
(Date, optional): Date of the steps information requested; defaults to today if no date is supplied.Promise<number>
: A Promise that resolves to the total steps for the specified date.1const totalSteps = await GCClient.getSteps(new Date('2020-03-24'));
getSleepData(date: string): Promise<SleepData>
Retrieves all sleep data for a given date
date
(Date, optional): Date of information requested, this will default to today if no date is suppliedPromise<SleepData>
: A Promise that resolves to an object containing detailed sleep information.
dailySleepDTO
(object): Information about the user's daily sleep.
id
(number): The unique identifier of the sleep record.userProfilePK
(number): The user's profile identifier.calendarDate
(string): The date of the sleep record.sleepMovement
(array): An array of sleep movement data.remSleepData
(boolean): Indicates whether REM sleep data is available.sleepLevels
(array): An array of sleep levels data.restlessMomentsCount
(number): Count of restless moments during sleep.1const detailedSleep = await GCClient.getSleepDuration(new Date('2020-03-24'));
getSleepDuration(date: string): Promise<{hours: number, minutes: number}
Retrieves hours and minutes slept for a given date
date
(Date, optional): Date of information requested, this will default to today if no date is suppliedPromise<{hours: string, minutes: string }>
: A Promise that resolves to an object containing information about the sleep duration
hours
(string): Number of hoursminutes
(string): Number of minutes1const detailedSleep = await GCClient.getSleepDuration(new Date('2020-03-24'));
getDailyWeightData(date?: Date): Promise<number>
Retrieves the daily weight and converts it from grams to pounds.
date
(Date, optional): Date of information requested. Defaults to the current date.Promise<number>
: A Promise that resolves to the daily weight converted from grams to pounds.Error
: If valid daily weight data cannot be found for the specified date.1const weightData = await GCClient.getDailyWeightData(new Date('2023-12-25'));
getDailyWeightInPounds(date?: Date): Promise<number>
Retrieves the daily weight in pounds for a given date.
date
(Date, optional): Date of information requested; defaults to today if no date is supplied.Promise<number>
: A Promise that resolves to the daily weight in pounds.1const weightInPounds = await GCClient.getDailyWeightInPounds( 2 new Date('2020-03-24') 3);
getDailyHydration(date?: Date): Promise<number>
Retrieves the daily hydration data and converts it from milliliters to ounces.
date
(Date, optional): Date of the requested information. Defaults to the current date.Promise<number>
: A Promise that resolves to the daily hydration data converted from milliliters to ounces.Error
: If valid daily hydration data cannot be found for the specified date or if the response is invalid.1const hydrationInOunces = await GCClient.getDailyHydration( 2 new Date('2023-12-25') 3);
getGolfSummary(): Promise<GolfSummary>
Retrieves a summary of golf scorecard data.
Promise<GolfSummary>
: A Promise that resolves to the golf scorecard summary.1const golfSummary = await GCClient.getGolfSummary();
getGolfScorecard(scorecardId: number): Promise<GolfScorecard>
Retrieves golf scorecard data for a specific scorecard.
scorecardId
(number): Identifier for the desired golf scorecard.Promise<GolfScorecard>
: A Promise that resolves to the golf scorecard data.1const scorecardId = 123; // Replace with the desired scorecard ID 2const golfScorecard = await GCClient.getGolfScorecard(scorecardId);
getHeartRate(date?: Date): Promise<HeartRate>
Retrieves daily heart rate data for a given date.
date
(Date, optional): Date of the heart rate data requested; defaults to today if no date is supplied.Promise<HeartRate>
: A Promise that resolves to the daily heart rate data.1const heartRateData = await GCClient.getHeartRate(new Date('2020-03-24'));
1const activities = await GCClient.getActivities(0, 1); 2const activity = activities[0]; 3activity['activityName'] = 'The Updated Name'; 4await GCClient.updateActivity(activity);
Deletes an activty.
1const activities = await GCClient.getActivities(0, 1); 2const activity = activities[0]; 3await GCClient.deleteActivity(activity);
updateHydrationLogOunces(date?: Date, valueInOz: number): Promise<WaterIntake>
Adds a hydration log entry in ounces for a given date.
date
(Date, optional): Date of the log entry; defaults to today if no date is supplied.valueInOz
(number): Amount of water intake in ounces. Accepts negative number.Promise<WaterIntake>
: A Promise that resolves to the hydration log entry.1const hydrationLogEntry = await GCClient.addHydrationLogOunces( 2 new Date('2020-03-24'), 3 16 4);
updateWeight(date = new Date(), lbs: number, timezone: string): Promise<UpdateWeight>
Updates weight information
date
(optional): Date object representing the weight entry date. Defaults to the current date if not provided.lbs
(number): Weight value in pounds.timezone
(string): String representing the timezone for the weight entry.Promise<UpdateWeight>
: A Promise that resolves to the result of the weight update.1await GCClient.updateWeight(undefined, 202.9, 'America/Los_Angeles');
To add a custom workout, use the addWorkout
or more specifically addRunningWorkout
.
1GCClient.addRunningWorkout('My 5k run', 5000, 'Some description');
Will add a running workout of 5km called 'My 5k run' and return a JSON object representing the saved workout.
To add a workout to your calendar, first find your workout and then add it to a specific date.
1const workouts = await GCClient.getWorkouts();
2const id = workouts[0].workoutId;
3GCClient.scheduleWorkout({ workoutId: id }, new Date('2020-03-24'));
This will add the workout to a specific date in your calendar and make it show up automatically if you're using any of the Garmin watches.
Deleting a workout is very similar to scheduling one.
1const workouts = await GCClient.getWorkouts();
2const id = workouts[0].workoutId;
3GCClient.deleteWorkout({ workoutId: id });
This library will handle custom requests to your active Garmin Connect session. There are a lot of different url's that is used, which means that this library probably wont cover them all. By using the network analyze tool you can find url's that are used by Garmin Connect to fetch data.
Let's assume I found a GET
requests to the following url:
https://connect.garmin.com/modern/proxy/wellness-service/wellness/dailyHeartRate/22f5f84c-de9d-4ad6-97f2-201097b3b983?date=2020-03-24
The request can be sent using GCClient
by running
1// You can get your displayName by using the getUserInfo method; 2const displayName = '22f5f84c-de9d-4ad6-97f2-201097b3b983'; 3const url = 4 'https://connect.garmin.com/modern/proxy/wellness-service/wellness/dailyHeartRate/'; 5const dateString = '2020-03-24'; 6GCClient.get(url + displayName, { date: dateString });
and will net you the same result as using the provided way
1GCClient.getHeartRate();
Notice how the client will keep track of the url's, your user information as well as keeping the session alive.
Many responses from Garmin Connect are missing type definitions and defaults to unknown
. Feel free to add types by opening a pull request.
For now, this library only supports the following:
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
7 existing vulnerabilities detected
Details
Reason
Found 2/9 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More