Gathering detailed insights and metrics for @gooin/garmin-connect-cn
Gathering detailed insights and metrics for @gooin/garmin-connect-cn
Gathering detailed insights and metrics for @gooin/garmin-connect-cn
Gathering detailed insights and metrics for @gooin/garmin-connect-cn
Makes it simple to interface with Garmin Connect to get or set any data point.
npm install @gooin/garmin-connect-cn
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.5.1
Package Id
@gooin/garmin-connect-cn@1.5.1
Unpacked Size
100.82 kB
Size
23.04 kB
File Count
28
NPM Version
8.19.2
Node Version
16.18.0
Published on
Sep 21, 2023
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
based on garmin-connect
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 @gooin/garmin-connect-cn
1const { GarminConnect } = require('@gooin/garmin-connect-cn');
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 userInfo = await GCClient.getUserInfo();
Now you can check userInfo.emailAddress
to verify that your login was successful.
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();
To get a list of recent activities, use the getActivities
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 a list of default length with most recent activities
2GCClient.getActivities();
3// Get activities 10 through 15. (start 10, limit 5)
4GCClient.getActivities(10, 5);
Use the activityId to get activity details.
1// search for the activity (optional)
2const [activity] = await GCClient.getActivities(0, 1);
3// get the activity details
4const activityDetails = await GCClient.getActivityDetails(activity.activityId);
Use the activityId to get metrics details about that specific activity.
1const activities = await GCClient.getActivities(0, 1);
2const id = activities[0].activityId;
3// Use the id as a parameter
4GCClient.getActivity({ activityId: id });
5// Or the whole activity response
6GCClient.getActivity(activities[0]);
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);
Get timestamp and number of steps taken for a specific date.
1// This will default to today if no date is supplied 2const steps = await GCClient.getSteps(new Date('2020-03-24'));
Get heart rate for a specific date.
1// This will default to today if no date is supplied 2const heartRate = await GCClient.getHeartRate(new Date('2020-03-24'));
Get the summary of how well you've slept for a specific date.
1// This will default to today if no date is supplied 2const sleep = await GCClient.getSleep(new Date('2020-03-24'));
Get the details of your sleep for a specific date.
1// This will default to today if no date is supplied 2const detailedSleep = await GCClient.getSleepData(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);
To add a new weight measurement, use setBodyWeight
. Here you specify your weight in kg.
1GCClient.setBodyWeight(81.4);
Will set your current weight to 81.4kg. The unit used might be tied to your preferred weight settings.
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