garmin-api-handler
v7.1.0
Published
Unofficial handler for Garmin connect API
Downloads
118
Readme
Garmin API handler
This is an unofficial handler for Garmin Connect API. The documentation is bad :)
How to download fit files, example:
const fs = require('fs');
const path = require('path');
const { GarminApi } = require('../dist');
const { DateTime } = require('luxon');
require('cross-fetch/polyfill');
const extract = require('extract-zip')
const api = new GarminApi();
(async () => {
await api.login(LOGIN, PASSWORD);
const activities = await api.getActivities({limit: 1000, startDate: DateTime.fromJSDate(new Date('2020-01-01')).startOf('day'), endDate: DateTime.fromJSDate(new Date('2020-12-31')).endOf('day')});
await Promise.all(activities.map(async (activity) => {
const data = await api.getActivityFile(activity.getId());
const fileName = `files/${activity.getId()}.fit.zip`;
fs.writeFileSync(fileName, Buffer.from(await data.arrayBuffer()));
await extract(path.resolve(__dirname, '..', fileName), { dir: path.resolve(__dirname, '..', 'files') })
fs.rmSync(fileName);
}));
})()