Documentation
¶
Index ¶
- Variables
- func FetchExerciseCatalog(ctx context.Context) (json.RawMessage, error)
- type AuthRequiredError
- type CircuitBreaker
- type Client
- func (c *Client) AddBloodPressure(ctx context.Context, systolic, diastolic, pulse int, ...) (json.RawMessage, error)
- func (c *Client) AddEvent(ctx context.Context, payload json.RawMessage) (json.RawMessage, error)
- func (c *Client) AddHydration(ctx context.Context, date string, amountML float64) (json.RawMessage, error)
- func (c *Client) AddWeight(ctx context.Context, weight float64, unitKey string, dateTimestamp string, ...) (json.RawMessage, error)
- func (c *Client) ConnectAPI(ctx context.Context, method, path string, body io.Reader) (json.RawMessage, error)
- func (c *Client) CountActivities(ctx context.Context) (int, error)
- func (c *Client) CreateManualActivity(ctx context.Context, name, activityType, timezone string, ...) (json.RawMessage, error)
- func (c *Client) DeleteActivity(ctx context.Context, activityID string) error
- func (c *Client) DeleteBloodPressure(ctx context.Context, date string, version string) error
- func (c *Client) DeleteCourse(ctx context.Context, courseID string) error
- func (c *Client) DeleteEvent(ctx context.Context, eventID string) error
- func (c *Client) DeleteWeight(ctx context.Context, date string, version string) error
- func (c *Client) DeleteWorkout(ctx context.Context, workoutID string) error
- func (c *Client) Download(ctx context.Context, path string) ([]byte, error)
- func (c *Client) DownloadActivity(ctx context.Context, activityID string, format DownloadFormat) ([]byte, error)
- func (c *Client) DownloadCourse(ctx context.Context, courseID string, format DownloadFormat) ([]byte, error)
- func (c *Client) DownloadWorkout(ctx context.Context, workoutID string) ([]byte, error)
- func (c *Client) GetActivities(ctx context.Context, start, limit int, activityType string) (json.RawMessage, error)
- func (c *Client) GetActivity(ctx context.Context, activityID string) (json.RawMessage, error)
- func (c *Client) GetActivityDetails(ctx context.Context, activityID string, maxChart, maxPoly int) (json.RawMessage, error)
- func (c *Client) GetActivityExerciseSets(ctx context.Context, activityID string) (json.RawMessage, error)
- func (c *Client) GetActivityGear(ctx context.Context, activityID string) (json.RawMessage, error)
- func (c *Client) GetActivityHRZones(ctx context.Context, activityID string) (json.RawMessage, error)
- func (c *Client) GetActivityPowerZones(ctx context.Context, activityID string) (json.RawMessage, error)
- func (c *Client) GetActivitySplitSummaries(ctx context.Context, activityID string) (json.RawMessage, error)
- func (c *Client) GetActivitySplits(ctx context.Context, activityID string) (json.RawMessage, error)
- func (c *Client) GetActivityTypedSplits(ctx context.Context, activityID string) (json.RawMessage, error)
- func (c *Client) GetActivityTypes(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetActivityWeather(ctx context.Context, activityID string) (json.RawMessage, error)
- func (c *Client) GetAllDayEvents(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetBadgeChallenges(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetBadgesAvailable(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetBadgesEarned(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetBadgesInProgress(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetBloodPressure(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
- func (c *Client) GetBodyBattery(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
- func (c *Client) GetBodyComposition(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
- func (c *Client) GetCalendarWeek(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetChallenges(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetCourse(ctx context.Context, courseID string) (json.RawMessage, error)
- func (c *Client) GetCourseElevation(ctx context.Context, points json.RawMessage) (json.RawMessage, error)
- func (c *Client) GetCourseFavorites(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetCourses(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetCyclingFTP(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetDailySteps(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
- func (c *Client) GetDailySummary(ctx context.Context, displayName, date string) (json.RawMessage, error)
- func (c *Client) GetDailyWeighIns(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetDeviceAlarms(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetDeviceSettings(ctx context.Context, deviceID string) (json.RawMessage, error)
- func (c *Client) GetDeviceSolar(ctx context.Context, deviceID, startDate, endDate string) (json.RawMessage, error)
- func (c *Client) GetDevices(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetDisplayName(ctx context.Context) (string, error)
- func (c *Client) GetEnduranceScore(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetEvents(ctx context.Context, startDate string, pageIndex, limit int, sortOrder string) (json.RawMessage, error)
- func (c *Client) GetFitnessAge(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetFloors(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetGear(ctx context.Context, userProfilePK string) (json.RawMessage, error)
- func (c *Client) GetGearActivities(ctx context.Context, gearUUID string, limit int) (json.RawMessage, error)
- func (c *Client) GetGearDefaults(ctx context.Context, userProfileNumber string) (json.RawMessage, error)
- func (c *Client) GetGearStats(ctx context.Context, gearUUID string) (json.RawMessage, error)
- func (c *Client) GetGoals(ctx context.Context, status string) (json.RawMessage, error)
- func (c *Client) GetHRV(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetHeartRate(ctx context.Context, displayName, date string) (json.RawMessage, error)
- func (c *Client) GetHillScore(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetHydration(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetIntensityMinutes(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetLactateThreshold(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetLastUsedDevice(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetLifestyleLogging(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetMaxMetrics(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetMenstrualCycleData(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
- func (c *Client) GetMenstrualCycleSummary(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
- func (c *Client) GetNutritionDailyFoodLog(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetNutritionDailyMeals(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetNutritionDailySettings(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetPersonalRecords(ctx context.Context, ownerDisplayName string) (json.RawMessage, error)
- func (c *Client) GetPregnancySummary(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetPrimaryTrainingDevice(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetProfile(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetRacePredictions(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
- func (c *Client) GetRespiration(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetRestingHeartRate(ctx context.Context, displayName, date string) (json.RawMessage, error)
- func (c *Client) GetSPO2(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetSleep(ctx context.Context, displayName, date string) (json.RawMessage, error)
- func (c *Client) GetSocialProfile(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetSteps(ctx context.Context, displayName, date string) (json.RawMessage, error)
- func (c *Client) GetStress(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetTrainingPlan(ctx context.Context, planID string) (json.RawMessage, error)
- func (c *Client) GetTrainingPlans(ctx context.Context, locale string) (json.RawMessage, error)
- func (c *Client) GetTrainingReadiness(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetTrainingStatus(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) GetUserSettings(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetWeeklyIntensityMinutes(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
- func (c *Client) GetWeeklySteps(ctx context.Context, endDate string, weeks int) (json.RawMessage, error)
- func (c *Client) GetWeeklyStress(ctx context.Context, endDate string, weeks int) (json.RawMessage, error)
- func (c *Client) GetWeighIns(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
- func (c *Client) GetWorkout(ctx context.Context, workoutID string) (json.RawMessage, error)
- func (c *Client) GetWorkouts(ctx context.Context, start, limit int) (json.RawMessage, error)
- func (c *Client) ImportCourseGPX(ctx context.Context, filePath string) (json.RawMessage, error)
- func (c *Client) LinkGear(ctx context.Context, gearUUID, activityID string) (json.RawMessage, error)
- func (c *Client) RenameActivity(ctx context.Context, activityID string, name string) (json.RawMessage, error)
- func (c *Client) RequestReload(ctx context.Context, date string) (json.RawMessage, error)
- func (c *Client) RetypeActivity(ctx context.Context, activityID string, typeID int, typeKey string, ...) (json.RawMessage, error)
- func (c *Client) SaveCourse(ctx context.Context, course json.RawMessage) (json.RawMessage, error)
- func (c *Client) ScheduleWorkout(ctx context.Context, workoutID, date string) (json.RawMessage, error)
- func (c *Client) SearchActivities(ctx context.Context, start, limit int, startDate, endDate string) (json.RawMessage, error)
- func (c *Client) SendCourseToDevice(ctx context.Context, courseID, deviceID, courseName string) (json.RawMessage, error)
- func (c *Client) SetExerciseSets(ctx context.Context, activityID string, payload json.RawMessage) error
- func (c *Client) Tokens() *garminauth.Tokens
- func (c *Client) UnlinkGear(ctx context.Context, gearUUID, activityID string) (json.RawMessage, error)
- func (c *Client) UnscheduleWorkout(ctx context.Context, scheduleID string) error
- func (c *Client) UploadActivity(ctx context.Context, filePath string) (json.RawMessage, error)
- func (c *Client) UploadBodyComposition(ctx context.Context, fitData []byte) (json.RawMessage, error)
- func (c *Client) UploadWorkout(ctx context.Context, workoutJSON json.RawMessage) (json.RawMessage, error)
- type ClientOption
- type DownloadFormat
- type GarminAPIError
- type InvalidFileFormatError
- type RateLimitError
- type RetryTransport
- type TokenExpiredError
Constants ¶
This section is empty.
Variables ¶
var ErrCircuitOpen = errors.New("circuit breaker is open")
ErrCircuitOpen is returned when the circuit breaker is open and not accepting requests.
Functions ¶
func FetchExerciseCatalog ¶ added in v1.4.0
func FetchExerciseCatalog(ctx context.Context) (json.RawMessage, error)
FetchExerciseCatalog fetches the public Garmin exercise catalog. This does not require authentication.
Types ¶
type AuthRequiredError ¶
type AuthRequiredError struct {
Email string
}
AuthRequiredError indicates no authentication credentials were found.
func (*AuthRequiredError) Error ¶
func (e *AuthRequiredError) Error() string
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
CircuitBreaker implements a simple circuit breaker pattern. It tracks consecutive failures and opens the circuit when a threshold is reached, preventing further requests until a reset timeout elapses.
func NewCircuitBreaker ¶
func NewCircuitBreaker(threshold int, resetTimeout time.Duration) *CircuitBreaker
NewCircuitBreaker creates a circuit breaker with the given threshold and reset timeout. Default: threshold=5, resetTimeout=30s.
func (*CircuitBreaker) Allow ¶
func (cb *CircuitBreaker) Allow() error
Allow checks if a request is permitted. Returns an error if the circuit is open. If the circuit is half-open, it allows one probe request.
func (*CircuitBreaker) Failures ¶
func (cb *CircuitBreaker) Failures() int
Failures returns the current consecutive failure count.
func (*CircuitBreaker) RecordFailure ¶
func (cb *CircuitBreaker) RecordFailure()
RecordFailure records a failed request. If the failure threshold is reached, the circuit opens.
func (*CircuitBreaker) RecordSuccess ¶
func (cb *CircuitBreaker) RecordSuccess()
RecordSuccess records a successful request, resetting the failure count and closing the circuit if it was half-open.
func (*CircuitBreaker) State ¶
func (cb *CircuitBreaker) State() string
State returns the current circuit breaker state as a string (for diagnostics).
type Client ¶
type Client struct {
// OnTokenRefresh is called after a successful OAuth2 token refresh.
// Use this to persist refreshed tokens back to storage.
// If nil, no action is taken (tokens are only updated in-memory).
OnTokenRefresh func(tokens *garminauth.Tokens)
// contains filtered or unexported fields
}
Client interacts with the Garmin Connect API.
func NewClient ¶
func NewClient(tokens *garminauth.Tokens, opts ...ClientOption) *Client
NewClient creates a new Garmin Connect API client.
func (*Client) AddBloodPressure ¶
func (c *Client) AddBloodPressure(ctx context.Context, systolic, diastolic, pulse int, timestampLocal, timestampGMT, notes string) (json.RawMessage, error)
AddBloodPressure adds a blood pressure measurement.
func (*Client) AddEvent ¶ added in v1.2.0
func (c *Client) AddEvent(ctx context.Context, payload json.RawMessage) (json.RawMessage, error)
AddEvent creates a new calendar event.
func (*Client) AddHydration ¶
func (c *Client) AddHydration(ctx context.Context, date string, amountML float64) (json.RawMessage, error)
AddHydration adds a hydration log entry for the given date. Amount is in milliliters.
func (*Client) AddWeight ¶
func (c *Client) AddWeight(ctx context.Context, weight float64, unitKey string, dateTimestamp string, gmtTimestamp string) (json.RawMessage, error)
AddWeight adds a weigh-in entry.
func (*Client) ConnectAPI ¶
func (c *Client) ConnectAPI(ctx context.Context, method, path string, body io.Reader) (json.RawMessage, error)
ConnectAPI makes a JSON API request to the Garmin Connect API. The response body is returned as a json.RawMessage. For 204 No Content responses (common for delete operations), nil is returned.
func (*Client) CountActivities ¶
CountActivities returns the total number of activities for the authenticated user.
func (*Client) CreateManualActivity ¶
func (c *Client) CreateManualActivity(ctx context.Context, name, activityType, timezone string, distanceMeters float64, durationSeconds float64, startTime string) (json.RawMessage, error)
CreateManualActivity creates a manual activity entry.
func (*Client) DeleteActivity ¶
DeleteActivity deletes an activity by ID.
func (*Client) DeleteBloodPressure ¶
DeleteBloodPressure deletes a blood pressure entry by date and version. Date format: YYYY-MM-DD.
func (*Client) DeleteCourse ¶ added in v1.1.0
DeleteCourse deletes a course by ID.
func (*Client) DeleteEvent ¶ added in v1.2.0
DeleteEvent deletes a calendar event by ID.
func (*Client) DeleteWeight ¶
DeleteWeight deletes a weigh-in entry by date and version (primary key). Date format: YYYY-MM-DD.
func (*Client) DeleteWorkout ¶
DeleteWorkout deletes a workout by ID.
func (*Client) DownloadActivity ¶
func (c *Client) DownloadActivity(ctx context.Context, activityID string, format DownloadFormat) ([]byte, error)
DownloadActivity downloads an activity in the specified format.
func (*Client) DownloadCourse ¶ added in v1.9.0
func (c *Client) DownloadCourse(ctx context.Context, courseID string, format DownloadFormat) ([]byte, error)
DownloadCourse downloads a course in the specified format.
func (*Client) DownloadWorkout ¶
DownloadWorkout downloads a workout as a FIT file.
func (*Client) GetActivities ¶
func (c *Client) GetActivities(ctx context.Context, start, limit int, activityType string) (json.RawMessage, error)
GetActivities returns a page of activities.
func (*Client) GetActivity ¶
GetActivity returns a single activity by ID.
func (*Client) GetActivityDetails ¶
func (c *Client) GetActivityDetails(ctx context.Context, activityID string, maxChart, maxPoly int) (json.RawMessage, error)
GetActivityDetails returns detailed activity data including charts and polylines.
func (*Client) GetActivityExerciseSets ¶
func (c *Client) GetActivityExerciseSets(ctx context.Context, activityID string) (json.RawMessage, error)
GetActivityExerciseSets returns exercise set data for strength training activities.
func (*Client) GetActivityGear ¶
GetActivityGear returns gear linked to an activity.
func (*Client) GetActivityHRZones ¶
func (c *Client) GetActivityHRZones(ctx context.Context, activityID string) (json.RawMessage, error)
GetActivityHRZones returns heart rate time-in-zone data for an activity.
func (*Client) GetActivityPowerZones ¶
func (c *Client) GetActivityPowerZones(ctx context.Context, activityID string) (json.RawMessage, error)
GetActivityPowerZones returns power time-in-zone data for an activity.
func (*Client) GetActivitySplitSummaries ¶
func (c *Client) GetActivitySplitSummaries(ctx context.Context, activityID string) (json.RawMessage, error)
GetActivitySplitSummaries returns the split summaries for an activity.
func (*Client) GetActivitySplits ¶
GetActivitySplits returns the splits for an activity.
func (*Client) GetActivityTypedSplits ¶
func (c *Client) GetActivityTypedSplits(ctx context.Context, activityID string) (json.RawMessage, error)
GetActivityTypedSplits returns the typed splits for an activity.
func (*Client) GetActivityTypes ¶ added in v1.8.0
GetActivityTypes returns all activity types from Garmin Connect.
func (*Client) GetActivityWeather ¶
func (c *Client) GetActivityWeather(ctx context.Context, activityID string) (json.RawMessage, error)
GetActivityWeather returns weather data for an activity.
func (*Client) GetAllDayEvents ¶
GetAllDayEvents returns daily wellness events for a given date. Date format: YYYY-MM-DD.
func (*Client) GetBadgeChallenges ¶
GetBadgeChallenges returns badge challenges.
func (*Client) GetBadgesAvailable ¶
GetBadgesAvailable returns all available badges.
func (*Client) GetBadgesEarned ¶
GetBadgesEarned returns all badges earned by the user.
func (*Client) GetBadgesInProgress ¶
GetBadgesInProgress returns badges currently in progress.
func (*Client) GetBloodPressure ¶
func (c *Client) GetBloodPressure(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
GetBloodPressure returns blood pressure data for a date range. Date format: YYYY-MM-DD.
func (*Client) GetBodyBattery ¶
func (c *Client) GetBodyBattery(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
GetBodyBattery returns body battery data for a date range. Date format: YYYY-MM-DD.
func (*Client) GetBodyComposition ¶
func (c *Client) GetBodyComposition(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
GetBodyComposition returns body composition data for a date range. Date format: YYYY-MM-DD.
func (*Client) GetCalendarWeek ¶
GetCalendarWeek returns the calendar data for the week containing the given date. The date must be in YYYY-MM-DD format. The Garmin calendar API uses 0-indexed months.
func (*Client) GetChallenges ¶
GetChallenges returns active challenges the user is participating in.
func (*Client) GetCourseElevation ¶ added in v1.1.0
func (c *Client) GetCourseElevation(ctx context.Context, points json.RawMessage) (json.RawMessage, error)
GetCourseElevation enriches geo points with elevation data.
func (*Client) GetCourseFavorites ¶ added in v1.0.0
GetCourseFavorites returns the user's favorite courses.
func (*Client) GetCourses ¶ added in v1.0.0
GetCourses returns all courses owned by the current user.
func (*Client) GetCyclingFTP ¶
GetCyclingFTP returns the latest cycling functional threshold power.
func (*Client) GetDailySteps ¶
func (c *Client) GetDailySteps(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
GetDailySteps returns daily step data for a date range. Date format: YYYY-MM-DD.
func (*Client) GetDailySummary ¶
func (c *Client) GetDailySummary(ctx context.Context, displayName, date string) (json.RawMessage, error)
GetDailySummary returns the user's daily summary for a given date. Date format: YYYY-MM-DD.
func (*Client) GetDailyWeighIns ¶
GetDailyWeighIns returns weigh-in data for a single day. Date format: YYYY-MM-DD.
func (*Client) GetDeviceAlarms ¶
GetDeviceAlarms returns alarms from all devices by fetching device settings for each registered device.
func (*Client) GetDeviceSettings ¶
GetDeviceSettings returns settings for a specific device.
func (*Client) GetDeviceSolar ¶
func (c *Client) GetDeviceSolar(ctx context.Context, deviceID, startDate, endDate string) (json.RawMessage, error)
GetDeviceSolar returns solar charging data for a compatible device. Date format: YYYY-MM-DD.
func (*Client) GetDevices ¶
GetDevices returns all registered devices for the current user.
func (*Client) GetDisplayName ¶ added in v0.3.0
GetDisplayName returns the authenticated user's display name from profile settings.
func (*Client) GetEnduranceScore ¶
GetEnduranceScore returns endurance score data for a given date. Date format: YYYY-MM-DD.
func (*Client) GetEvents ¶ added in v1.2.0
func (c *Client) GetEvents(ctx context.Context, startDate string, pageIndex, limit int, sortOrder string) (json.RawMessage, error)
GetEvents returns calendar events starting from a date with pagination.
func (*Client) GetFitnessAge ¶
GetFitnessAge returns fitness age data for a given date. Date format: YYYY-MM-DD.
func (*Client) GetFloors ¶
GetFloors returns floors climbed data for a given date. Date format: YYYY-MM-DD.
func (*Client) GetGearActivities ¶
func (c *Client) GetGearActivities(ctx context.Context, gearUUID string, limit int) (json.RawMessage, error)
GetGearActivities returns activities linked to a specific gear item.
func (*Client) GetGearDefaults ¶
func (c *Client) GetGearDefaults(ctx context.Context, userProfileNumber string) (json.RawMessage, error)
GetGearDefaults returns default gear per activity type for a user.
func (*Client) GetGearStats ¶
GetGearStats returns usage statistics for a specific gear item.
func (*Client) GetGoals ¶
GetGoals returns the user's active goals. If status is non-empty, it filters by goal status (e.g. "active", "completed").
func (*Client) GetHRV ¶
GetHRV returns heart rate variability data for a given date. Date format: YYYY-MM-DD.
func (*Client) GetHeartRate ¶
func (c *Client) GetHeartRate(ctx context.Context, displayName, date string) (json.RawMessage, error)
GetHeartRate returns heart rate data for a given date. Date format: YYYY-MM-DD.
func (*Client) GetHillScore ¶
GetHillScore returns hill score data for a given date. Date format: YYYY-MM-DD.
func (*Client) GetHydration ¶
GetHydration returns hydration data for a given date. Date format: YYYY-MM-DD.
func (*Client) GetIntensityMinutes ¶
GetIntensityMinutes returns intensity minutes data for a given date. Date format: YYYY-MM-DD.
func (*Client) GetLactateThreshold ¶
GetLactateThreshold returns the latest lactate threshold data.
func (*Client) GetLastUsedDevice ¶
GetLastUsedDevice returns the most recently used device.
func (*Client) GetLifestyleLogging ¶
GetLifestyleLogging returns lifestyle logging data for a given date. Date format: YYYY-MM-DD.
func (*Client) GetMaxMetrics ¶
GetMaxMetrics returns VO2max and other max metrics for a given date. Date format: YYYY-MM-DD.
func (*Client) GetMenstrualCycleData ¶
func (c *Client) GetMenstrualCycleData(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
GetMenstrualCycleData returns menstrual cycle data for a given date range. Date format: YYYY-MM-DD.
func (*Client) GetMenstrualCycleSummary ¶
func (c *Client) GetMenstrualCycleSummary(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
GetMenstrualCycleSummary returns menstrual cycle summary data for a given date range. Date format: YYYY-MM-DD.
func (*Client) GetNutritionDailyFoodLog ¶ added in v1.6.0
func (c *Client) GetNutritionDailyFoodLog(ctx context.Context, date string) (json.RawMessage, error)
GetNutritionDailyFoodLog returns nutrition food log data for a given date. Date format: YYYY-MM-DD.
func (*Client) GetNutritionDailyMeals ¶ added in v1.6.0
GetNutritionDailyMeals returns nutrition meal summary data for a given date. Date format: YYYY-MM-DD.
func (*Client) GetNutritionDailySettings ¶ added in v1.6.0
func (c *Client) GetNutritionDailySettings(ctx context.Context, date string) (json.RawMessage, error)
GetNutritionDailySettings returns nutrition settings for a given date. Date format: YYYY-MM-DD.
func (*Client) GetPersonalRecords ¶
func (c *Client) GetPersonalRecords(ctx context.Context, ownerDisplayName string) (json.RawMessage, error)
GetPersonalRecords returns the user's personal records for a given owner display name.
func (*Client) GetPregnancySummary ¶
GetPregnancySummary returns pregnancy summary data.
func (*Client) GetPrimaryTrainingDevice ¶
GetPrimaryTrainingDevice returns information about the primary training device.
func (*Client) GetProfile ¶
GetProfile returns the authenticated user's profile settings.
func (*Client) GetRacePredictions ¶
func (c *Client) GetRacePredictions(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
GetRacePredictions returns race prediction data. If startDate and endDate are empty, returns current predictions. Date format: YYYY-MM-DD.
func (*Client) GetRespiration ¶
GetRespiration returns respiration data for a given date. Date format: YYYY-MM-DD.
func (*Client) GetRestingHeartRate ¶
func (c *Client) GetRestingHeartRate(ctx context.Context, displayName, date string) (json.RawMessage, error)
GetRestingHeartRate returns resting heart rate data for a given date. Date format: YYYY-MM-DD.
func (*Client) GetSPO2 ¶
GetSPO2 returns SpO2 (blood oxygen) data for a given date. Date format: YYYY-MM-DD.
func (*Client) GetSocialProfile ¶
GetSocialProfile returns the authenticated user's social profile. It first resolves the display name via profile settings, then fetches the social profile. The response includes profileId needed by other API calls.
func (*Client) GetSteps ¶
GetSteps returns step chart data for a given date. Date format: YYYY-MM-DD.
func (*Client) GetTrainingPlan ¶
GetTrainingPlan returns a specific training plan by ID.
func (*Client) GetTrainingPlans ¶
GetTrainingPlans returns the user's training plans.
func (*Client) GetTrainingReadiness ¶
GetTrainingReadiness returns training readiness data for a given date. Date format: YYYY-MM-DD.
func (*Client) GetTrainingStatus ¶
GetTrainingStatus returns training status data for a given date. Date format: YYYY-MM-DD.
func (*Client) GetUserSettings ¶
GetUserSettings returns the authenticated user's settings.
func (*Client) GetWeeklyIntensityMinutes ¶
func (c *Client) GetWeeklyIntensityMinutes(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
GetWeeklyIntensityMinutes returns weekly intensity minutes data for a date range. Date format: YYYY-MM-DD.
func (*Client) GetWeeklySteps ¶
func (c *Client) GetWeeklySteps(ctx context.Context, endDate string, weeks int) (json.RawMessage, error)
GetWeeklySteps returns weekly step data ending at the given date. Date format: YYYY-MM-DD.
func (*Client) GetWeeklyStress ¶
func (c *Client) GetWeeklyStress(ctx context.Context, endDate string, weeks int) (json.RawMessage, error)
GetWeeklyStress returns weekly stress data ending at the given date. Date format: YYYY-MM-DD.
func (*Client) GetWeighIns ¶
func (c *Client) GetWeighIns(ctx context.Context, startDate, endDate string) (json.RawMessage, error)
GetWeighIns returns weigh-in data for a date range. Date format: YYYY-MM-DD.
func (*Client) GetWorkout ¶
GetWorkout returns a single workout by ID.
func (*Client) GetWorkouts ¶
GetWorkouts returns a page of workouts.
func (*Client) ImportCourseGPX ¶ added in v1.1.0
ImportCourseGPX uploads a GPX file and returns parsed course data.
func (*Client) LinkGear ¶
func (c *Client) LinkGear(ctx context.Context, gearUUID, activityID string) (json.RawMessage, error)
LinkGear links a gear item to an activity.
func (*Client) RenameActivity ¶
func (c *Client) RenameActivity(ctx context.Context, activityID string, name string) (json.RawMessage, error)
RenameActivity updates the name of an activity.
func (*Client) RequestReload ¶
RequestReload requests Garmin to reload data for a given date. Date format: YYYY-MM-DD.
func (*Client) RetypeActivity ¶
func (c *Client) RetypeActivity(ctx context.Context, activityID string, typeID int, typeKey string, parentTypeID int) (json.RawMessage, error)
RetypeActivity changes the activity type.
func (*Client) SaveCourse ¶ added in v1.1.0
func (c *Client) SaveCourse(ctx context.Context, course json.RawMessage) (json.RawMessage, error)
SaveCourse creates a new course from enriched course data. The course payload must include coursePrivacy (1=public, 2=private, 4=group) and rulePK (must not be null, typically 2).
func (*Client) ScheduleWorkout ¶
func (c *Client) ScheduleWorkout(ctx context.Context, workoutID, date string) (json.RawMessage, error)
ScheduleWorkout schedules a workout on a calendar date.
func (*Client) SearchActivities ¶
func (c *Client) SearchActivities(ctx context.Context, start, limit int, startDate, endDate string) (json.RawMessage, error)
SearchActivities returns activities matching date range and optional filters.
func (*Client) SendCourseToDevice ¶ added in v1.0.0
func (c *Client) SendCourseToDevice(ctx context.Context, courseID, deviceID, courseName string) (json.RawMessage, error)
SendCourseToDevice sends a course to a device via the device message API.
func (*Client) SetExerciseSets ¶ added in v1.4.0
func (c *Client) SetExerciseSets(ctx context.Context, activityID string, payload json.RawMessage) error
SetExerciseSets sets exercise sets for a strength training activity.
func (*Client) Tokens ¶
func (c *Client) Tokens() *garminauth.Tokens
Tokens returns the current tokens held by the client.
func (*Client) UnlinkGear ¶
func (c *Client) UnlinkGear(ctx context.Context, gearUUID, activityID string) (json.RawMessage, error)
UnlinkGear unlinks a gear item from an activity.
func (*Client) UnscheduleWorkout ¶
UnscheduleWorkout removes a scheduled workout from the calendar.
func (*Client) UploadActivity ¶
UploadActivity uploads an activity file (FIT, GPX, or TCX).
func (*Client) UploadBodyComposition ¶
func (c *Client) UploadBodyComposition(ctx context.Context, fitData []byte) (json.RawMessage, error)
UploadBodyComposition uploads a FIT-encoded body composition file.
func (*Client) UploadWorkout ¶
func (c *Client) UploadWorkout(ctx context.Context, workoutJSON json.RawMessage) (json.RawMessage, error)
UploadWorkout uploads a workout from JSON data.
type ClientOption ¶
type ClientOption func(*Client)
ClientOption configures a Client.
func WithHTTPClient ¶
func WithHTTPClient(c *http.Client) ClientOption
WithHTTPClient sets a custom HTTP client.
type DownloadFormat ¶ added in v1.9.0
type DownloadFormat string
DownloadFormat represents a supported export format.
const ( FormatFIT DownloadFormat = "fit" FormatTCX DownloadFormat = "tcx" FormatGPX DownloadFormat = "gpx" FormatKML DownloadFormat = "kml" FormatCSV DownloadFormat = "csv" )
type GarminAPIError ¶
GarminAPIError represents a non-2xx error response from the Garmin Connect API.
func (*GarminAPIError) Error ¶
func (e *GarminAPIError) Error() string
type InvalidFileFormatError ¶
type InvalidFileFormatError struct {
Format string
}
InvalidFileFormatError indicates an unsupported file format was requested.
func (*InvalidFileFormatError) Error ¶
func (e *InvalidFileFormatError) Error() string
type RateLimitError ¶
type RateLimitError struct {
RetryAfter string
}
RateLimitError indicates the API returned a 429 Too Many Requests response.
func (*RateLimitError) Error ¶
func (e *RateLimitError) Error() string
type RetryTransport ¶
type RetryTransport struct {
// Base is the underlying RoundTripper. If nil, http.DefaultTransport is used.
Base http.RoundTripper
// MaxRetries429 is the maximum number of retries for 429 responses. Default: 3.
MaxRetries429 int
// MaxRetries5xx is the maximum number of retries for 5xx responses. Default: 2.
MaxRetries5xx int
// contains filtered or unexported fields
}
RetryTransport wraps an http.RoundTripper and retries requests on 429 (Too Many Requests) and 5xx responses with backoff.
func NewRetryTransport ¶
func NewRetryTransport(base http.RoundTripper) *RetryTransport
NewRetryTransport creates a RetryTransport with sensible defaults.
type TokenExpiredError ¶
type TokenExpiredError struct {
Email string
}
TokenExpiredError indicates the stored token has expired and could not be refreshed.
func (*TokenExpiredError) Error ¶
func (e *TokenExpiredError) Error() string