fitbit

package module
v1.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 13 Imported by: 1

README

go-fitbit

Fitbit API for Go

The official docs do provide partially different data than provided by the API. This project uses the retuned data of the API as base instead of the official fields defined by the documentation. This fields do use omitempty to not break parsing. Partially some fields were added in the documentation but are still missing in the Swagger file provided by Fitbit.

Please note that you need to register an app on https://dev.fitbit.com/apps/new to receive an API key to use any functionality provided by this project. If you want to use the data only for yourself, you can use "Personal" as OAuth application type. This way the API allows access to intraday data like pulse data in second resolution. Otherwise, use "Server" as application type. You can view your existing apps including your credentials at https://dev.fitbit.com/apps.

This project is provided as-is and should be tested before using in any productive environment. Did I forgot something to implement, found a bug, something changed or recommendations? Please feel free to create an issue or a pull request!

Installation

This project can be used as a dependency of your project.

go get github.com/Thomas2500/go-fitbit

Example

You can find a working example how to use go-fitbit within the folder example/server/ which shows data of most API endpoints, shows how to use subscriptions and how to handle token updates.

Initialisizing a new API session can be done using the fitbit.Config struct. This will return a new API session.

// Create a new fitbit session
fca = fitbit.New(fitbit.Config{
  ClientID:     clientID,
  ClientSecret: clientSecret,
  RedirectURL:  fmt.Sprintf("https://%s/callback", "localhost"),
  Scopes: []string{
    fitbit.ScopeActivity,
    fitbit.ScopeBreathingRate,
    fitbit.ScopeHeartrate,
    fitbit.ScopeLocation,
    fitbit.ScopeNutrition,
    fitbit.ScopeProfile,
    fitbit.ScopeSettings,
    fitbit.ScopeSleep,
    fitbit.ScopeSocial,
    fitbit.ScopeSpO2,
    fitbit.ScopeTemperature,
    fitbit.ScopeWeight,
  },
})

Notes

As of https://dev.fitbit.com/build/reference/web-api/basics/#numerical-ids all IDs should be considered as unsigned int64.

TODO

Some functions arn't tested because I do not have the hardware for it (I'm only using a Fitbit Versa 1 and MobileTrack of the iPhone app). If you have hardware which provides additional data (alarms, temperature, or Fitbit Aria) please test the functionality and let me know if everything works or something needs to be changed.

Functioons explicitly not tested (eventually broken, please test!) or not finished yet:

Further to do:

  • combine similar structs and highlight differences

Findings

  • /1/foods/locales.json returns imageUpload true on en_US, but not with other languages like de_DE. No description how it can be used.
  • Food search does only return PUBLIC records and no custom stored records. I found no way to find my own records or use them.

What I use this API for

I do save the fetched data into MariaDB & InfluxDB databases for further processing and a simple overview in Grafana. My plan for the future is to further process the data and combine it with other sources of data like weather, movie seen, music listened to, public travel vs driving with car, ... The possibilities are endless and I do have currently enough free storage to store everything :-)

Big thanks to Fitbit for providing such great devices and API access to the generated data! Unfortunately, this is not a matter of course in the fitness and health sector, although it should be.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveZoneMinutesDay added in v1.1.0

type ActiveZoneMinutesDay struct {
	ActivitiesActiveZoneMinutes []struct {
		DateTime string `json:"dateTime"`
		Value    struct {
			FatBurnActiveZoneMinutes int `json:"fatBurnActiveZoneMinutes"`
			ActiveZoneMinutes        int `json:"activeZoneMinutes"`
		} `json:"value"`
	} `json:"activities-active-zone-minutes"`
}

ActiveZoneMinutesDay contains the active zone minutes for a given day

type ActiveZoneMinutesIntraday added in v1.1.0

type ActiveZoneMinutesIntraday struct {
	ActivitiesActiveZoneMinutesIntraday []struct {
		DateTime string `json:"dateTime"`
		Minutes  []struct {
			Minute string `json:"minute"`
			Value  struct {
				FatBurnActiveZoneMinutes int `json:"fatBurnActiveZoneMinutes,omitempty"`
				ActiveZoneMinutes        int `json:"activeZoneMinutes"`
			} `json:"value,omitempty"`
		} `json:"minutes"`
	} `json:"activities-active-zone-minutes-intraday"`
}

type ActivitiesFrequent

type ActivitiesFrequent struct {
	ActivityID  int     `json:"activityId"`
	Calories    int     `json:"calories"`
	Description string  `json:"description"`
	Distance    float64 `json:"distance"`
	Duration    int     `json:"duration"`
	Name        string  `json:"name"`
}

ActivitiesFrequent contains an activity from frequent call

type ActivitiesGoal

type ActivitiesGoal struct {
	Goals struct {
		ActiveMinutes int     `json:"activeMinutes,omitempty"`
		CaloriesOut   int     `json:"caloriesOut,omitempty"`
		Distance      float64 `json:"distance"`
		Floors        int     `json:"floors"`
		Steps         int     `json:"steps"`
	} `json:"goals"`
}

ActivitiesGoal contains the activities goal of an user

type ActivitiesHeartIntraday

type ActivitiesHeartIntraday struct {
	Dataset []struct {
		Time  string `json:"time"`
		Value int    `json:"value"`
	} `json:"dataset"`
	DatasetInterval int    `json:"datasetInterval"`
	DatasetType     string `json:"datasetType"`
}

ActivitiesHeartIntraday intraday data

type ActivitiesInterdayLog

type ActivitiesInterdayLog struct {
	ActivitiesCalories          []ActivitiesLogSingleRecord    `json:"activities-calories,omitempty"`
	ActivitiesCaloriesIntraday  ActivitiesIntradaySingleRecord `json:"activities-calories-intraday,omitempty"`
	ActivitiesSteps             []ActivitiesLogSingleRecord    `json:"activities-steps,omitempty"`
	ActivitiesStepsIntraday     ActivitiesIntradaySingleRecord `json:"activities-steps-intraday,omitempty"`
	ActivitiesDistance          []ActivitiesLogSingleRecord    `json:"activities-distance,omitempty"`
	ActivitiesDistanceIntraday  ActivitiesIntradaySingleRecord `json:"activities-distance-intraday,omitempty"`
	ActivitiesFloors            []ActivitiesLogSingleRecord    `json:"activities-floors,omitempty"`
	ActivitiesFloorsIntraday    ActivitiesIntradaySingleRecord `json:"activities-floors-intraday,omitempty"`
	ActivitiesElevation         []ActivitiesLogSingleRecord    `json:"activities-elevation,omitempty"`
	ActivitiesElevationIntraday ActivitiesIntradaySingleRecord `json:"activities-elevation-intraday,omitempty"`
}

ActivitiesInterdayLog contains user activity logs for the given day in intraday accuracy

type ActivitiesIntradaySingleRecord

type ActivitiesIntradaySingleRecord struct {
	Dataset []struct {
		Time  string  `json:"time"`
		Value float64 `json:"value"`
	} `json:"dataset,omitempty"`
	DatasetInterval int    `json:"datasetInterval,omitempty"`
	DatasetType     string `json:"datasetType,omitempty"`
}

ActivitiesIntradaySingleRecord contains a single record of an intraday activity

type ActivitiesLifetime

type ActivitiesLifetime struct {
	Best struct {
		Total struct {
			Distance struct {
				Date  string  `json:"date"`
				Value float64 `json:"value"`
			} `json:"distance"`
			Floors struct {
				Date  string  `json:"date"`
				Value float64 `json:"value"`
			} `json:"floors"`
			Steps struct {
				Date  string `json:"date"`
				Value int64  `json:"value"`
			} `json:"steps"`
		} `json:"total"`
		Tracker struct {
			Distance struct {
				Date  string  `json:"date"`
				Value float64 `json:"value"`
			} `json:"distance"`
			Floors struct {
				Date  string  `json:"date"`
				Value float64 `json:"value"`
			} `json:"floors"`
			Steps struct {
				Date  string `json:"date"`
				Value int64  `json:"value"`
			} `json:"steps"`
		} `json:"tracker"`
	} `json:"best"`
	Lifetime struct {
		Total struct {
			ActiveScore float64 `json:"activeScore"`
			CaloriesOut float64 `json:"caloriesOut"`
			Distance    float64 `json:"distance"`
			Floors      int64   `json:"floors"`
			Steps       int64   `json:"steps"`
		} `json:"total"`
		Tracker struct {
			ActiveScore float64 `json:"activeScore"`
			CaloriesOut float64 `json:"caloriesOut"`
			Distance    float64 `json:"distance"`
			Floors      int64   `json:"floors"`
			Steps       int64   `json:"steps"`
		} `json:"tracker"`
	} `json:"lifetime"`
}

ActivitiesLifetime contains the account lifetime statistics

type ActivitiesLog

type ActivitiesLog struct {
	ActivitiesTrackerSteps                []ActivitiesLogSingleRecord `json:"activities-tracker-steps,omitempty"`
	ActivitiesTrackerCalories             []ActivitiesLogSingleRecord `json:"activities-tracker-calories,omitempty"`
	ActivitiesTrackerDistance             []ActivitiesLogSingleRecord `json:"activities-tracker-distance,omitempty"`
	ActivitiesTrackerFloors               []ActivitiesLogSingleRecord `json:"activities-tracker-floors,omitempty"`
	ActivitiesTrackerElevation            []ActivitiesLogSingleRecord `json:"activities-tracker-elevation,omitempty"`
	ActivitiesTrackerMinutesSedentary     []ActivitiesLogSingleRecord `json:"activities-tracker-minutesSedentary,omitempty"`
	ActivitiesTrackerMinutesLightlyActive []ActivitiesLogSingleRecord `json:"activities-tracker-minutesLightlyActive,omitempty"`
	ActivitiesTrackerMinutesFairlyActive  []ActivitiesLogSingleRecord `json:"activities-tracker-minutesFairlyActive,omitempty"`
	ActivitiesTrackerMinutesVeryActive    []ActivitiesLogSingleRecord `json:"activities-tracker-minutesVeryActive,omitempty"`
	ActivitiesTrackerActivityCalories     []ActivitiesLogSingleRecord `json:"activities-tracker-activityCalories,omitempty"`
}

ActivitiesLog contains user activity logs, only one dataset is used and the other ones are empty

type ActivitiesLogList

type ActivitiesLogList struct {
	Activities []struct {
		ActiveDuration    int `json:"activeDuration"`
		ActiveZoneMinutes struct {
			MinutesInHeartRateZones []struct {
				MinuteMultiplier int    `json:"minuteMultiplier"`
				Minutes          int    `json:"minutes"`
				Order            int    `json:"order"`
				Type             string `json:"type"`
				ZoneName         string `json:"zoneName"`
			} `json:"minutesInHeartRateZones"`
		} `json:"activeZoneMinutes"`
		ActivityLevel []struct {
			Minutes int    `json:"minutes"`
			Name    string `json:"name"`
		} `json:"activityLevel"`
		ActivityName          string    `json:"activityName"`
		ActivityTypeID        int       `json:"activityTypeId"`
		Calories              int       `json:"calories"`
		CaloriesLink          string    `json:"caloriesLink"`
		Distance              float64   `json:"distance"`
		DistanceUnit          string    `json:"distanceUnit"`
		Duration              int       `json:"duration"`
		ElevationGain         float64   `json:"elevationGain"`
		HasActiveZoneMinutes  bool      `json:"hasActiveZoneMinutes"`
		LastModified          time.Time `json:"lastModified"`
		LogID                 int64     `json:"logId"`
		LogType               string    `json:"logType"`
		ManualValuesSpecified struct {
			Calories bool `json:"calories"`
			Distance bool `json:"distance"`
			Steps    bool `json:"steps"`
		} `json:"manualValuesSpecified"`
		OriginalDuration  int       `json:"originalDuration"`
		OriginalStartTime time.Time `json:"originalStartTime"`
		PoolLength        int       `json:"poolLength,omitempty"`
		PoolLengthUnit    string    `json:"poolLengthUnit,omitempty"`
		Source            struct {
			ID              string   `json:"id"`
			Name            string   `json:"name"`
			TrackerFeatures []string `json:"trackerFeatures"`
			Type            string   `json:"type"`
			URL             string   `json:"url"`
		} `json:"source"`
		Speed            float64   `json:"speed"`
		StartTime        time.Time `json:"startTime"`
		SwimLengths      int       `json:"swimLengths,omitempty"`
		AverageHeartRate int       `json:"averageHeartRate,omitempty"`
		DetailsLink      string    `json:"detailsLink,omitempty"`
		HeartRateLink    string    `json:"heartRateLink,omitempty"`
		HeartRateZones   []struct {
			CaloriesOut float64 `json:"caloriesOut"`
			Max         int     `json:"max"`
			Min         int     `json:"min"`
			Minutes     int     `json:"minutes"`
			Name        string  `json:"name"`
		} `json:"heartRateZones,omitempty"`
		Pace    float64 `json:"pace,omitempty"`
		Steps   int     `json:"steps,omitempty"`
		TcxLink string  `json:"tcxLink,omitempty"`
	} `json:"activities"`
	Pagination struct {
		BeforeDate string `json:"beforeDate"`
		Limit      int    `json:"limit"`
		Next       string `json:"next"`
		Offset     int    `json:"offset"`
		Previous   string `json:"previous"`
		Sort       string `json:"sort"`
	} `json:"pagination"`
}

ActivitiesLogList contains the activity log list

type ActivitiesLogSingleRecord

type ActivitiesLogSingleRecord struct {
	DateTime string `json:"dateTime"`
	Value    string `json:"value"`
}

ActivitiesLogSingleRecord contains a single record of an activity

type ActivitiesSummaryDay

type ActivitiesSummaryDay struct {
	Activities []struct {
		ActivityID           int       `json:"activityId"`
		ActivityParentID     int       `json:"activityParentId"`
		ActivityParentName   string    `json:"activityParentName"`
		Calories             int       `json:"calories"`
		Description          string    `json:"description"`
		DetailsLink          string    `json:"detailsLink,omitempty"`
		Distance             float64   `json:"distance"`
		Duration             int       `json:"duration"`
		HasActiveZoneMinutes bool      `json:"hasActiveZoneMinutes"`
		HasStartTime         bool      `json:"hasStartTime"`
		IsFavorite           bool      `json:"isFavorite"`
		LastModified         time.Time `json:"lastModified"`
		LogID                int64     `json:"logId"`
		Name                 string    `json:"name"`
		StartDate            string    `json:"startDate"`
		StartTime            string    `json:"startTime"`
		Steps                int       `json:"steps"`
	} `json:"activities"`
	Goals struct {
		ActiveMinutes int     `json:"activeMinutes"`
		CaloriesOut   int     `json:"caloriesOut"`
		Distance      float64 `json:"distance"`
		Floors        int     `json:"floors"`
		Steps         int     `json:"steps"`
	} `json:"goals"`
	Summary struct {
		ActiveScore            int `json:"activeScore"`
		ActivityCalories       int `json:"activityCalories"`
		CalorieEstimationMu    int `json:"calorieEstimationMu"`
		CaloriesBMR            int `json:"caloriesBMR"`
		CaloriesOut            int `json:"caloriesOut"`
		CaloriesOutUnestimated int `json:"caloriesOutUnestimated"`
		Distances              []struct {
			Activity string  `json:"activity"`
			Distance float64 `json:"distance"`
		} `json:"distances"`
		Elevation           float64 `json:"elevation"`
		FairlyActiveMinutes int     `json:"fairlyActiveMinutes"`
		Floors              int     `json:"floors"`
		HeartRateZones      []struct {
			CaloriesOut float64 `json:"caloriesOut"`
			Max         int     `json:"max"`
			Min         int     `json:"min"`
			Minutes     int     `json:"minutes"`
			Name        string  `json:"name"`
		} `json:"heartRateZones"`
		LightlyActiveMinutes int  `json:"lightlyActiveMinutes"`
		MarginalCalories     int  `json:"marginalCalories"`
		RestingHeartRate     int  `json:"restingHeartRate"`
		SedentaryMinutes     int  `json:"sedentaryMinutes"`
		Steps                int  `json:"steps"`
		UseEstimation        bool `json:"useEstimation"`
		VeryActiveMinutes    int  `json:"veryActiveMinutes"`
	} `json:"summary"`
}

ActivitiesSummaryDay contains a summary of activities of a requested day

type ActivitiesTypes

type ActivitiesTypes struct {
	Categories []struct {
		Activities []struct {
			AccessLevel    string `json:"accessLevel"`
			ActivityLevels []struct {
				ID          int64   `json:"id"`
				MaxSpeedMPH float64 `json:"maxSpeedMPH"`
				Mets        float64 `json:"mets"`
				MinSpeedMPH float64 `json:"minSpeedMPH"`
				Name        string  `json:"name"`
			} `json:"activityLevels,omitempty"`
			HasSpeed bool    `json:"hasSpeed"`
			ID       int     `json:"id"`
			Name     string  `json:"name"`
			Mets     float64 `json:"mets,omitempty"`
		} `json:"activities"`
		ID            int    `json:"id"`
		Name          string `json:"name"`
		SubCategories []struct {
			Activities []struct {
				AccessLevel string  `json:"accessLevel"`
				HasSpeed    bool    `json:"hasSpeed"`
				ID          int64   `json:"id"`
				Mets        float64 `json:"mets"`
				Name        string  `json:"name"`
			} `json:"activities"`
			ID   int64  `json:"id"`
			Name string `json:"name"`
		} `json:"subCategories,omitempty"`
	} `json:"categories"`
}

ActivitiesTypes contains a list of activities

type AddFoodLogResponse

type AddFoodLogResponse struct {
	FoodDay struct {
		Date    string `json:"date"`
		Summary struct {
			Calories int     `json:"calories"`
			Carbs    float64 `json:"carbs"`
			Fat      float64 `json:"fat"`
			Fiber    float64 `json:"fiber"`
			Protein  float64 `json:"protein"`
			Sodium   float64 `json:"sodium"`
			Water    int     `json:"water"`
		} `json:"summary"`
	} `json:"foodDay"`
	FoodLog struct {
		IsFavorite bool   `json:"isFavorite"`
		LogDate    string `json:"logDate"`
		LogID      int64  `json:"logId"`
		LoggedFood struct {
			AccessLevel string `json:"accessLevel"`
			Amount      int    `json:"amount"`
			Brand       string `json:"brand"`
			Calories    int    `json:"calories"`
			FoodID      int    `json:"foodId"`
			Locale      string `json:"locale"`
			MealTypeID  int    `json:"mealTypeId"`
			Name        string `json:"name"`
			Unit        struct {
				ID     int    `json:"id"`
				Name   string `json:"name"`
				Plural string `json:"plural"`
			} `json:"unit"`
			Units []int `json:"units"`
		} `json:"loggedFood"`
		NutritionalValues struct {
			Calories int `json:"calories"`
			Carbs    int `json:"carbs"`
			Fat      int `json:"fat"`
			Fiber    int `json:"fiber"`
			Protein  int `json:"protein"`
			Sodium   int `json:"sodium"`
		} `json:"nutritionalValues"`
	} `json:"foodLog"`
}

AddFoodLogResponse defines the response of AddFood request

type Badge

type Badge struct {
	BadgeGradientEndColor   string        `json:"badgeGradientEndColor"`
	BadgeGradientStartColor string        `json:"badgeGradientStartColor"`
	BadgeType               string        `json:"badgeType"`
	Category                string        `json:"category"`
	Cheers                  []interface{} `json:"cheers"` // FIXME: unknown data
	DateTime                string        `json:"dateTime"`
	Description             string        `json:"description"`
	EarnedMessage           string        `json:"earnedMessage,omitempty"`
	EncodedID               string        `json:"encodedId"`
	Image100Px              string        `json:"image100px"`
	Image125Px              string        `json:"image125px"`
	Image300Px              string        `json:"image300px"`
	Image50Px               string        `json:"image50px"`
	Image75Px               string        `json:"image75px"`
	MarketingDescription    string        `json:"marketingDescription"`
	MobileDescription       string        `json:"mobileDescription"`
	Name                    string        `json:"name"`
	ShareImage640Px         string        `json:"shareImage640px"`
	ShareText               string        `json:"shareText"`
	ShortDescription        string        `json:"shortDescription"`
	ShortName               string        `json:"shortName"`
	TimesAchieved           int           `json:"timesAchieved"`
	Value                   int           `json:"value,omitempty"`
	Unit                    string        `json:"unit,omitempty"`
}

Badge contains information about a badge

type BadgesList

type BadgesList struct {
	Badges []Badge `json:"badges"`
}

BadgesList contains a list of badges

type BodyFat

type BodyFat struct {
	Fat []struct {
		Date   string  `json:"date"`
		Fat    float64 `json:"fat"`
		LogID  int64   `json:"logId"`
		Source string  `json:"source"`
		Time   string  `json:"time"`
	} `json:"fat"`
}

BodyFat contains one or multiple records, similar to BodyFat but without weight

type BodyFatGoal

type BodyFatGoal struct {
	Goal struct {
		Fat int `json:"fat"`
	} `json:"goal"`
}

BodyFatGoal contains the currently set fat goal of the user

type BodyWeight

type BodyWeight struct {
	Weight []struct {
		Bmi    float64 `json:"bmi"`
		Date   string  `json:"date"`
		Fat    float64 `json:"fat"`
		LogID  int64   `json:"logId"`
		Source string  `json:"source"`
		Time   string  `json:"time"`
		Weight float64 `json:"weight"`
	} `json:"weight"`
}

BodyWeight contains one or multiple records

type BodyWeightGoal

type BodyWeightGoal struct {
	Goal struct {
		GoalType        string  `json:"goalType"`
		StartDate       string  `json:"startDate"`
		StartWeight     float64 `json:"startWeight"`
		Weight          int     `json:"weight"`
		WeightThreshold float64 `json:"weightThreshold"`
	} `json:"goal"`
}

BodyWeightGoal contains the currently set body goal by the user

type BreathingRate added in v1.2.0

type BreathingRate struct {
	Br []struct {
		Value struct {
			BreathingRate float64 `json:"breathingRate"`
		} `json:"value"`
		DateTime string `json:"dateTime"`
	} `json:"br"`
}

type BreathingRateIntraday added in v1.2.0

type BreathingRateIntraday struct {
	Br []struct {
		Value struct {
			DeepSleepSummary struct {
				BreathingRate float64 `json:"breathingRate"`
			} `json:"deepSleepSummary"`
			RemSleepSummary struct {
				BreathingRate float64 `json:"breathingRate"`
			} `json:"remSleepSummary"`
			FullSleepSummary struct {
				BreathingRate float64 `json:"breathingRate"`
			} `json:"fullSleepSummary"`
			LightSleepSummary struct {
				BreathingRate float64 `json:"breathingRate"`
			} `json:"lightSleepSummary"`
		} `json:"value"`
		DateTime string `json:"dateTime"`
	} `json:"br"`
}

type CardioFitnessScoreLog

type CardioFitnessScoreLog struct {
	CardioScore []struct {
		DateTime string `json:"dateTime"`
		Value    struct {
			Vo2Max string `json:"vo2Max"` // VO2 Max in mL/kg/min
		} `json:"value"`
	} `json:"cardioScore"`
}

CardioFitnessScoreLog contains the cardio fitness score (VO2Max) for a given date

type Config

type Config struct {
	ClientID     string  // ClientID is the client id (OAuth 2.0 Client ID) of the application (required)
	ClientSecret string  // ClientSecret is the client secret (Client Secret) of the application (required)
	RedirectURL  string  // RedirectURL is the redirect url of the application (required)
	Scopes       []Scope // Scopes is a list of scopes to request
	Locale       string  // en_AU, fr_FR, de_DE, ja_JP, en_NZ, es_ES, en_GB, en_US (default: de_DE)
}

Config describes the configuration of a fitbit API configuration

type Device

type Device struct {
	Battery       string        `json:"battery"`
	BatteryLevel  int           `json:"batteryLevel,omitempty"`
	DeviceVersion string        `json:"deviceVersion"`
	Features      []interface{} `json:"features"`
	ID            string        `json:"id"`
	LastSyncTime  string        `json:"lastSyncTime"`
	Mac           string        `json:"mac,omitempty"`
	Type          string        `json:"type"`
}

Device contains information about a fitbit device

type ECGLogList added in v1.2.3

type ECGLogList struct {
	EcgReadings []struct {
		StartTime               string `json:"startTime"`
		AverageHeartRate        int    `json:"averageHeartRate"`
		ResultClassification    string `json:"resultClassification"`
		WaveformSamples         []int  `json:"waveformSamples"`
		SamplingFrequencyHz     int    `json:"samplingFrequencyHz"`
		ScalingFactor           int    `json:"scalingFactor"`
		NumberOfWaveformSamples int    `json:"numberOfWaveformSamples"`
		LeadNumber              int    `json:"leadNumber"`
		FeatureVersion          string `json:"featureVersion"`
		DeviceName              string `json:"deviceName"`
		FirmwareVersion         string `json:"firmwareVersion"`
	} `json:"ecgReadings"`
	Pagination struct {
		AfterDate string `json:"afterDate"`
		Limit     int    `json:"limit"`
		Next      string `json:"next"`
		Offset    int    `json:"offset"`
		Previous  string `json:"previous"`
		Sort      string `json:"sort"`
	} `json:"pagination"`
}

ECG data

type FoodCollectionList

type FoodCollectionList []struct {
	AccessLevel        string `json:"accessLevel"`
	Amount             int    `json:"amount,omitempty"`
	Brand              string `json:"brand"`
	Calories           int    `json:"calories"`
	CreatorEncodedID   string `json:"creatorEncodedId,omitempty"`
	DateLastEaten      string `json:"dateLastEaten,omitempty"`
	DefaultServingSize int    `json:"defaultServingSize"`
	DefaultUnit        struct {
		ID     int    `json:"id"`
		Name   string `json:"name"`
		Plural string `json:"plural"`
	} `json:"defaultUnit"`
	FoodID     uint64 `json:"foodId"`
	MealTypeID uint64 `json:"mealTypeId,omitempty"`
	Name       string `json:"name"`
	Servings   []struct {
		Multiplier  int `json:"multiplier"`
		ServingSize int `json:"servingSize"`
		UnitID      int `json:"unitId"`
		Unit        struct {
			ID     int    `json:"id"`
			Name   string `json:"name"`
			Plural string `json:"plural"`
		} `json:"unit,omitempty"`
	} `json:"servings,omitempty"`
	Unit struct {
		ID     int    `json:"id"`
		Name   string `json:"name"`
		Plural string `json:"plural"`
	} `json:"unit"`
	Units             []int  `json:"units"`
	Locale            string `json:"locale,omitempty"`
	NutritionalValues struct {
		Biotin            int     `json:"biotin"`
		Calcium           int     `json:"calcium"`
		Calories          int     `json:"calories"`
		CaloriesFromFat   int     `json:"caloriesFromFat"`
		Cholesterol       int     `json:"cholesterol"`
		Copper            int     `json:"copper"`
		DietaryFiber      int     `json:"dietaryFiber"`
		FolicAcid         int     `json:"folicAcid"`
		Iodine            int     `json:"iodine"`
		Iron              int     `json:"iron"`
		Magnesium         int     `json:"magnesium"`
		Niacin            int     `json:"niacin"`
		PantothenicAcid   int     `json:"pantothenicAcid"`
		Phosphorus        int     `json:"phosphorus"`
		Potassium         int     `json:"potassium"`
		Protein           int     `json:"protein"`
		Riboflavin        int     `json:"riboflavin"`
		SaturatedFat      float64 `json:"saturatedFat"`
		Sodium            int     `json:"sodium"`
		Sugars            int     `json:"sugars"`
		Thiamin           int     `json:"thiamin"`
		TotalCarbohydrate int     `json:"totalCarbohydrate"`
		TotalFat          int     `json:"totalFat"`
		TransFat          int     `json:"transFat"`
		VitaminA          int     `json:"vitaminA"`
		VitaminB12        int     `json:"vitaminB12"`
		VitaminB6         int     `json:"vitaminB6"`
		VitaminC          int     `json:"vitaminC"`
		VitaminD          int     `json:"vitaminD"`
		VitaminE          int     `json:"vitaminE"`
		Zinc              int     `json:"zinc"`
	} `json:"nutritionalValues,omitempty"`
}

FoodCollectionList contains a list of food collections

type FoodEntry

type FoodEntry struct {
	Food struct {
		AccessLevel        string `json:"accessLevel"`
		Brand              string `json:"brand"`
		Calories           int    `json:"calories"`
		DefaultServingSize int    `json:"defaultServingSize"`
		DefaultUnit        struct {
			ID     int    `json:"id"`
			Name   string `json:"name"`
			Plural string `json:"plural"`
		} `json:"defaultUnit"`
		FoodID    int    `json:"foodId"`
		IsGeneric bool   `json:"isGeneric"`
		Locale    string `json:"locale"`
		Name      string `json:"name"`
		Servings  []struct {
			Multiplier  int `json:"multiplier"`
			ServingSize int `json:"servingSize"`
			Unit        struct {
				ID     int    `json:"id"`
				Name   string `json:"name"`
				Plural string `json:"plural"`
			} `json:"unit"`
			UnitID int `json:"unitId"`
		} `json:"servings"`
		Units []int `json:"units"`
	} `json:"food"`
}

FoodEntry contains a food entry

type FoodGoal

type FoodGoal struct {
	FoodPlan struct {
		EstimatedDate string `json:"estimatedDate"`
		Intensity     string `json:"intensity"`
		Personalized  bool   `json:"personalized"`
	} `json:"foodPlan"`
	Goals struct {
		Calories int `json:"calories"`
	} `json:"goals"`
}

FoodGoal contains the food goal of a user

type FoodLocales

type FoodLocales []struct {
	Barcode     bool   `json:"barcode"`
	ImageUpload bool   `json:"imageUpload"`
	Label       string `json:"label"`
	Value       string `json:"value"`
}

FoodLocales contains a list of supported food locales

type FoodLog

type FoodLog struct {
	Foods []struct {
		IsFavorite bool   `json:"isFavorite"`
		LogDate    string `json:"logDate"`
		LogID      uint64 `json:"logId"`
		LoggedFood struct {
			AccessLevel      string  `json:"accessLevel"`
			Amount           float64 `json:"amount"`
			Brand            string  `json:"brand"`
			Calories         uint64  `json:"calories"`
			CreatorEncodedID string  `json:"creatorEncodedId,omitempty"`
			FoodID           uint64  `json:"foodId"`
			Locale           string  `json:"locale"`
			MealTypeID       uint64  `json:"mealTypeId"`
			Name             string  `json:"name"`
			Unit             struct {
				ID     int    `json:"id"`
				Name   string `json:"name"`
				Plural string `json:"plural"`
			} `json:"unit"`
			Units []int `json:"units"`
		} `json:"loggedFood,omitempty"`
		NutritionalValues struct {
			Calories int     `json:"calories"`
			Carbs    float64 `json:"carbs"`
			Fat      float64 `json:"fat"`
			Fiber    float64 `json:"fiber"`
			Protein  float64 `json:"protein"`
			Sodium   int     `json:"sodium"`
		} `json:"nutritionalValues"`
	} `json:"foods"`
	Goals struct {
		Calories             int `json:"calories"`
		EstimatedCaloriesOut int `json:"estimatedCaloriesOut"`
	} `json:"goals"`
	Summary struct {
		Calories int     `json:"calories"`
		Carbs    float64 `json:"carbs"`
		Fat      float64 `json:"fat"`
		Fiber    float64 `json:"fiber"`
		Protein  float64 `json:"protein"`
		Sodium   float64 `json:"sodium"`
		Water    int     `json:"water"`
	} `json:"summary"`
}

FoodLog contains a users food log

type FoodSearchResult

type FoodSearchResult struct {
	Foods []struct {
		AccessLevel        string `json:"accessLevel"`
		Brand              string `json:"brand"`
		Calories           int    `json:"calories"`
		DefaultServingSize int    `json:"defaultServingSize"`
		DefaultUnit        struct {
			ID     int    `json:"id"`
			Name   string `json:"name"`
			Plural string `json:"plural"`
		} `json:"defaultUnit"`
		FoodID    int    `json:"foodId"`
		IsGeneric bool   `json:"isGeneric"`
		Locale    string `json:"locale"`
		Name      string `json:"name"`
		Units     []int  `json:"units"`
	} `json:"foods"`
}

FoodSearchResult contains a list of food found by FoodSearch

type FoodUnits

type FoodUnits []struct {
	ID     int    `json:"id"`
	Name   string `json:"name"`
	Plural string `json:"plural"`
}

FoodUnits defines the response of FoodUnits request

type FoodWaterLogDateRange

type FoodWaterLogDateRange struct {
	FoodsLogCaloriesIn []struct {
		DateTime string `json:"dateTime"`
		Value    string `json:"value"`
	} `json:"foods-log-caloriesIn,omitempty"`
	FoodsLogWater []struct {
		DateTime string `json:"dateTime"`
		Value    string `json:"value"`
	} `json:"foods-log-water,omitempty"`
}

FoodWaterLogDateRange contains a summary of calories or water for a given date range

type Friend

type Friend struct {
	Attributes struct {
		Friend bool   `json:"friend"`
		Child  bool   `json:"child"`
		Name   string `json:"name"`
		Avatar string `json:"avatar"`
	} `json:"attributes"`
	ID   string `json:"id"`
	Type string `json:"type"`
}

Friend describes a friend

type FriendsInvitations

type FriendsInvitations struct {
	Data []struct {
		Type       string `json:"type"`
		ID         string `json:"id"`
		Attributes struct {
			DateTime string `json:"dateTime"`
			Email    string `json:"email,omitempty"`
			Source   string `json:"source"`
		} `json:"attributes,omitempty"`
		Relationships struct {
			User struct {
				Data struct {
					Type string `json:"type"`
					ID   string `json:"id"`
				} `json:"data"`
			} `json:"user"`
		} `json:"relationships,omitempty"`
	} `json:"data,omitempty"`
	Included []struct {
		Type       string `json:"type"`
		ID         string `json:"id"`
		Attributes struct {
			Friend bool   `json:"friend"`
			Child  bool   `json:"child"`
			Avatar string `json:"avatar"`
			Name   string `json:"name"`
		} `json:"attributes"`
	} `json:"included,omitempty"`
}

FriendsInvitations contains a list of open invitations to the user

type FriendsLeaderboard

type FriendsLeaderboard struct {
	Data []struct {
		Attributes struct {
			StepSummary int `json:"step-summary"`
			StepRank    int `json:"step-rank"`
		} `json:"attributes"`
		Relationships struct {
			User struct {
				Data struct {
					ID   string `json:"id"`
					Type string `json:"type"`
				} `json:"data"`
			} `json:"user"`
		} `json:"relationships"`
		ID   string `json:"id"`
		Type string `json:"type"`
	} `json:"data"`
	Included []struct {
		Attributes struct {
			Friend bool   `json:"friend,omitempty"`
			Child  bool   `json:"child"`
			Name   string `json:"name"`
			Avatar string `json:"avatar"`
		} `json:"attributes,omitempty"`
		ID   string `json:"id"`
		Type string `json:"type"`
	} `json:"included"`
}

FriendsLeaderboard contains the leaderboard of a user

type FriendsList

type FriendsList struct {
	Data []Friend `json:"data"`
}

FriendsList contins a list of friends

type GarminTrainingCenterDatabasev2

type GarminTrainingCenterDatabasev2 struct {
	XMLName    xml.Name `xml:"TrainingCenterDatabase"`
	Text       string   `xml:",chardata"`
	Xmlns      string   `xml:"xmlns,attr"`
	Activities struct {
		Text     string `xml:",chardata"`
		Activity struct {
			Text  string `xml:",chardata"`
			Sport string `xml:"Sport,attr"`
			ID    string `xml:"Id"`
			Lap   []struct {
				Text             string `xml:",chardata"`
				StartTime        string `xml:"StartTime,attr"`
				TotalTimeSeconds string `xml:"TotalTimeSeconds"`
				DistanceMeters   string `xml:"DistanceMeters"`
				Calories         string `xml:"Calories"`
				Intensity        string `xml:"Intensity"`
				TriggerMethod    string `xml:"TriggerMethod"`
				Track            struct {
					Text       string `xml:",chardata"`
					Trackpoint []struct {
						Text     string `xml:",chardata"`
						Time     string `xml:"Time"`
						Position struct {
							Text             string `xml:",chardata"`
							LatitudeDegrees  string `xml:"LatitudeDegrees"`
							LongitudeDegrees string `xml:"LongitudeDegrees"`
						} `xml:"Position"`
						AltitudeMeters string `xml:"AltitudeMeters"`
						DistanceMeters string `xml:"DistanceMeters"`
						HeartRateBpm   struct {
							Text  string `xml:",chardata"`
							Value string `xml:"Value"`
						} `xml:"HeartRateBpm"`
					} `xml:"Trackpoint"`
				} `xml:"Track"`
			} `xml:"Lap"`
			Creator struct {
				Text      string `xml:",chardata"`
				Type      string `xml:"type,attr"`
				Xsi       string `xml:"xsi,attr"`
				Name      string `xml:"Name"`
				UnitID    string `xml:"UnitId"`
				ProductID string `xml:"ProductID"`
			} `xml:"Creator"`
		} `xml:"Activity"`
	} `xml:"Activities"`
}

ActivityTCX contains the activity TCX for a given activity Fitbit is using http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2 for the TCX format Also available at https://www8.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd TODO: Extend struct below to include all available fields

func ReadTCX

func ReadTCX(data []byte) (GarminTrainingCenterDatabasev2, error)

type HRVDay

type HRVDay struct {
	Value    HRVValue `json:"value"`
	DateTime string   `json:"dateTime"`
}

type HRVIntraday

type HRVIntraday struct {
	Minutes  []HRVMinutes `json:"minutes"`
	DateTime string       `json:"dateTime"`
}

type HRVIntradayValue

type HRVIntradayValue struct {
	Rmssd    float64 `json:"rmssd"`
	Coverage float64 `json:"coverage"`
	Hf       float64 `json:"hf"`
	Lf       float64 `json:"lf"`
}

type HRVMinutes

type HRVMinutes struct {
	Minute string           `json:"minutes"`
	Value  HRVIntradayValue `json:"value"`
}

type HRVValue

type HRVValue struct {
	DailyRmssd float64 `json:"dailyRmssd"`
	DeepRmssd  float64 `json:"deepRmssd"`
}

type HeartDay

type HeartDay struct {
	ActivitiesHeart []struct {
		DateTime string `json:"dateTime"`
		Value    struct {
			CustomHeartRateZones []interface{}    `json:"customHeartRateZones,omitempty"`
			HeartRateZones       []HeartRateZones `json:"heartRateZones"`
			RestingHeartRate     int              `json:"restingHeartRate"`
		} `json:"value"`
	} `json:"activities-heart"`
	ActivitiesHeartIntraday ActivitiesHeartIntraday `json:"activities-heart-intraday,omitempty"`
}

HeartDay contains a summary of heartrates for a given date range

type HeartIntraday

type HeartIntraday struct {
	ActivitiesHeart []struct {
		CustomHeartRateZones []interface{}    `json:"customHeartRateZones"`
		DateTime             string           `json:"dateTime"`
		HeartRateZones       []HeartRateZones `json:"heartRateZones"`
		Value                string           `json:"value"`
	} `json:"activities-heart"`
	ActivitiesHeartIntraday ActivitiesHeartIntraday `json:"activities-heart-intraday,omitempty"`
}

HeartIntraday with slightly different structure to HeartDay

type HeartRateVariabilityIntraday

type HeartRateVariabilityIntraday struct {
	Hrv []HRVIntraday `json:"hrv"`
}

HeartRateVariabilityIntraday with slightly different structure to HeartRateVariabilitySummary

type HeartRateVariabilitySummary

type HeartRateVariabilitySummary struct {
	Hrv []HRVDay `json:"hrv"`
}

HeartRateVariabilitySummary contains a summary of heartrate variability (HRV) values for a given date range

type HeartRateZones

type HeartRateZones struct {
	CaloriesOut float64 `json:"caloriesOut"`
	Max         int     `json:"max"`
	Min         int     `json:"min"`
	Minutes     int     `json:"minutes"`
	Name        string  `json:"name"`
}

HeartRateZones contains the heart rate zones of different types like cardio

type IntrospectResponse

type IntrospectResponse struct {
	Active    bool   `json:"active"`
	Scope     string `json:"scope,omitempty"`
	ClientID  string `json:"client_id,omitempty"`
	UserID    string `json:"user_id,omitempty"`
	TokenType string `json:"token_type,omitempty"`
	Exp       int64  `json:"exp,omitempty"`
	Iat       int64  `json:"iat,omitempty"`
}

IntrospectResponse contains the response of the introspect request

type LogListParameters

type LogListParameters struct {
	BeforeDate string
	AfterDate  string
	Limit      int
	Offset     int
}

LogListParameters contains parameters for the activity log list

type NewActivity

type NewActivity struct {
	ActivityID     int     `json:"activityId,omitempty"`
	ActivityName   string  `json:"activityName,omitempty"`
	ManualCalories int     `json:"manualCalories,omitempty"`
	StartTime      string  `json:"startTime"`              // HH:mm
	DurationMillis int64   `json:"durationMillis"`         // milliseconds
	Date           string  `json:"date"`                   // yyyy-MM-dd
	Distance       float64 `json:"distance,omitempty"`     // x.xx
	DistanceUnit   string  `json:"distanceUnit,omitempty"` // Steps units are available only for "Walking" (activityId=90013) and "Running" (activityId=90009) directory activities and their intensity levels.
}

NewActivity contains the data for a new activity

type NewActivityResponse

type NewActivityResponse struct {
	ActivityLog struct {
		ActivityID       int     `json:"activityId"`
		ActivityParentID int     `json:"activityParentId"`
		Calories         int     `json:"calories"`
		Description      string  `json:"description"`
		Distance         float64 `json:"distance"`
		Duration         int     `json:"duration"`
		IsFavorite       bool    `json:"isFavorite"`
		LogID            int64   `json:"logId"`
		Name             string  `json:"name"`
		StartTime        string  `json:"startTime"`
		Steps            int     `json:"steps"`
	} `json:"activityLog"`
}

NewActivityResponse contains the response from a new activity request

type NewFoodLog

type NewFoodLog struct {
	FoodID     uint64  `json:"foodId,omitempty"`
	FoodName   string  `json:"foodName,omitempty"`
	MealTypeID int     `json:"mealTypeId"`
	UnitID     uint64  `json:"unitId"` // given by unit search and food serch which units are captable here
	Amount     float64 `json:"amount"`
	Date       string  `json:"date"`
	Favorite   bool    `json:"favorite,omitempty"`
	BrandName  string  `json:"brandName,omitempty"`
	Calories   uint64  `json:"calories,omitempty"`
}

NewFoodLog defines the data to be sent to the API when adding a new food log entry

type Profile

type Profile struct {
	User struct {
		Age                    int    `json:"age"`
		Ambassador             bool   `json:"ambassador"`
		AutoStrideEnabled      bool   `json:"autoStrideEnabled"`
		Avatar                 string `json:"avatar"`
		Avatar150              string `json:"avatar150"`
		Avatar640              string `json:"avatar640"`
		AverageDailySteps      int    `json:"averageDailySteps"`
		ChallengesBeta         bool   `json:"challengesBeta"`
		ClockTimeDisplayFormat string `json:"clockTimeDisplayFormat"`
		Corporate              bool   `json:"corporate"`
		CorporateAdmin         bool   `json:"corporateAdmin"`
		Country                string `json:"country"`
		DateOfBirth            string `json:"dateOfBirth"`
		DisplayName            string `json:"displayName"`
		DisplayNameSetting     string `json:"displayNameSetting"`
		DistanceUnit           string `json:"distanceUnit"`
		EncodedID              string `json:"encodedId"`
		FamilyGuidanceEnabled  bool   `json:"familyGuidanceEnabled"`
		Features               struct {
			ExerciseGoal             bool `json:"exerciseGoal"`
			PhoneNumberFriendFinding struct {
				Algorithm string   `json:"algorithm"`
				Countries []string `json:"countries"`
				Salt      string   `json:"salt"`
			} `json:"phoneNumberFriendFinding"`
		} `json:"features"`
		FoodsLocale              string  `json:"foodsLocale"`
		FullName                 string  `json:"fullName"`
		Gender                   string  `json:"gender"`
		GlucoseUnit              string  `json:"glucoseUnit"`
		Height                   float64 `json:"height"`
		HeightUnit               string  `json:"heightUnit"`
		IsBugReportEnabled       bool    `json:"isBugReportEnabled"`
		IsChild                  bool    `json:"isChild"`
		IsCoach                  bool    `json:"isCoach"`
		LanguageLocale           string  `json:"languageLocale"`
		LegalTermsAcceptRequired bool    `json:"legalTermsAcceptRequired"`
		Locale                   string  `json:"locale"`
		MemberSince              string  `json:"memberSince"`
		MfaEnabled               bool    `json:"mfaEnabled"`
		OffsetFromUTCMillis      int     `json:"offsetFromUTCMillis"`
		SdkDeveloper             bool    `json:"sdkDeveloper"`
		SleepTracking            string  `json:"sleepTracking"`
		StartDayOfWeek           string  `json:"startDayOfWeek"`
		StrideLengthRunning      float64 `json:"strideLengthRunning"`
		StrideLengthRunningType  string  `json:"strideLengthRunningType"`
		StrideLengthWalking      float64 `json:"strideLengthWalking"`
		StrideLengthWalkingType  string  `json:"strideLengthWalkingType"`
		SwimUnit                 string  `json:"swimUnit"`
		Timezone                 string  `json:"timezone"`
		TopBadges                []Badge `json:"topBadges"`
		WaterUnit                string  `json:"waterUnit"`
		WaterUnitName            string  `json:"waterUnitName"`
		Weight                   float64 `json:"weight"`
		WeightUnit               string  `json:"weightUnit"`
	} `json:"user"`
}

Profile contains profile information of an user

type Ratelimit

type Ratelimit struct {
	RateLimitAvailable int       // RateLimitAvailable is the number of requests available for the current rate limit window
	RateLimitUsed      int       // RateLimitUsed is the number of requests used for the current rate limit window
	RateLimitReset     time.Time // RateLimitReset is the time when the rate limit window resets
}

Ratelimit includes the rate limit information provided on every request

type Scope

type Scope = string

Scope describes an oauth2 scope for Fitbit

const (
	ScopeActivity      Scope = "activity"
	ScopeCardioFitness Scope = "cardio_fitness"
	ScopeBreathingRate Scope = "respiratory_rate"
	ScopeECG           Scope = "electrocardiogram"
	ScopeHeartrate     Scope = "heartrate"
	ScopeLocation      Scope = "location"
	ScopeNutrition     Scope = "nutrition"
	ScopeProfile       Scope = "profile"
	ScopeSettings      Scope = "settings"
	ScopeSleep         Scope = "sleep"
	ScopeSocial        Scope = "social"
	ScopeSpO2          Scope = "oxygen_saturation"
	ScopeTemperature   Scope = "temperature"
	ScopeWeight        Scope = "weight"
)

Different types of useable scopes

type Session

type Session struct {
	// HookTokenChange is a function that is called when the refresh_token changes
	TokenChange func(token *oauth2.Token)
	// contains filtered or unexported fields
}

Session is the main object with user data

func New

func New(config Config) *Session

New creates a new fitbit oauth session

func (*Session) ActiveZoneMinutesIntraday added in v1.1.0

func (m *Session) ActiveZoneMinutesIntraday(day string, resolution string) (ActiveZoneMinutesIntraday, error)

ActiveZoneMinutesIntraday returns the active zone minutes log intraday by a given date in the given resolution date must be in the format yyyy-MM-dd resolution can be 1min, 5min, or 15min 1min is default

func (*Session) ActiveZoneMinutesIntradayByDateRange added in v1.1.0

func (m *Session) ActiveZoneMinutesIntradayByDateRange(startDay string, endDay string, resolution string) (ActiveZoneMinutesIntraday, error)

ActiveZoneMinutesIntradayByDateRange returns the active zone minutes log intraday by a given date in the given resolution date must be in the format yyyy-MM-dd resolution can be 1min, 5min, or 15min 1min is default

func (*Session) ActiveZoneMinutesLogByDateRange added in v1.1.0

func (m *Session) ActiveZoneMinutesLogByDateRange(startDay string, endDay string) (ActiveZoneMinutesDay, error)

ActiveZoneMinutesLogByDateRange returns the active zone minutes log by a given date date must be in the format yyyy-MM-dd

func (*Session) ActiveZoneMinutesLogByDay added in v1.1.0

func (m *Session) ActiveZoneMinutesLogByDay(day string) (ActiveZoneMinutesDay, error)

ActiveZoneMinutesLogByDay returns the active zone minutes log by a given date date must be in the format yyyy-MM-dd

func (*Session) ActivitiesDaySummary

func (m *Session) ActivitiesDaySummary(day string) (ActivitiesSummaryDay, error)

ActivitiesDaySummary returns the summary of activities and made exercises date must be in the format yyyy-MM-dd

func (*Session) ActivitiesGoal

func (m *Session) ActivitiesGoal(period string) (ActivitiesGoal, error)

ActivitiesGoal returns user set activities goal

func (*Session) ActivitiesLifetime

func (m *Session) ActivitiesLifetime() (ActivitiesLifetime, error)

ActivitiesLifetime returns the summary of activities and made exercises date must be in the format yyyy-MM-dd

func (*Session) ActivitiesLogByDay

func (m *Session) ActivitiesLogByDay(day string, activity string, fetchRange string) (ActivitiesLog, error)

ActivitiesLogByDay returns the activities recorded for a given day and type date must be in the format yyyy-MM-dd and describes the end date activity is type of data to be fetched and returned fetchRange defines the timespan the data reaches back from day

func (*Session) ActivitiesLogInterdayByDay

func (m *Session) ActivitiesLogInterdayByDay(day string, activity string) (ActivitiesInterdayLog, error)

ActivitiesLogInterdayByDay returns the interday activities recorded for a given day and type date must be in the format yyyy-MM-dd and describes the end date activity is type of data to be fetched and returned

func (*Session) ActivityFrequent

func (m *Session) ActivityFrequent() ([]ActivitiesFrequent, error)

ActivityFrequent returns a list of frequent user activities

func (*Session) ActivityLog

func (m *Session) ActivityLog(params LogListParameters) (ActivitiesLogList, error)

ActivityLog returns the activity log for the given configuration

func (*Session) ActivityRecent

func (m *Session) ActivityRecent() ([]ActivitiesFrequent, error)

ActivityRecent returns a list of fRecent user activities

func (*Session) ActivityTCX

func (m *Session) ActivityTCX(logID int64) ([]byte, error)

ActivityTCX returns the activity TCX for the given activity

func (*Session) ActivityTypes

func (m *Session) ActivityTypes() (ActivitiesTypes, error)

ActivityTypes returns a list of activities available, even user created ones

func (*Session) AddBodyFat

func (m *Session) AddBodyFat(day string, fat float64) (BodyFat, error)

AddBodyFat adds a new body weight record date must be in the format yyyy-MM-dd

func (*Session) AddBodyWeight

func (m *Session) AddBodyWeight(day string, weight float64) (BodyWeight, error)

AddBodyWeight adds a new body weight record date must be in the format yyyy-MM-dd

func (*Session) AddFood

func (m *Session) AddFood(data NewFoodLog) (AddFoodLogResponse, error)

AddFood logs a new consumed food entry

func (*Session) AddFoodFavorite

func (m *Session) AddFoodFavorite(id uint64) error

AddFoodFavorite adds food by id to favorites

func (*Session) AddSleep

func (m *Session) AddSleep(date string, startTime string, duration int64) (SleepDay, error)

AddSleep adds a new sleep record date in form of yyyy-MM-dd startTime in form of HH:mm duration in milliseconds

func (*Session) AddSubscription

func (m *Session) AddSubscription(collectionPath string, uniqueID int) (bool, Subscription, error)

AddSubscription adds a new subscription where fitbit sends a request on changes caused by the user

func (*Session) AddWater

func (m *Session) AddWater(date string, amount float64, unit string) (WaterLog, error)

AddWater adds a new water log entry for the user date has to be in the format yyyy-MM-dd amount contains the amount of water consumed unit can be ml, fl oz or cup

func (*Session) Badges

func (m *Session) Badges(userID uint64) (BadgesList, error)

Badges returns a list of user badges

func (*Session) BodyFatGoal

func (m *Session) BodyFatGoal() (BodyFatGoal, error)

BodyFatGoal requests the fat goal of the user

func (*Session) BodyFatLogByDateRange

func (m *Session) BodyFatLogByDateRange(startDay string, endDay string) (BodyFat, error)

BodyFatLogByDateRange returns the weight log of a given time range by date date must be in the format yyyy-MM-dd

func (*Session) BodyFatLogByDay

func (m *Session) BodyFatLogByDay(day string) (BodyFat, error)

BodyFatLogByDay returns the fat log by a given date date must be in the format yyyy-MM-dd

func (*Session) BodyWeightGoal

func (m *Session) BodyWeightGoal() (BodyWeightGoal, error)

BodyWeightGoal requests the weight goal of the user

func (*Session) BodyWeightLogByDateRange

func (m *Session) BodyWeightLogByDateRange(startDay string, endDay string) (BodyWeight, error)

BodyWeightLogByDateRange returns the weight log of a given time range by date date must be in the format yyyy-MM-dd

func (*Session) BodyWeightLogByDay

func (m *Session) BodyWeightLogByDay(day string) (BodyWeight, error)

BodyWeightLogByDay returns the weight log by a given date date must be in the format yyyy-MM-dd

func (*Session) BreathingRateLogByDateRange added in v1.2.0

func (m *Session) BreathingRateLogByDateRange(startDay string, endDay string) (BreathingRate, error)

BreathingRateLogByDateRange returns the breathing rate summary log of a given time range by date date must be in the format yyyy-MM-dd

func (*Session) BreathingRateLogByDateRangeIntraday added in v1.2.0

func (m *Session) BreathingRateLogByDateRangeIntraday(startDay string, endDay string) (BreathingRateIntraday, error)

BreathingRateLogByDateRangeIntraday returns the breathing rate log of a given time range by date date must be in the format yyyy-MM-dd

func (*Session) BreathingRateLogByDay added in v1.2.0

func (m *Session) BreathingRateLogByDay(day string) (BreathingRate, error)

BreathingRateLogByDay returns the breathing rate log (summary) by a given date date must be in the format yyyy-MM-dd

func (*Session) BreathingRateLogByDayIntraday added in v1.2.0

func (m *Session) BreathingRateLogByDayIntraday(day string) (BreathingRateIntraday, error)

BreathingRateLogByDayIntraday returns the breathing rate log by a given date date must be in the format yyyy-MM-dd

func (*Session) CardioFitnessScoreByDateRange

func (m *Session) CardioFitnessScoreByDateRange(startDate, endDate string) (CardioFitnessScoreLog, error)

CardioFitnessScoreByDateRange returns the cardio fitness score (VO2Max) for the given date range date must be in the format yyyy-MM-dd, scope ScopeCardioFitness must be granted

func (*Session) CardioFitnessScoreByDay

func (m *Session) CardioFitnessScoreByDay(date string) (CardioFitnessScoreLog, error)

CardioFitnessScoreByDay returns the cardio fitness score (VO2Max) for a given date date must be in the format yyyy-MM-dd, scope ScopeCardioFitness must be granted

func (*Session) Devices

func (m *Session) Devices(userID uint64) ([]Device, error)

Devices returns

func (*Session) ECGLog added in v1.2.3

func (m *Session) ECGLog(params LogListParameters) (ECGLogList, error)

ECGLog returns the ECG log list

func (*Session) Exchange

func (m *Session) Exchange(code string) (*oauth2.Token, error)

Exchange uses an authorization code to retrieve an access token and refresh token. sets them in the current session using SetToken and rebuilds the httpClient

func (*Session) FoodByID

func (m *Session) FoodByID(id uint64) (FoodEntry, error)

FoodByID returns a food by its id

func (*Session) FoodFavorites

func (m *Session) FoodFavorites() (FoodCollectionList, error)

FoodFavorites returns favorite food TODO: not tested, seems to be not implemented within the app

func (*Session) FoodFrequent

func (m *Session) FoodFrequent() (FoodCollectionList, error)

FoodFrequent returns frequently eaten food

func (*Session) FoodGoal

func (m *Session) FoodGoal() (FoodGoal, error)

FoodGoal requests the food goal of the user

func (*Session) FoodLocales

func (m *Session) FoodLocales() (FoodLocales, error)

FoodLocales returns a list of supported food locales

func (*Session) FoodLogByDateRange

func (m *Session) FoodLogByDateRange(startDay string, endDay string) (FoodWaterLogDateRange, error)

FoodLogByDateRange returns the calories log of a given time range by date date must be in the format yyyy-MM-dd

func (*Session) FoodLogByDay

func (m *Session) FoodLogByDay(day string) (FoodLog, error)

FoodLogByDay returns the food log by a given date date must be in the format yyyy-MM-dd

func (*Session) FoodRecent

func (m *Session) FoodRecent() (FoodCollectionList, error)

FoodRecent returns recently eaten food

func (*Session) FoodSearch

func (m *Session) FoodSearch(value string) (FoodSearchResult, error)

FoodSearch searches for food within the fitbit database for matching food

func (*Session) FoodUnits

func (m *Session) FoodUnits() (FoodUnits, error)

FoodUnits contains a list of supported food units

func (*Session) FriendInviteByEmail

func (m *Session) FriendInviteByEmail(value string) ([]byte, error)

FriendInviteByEmail invites another user to be friends by email FIXME: untested function, unknown response from server

func (*Session) FriendInviteByUserID

func (m *Session) FriendInviteByUserID(value string) ([]byte, error)

FriendInviteByUserID invites another user to be friends by user id FIXME: untested function, unknown response from server

func (*Session) FriendsRespondToInvition

func (m *Session) FriendsRespondToInvition(userID string, accept bool) ([]byte, error)

FriendsRespondToInvition reacts to a inviation FIXME: untested function, unknown response from server

func (*Session) GetFriendInvitations

func (m *Session) GetFriendInvitations() (FriendsInvitations, error)

GetFriendInvitations returns a list of open friend invitations

func (*Session) GetFriends

func (m *Session) GetFriends() (FriendsList, error)

GetFriends returns the current friends of the current user

func (*Session) GetFriendsLeaderboard

func (m *Session) GetFriendsLeaderboard() (FriendsLeaderboard, error)

GetFriendsLeaderboard returns the leaderbord including the user

func (*Session) GetRatelimit

func (m *Session) GetRatelimit() Ratelimit

GetRatelimit returns the current ratelimit information obtained by the last API request

func (*Session) GetSubscriptions

func (m *Session) GetSubscriptions(collectionPath string) (bool, SubscriptionList, error)

GetSubscriptions get's a list of current subscriptions

func (*Session) HRVIntradayByDate

func (m *Session) HRVIntradayByDate(day string) (HeartRateVariabilityIntraday, error)

HRVSummaryByDate the Heart Rate Variability (HRV) data for a date. HRV data applies specifically to a user’s “main sleep,” which is the longest single period of time asleep on a given date. date must be in the format yyyy-MM-dd

func (*Session) HRVIntradayByDateRange

func (m *Session) HRVIntradayByDateRange(startDay string, endDay string) (HeartRateVariabilityIntraday, error)

HRVSummaryByDateRange the Heart Rate Variability (HRV) data for a date range. HRV data applies specifically to a user’s “main sleep,” which is the longest single period of time asleep on a given date. date must be in the format yyyy-MM-dd

func (*Session) HRVSummaryByDate

func (m *Session) HRVSummaryByDate(day string) (HeartRateVariabilitySummary, error)

HRVSummaryByDate the Heart Rate Variability (HRV) data for a date. HRV data applies specifically to a user’s “main sleep,” which is the longest single period of time asleep on a given date. date must be in the format yyyy-MM-dd

func (*Session) HRVSummaryByDateRange

func (m *Session) HRVSummaryByDateRange(startDay string, endDay string) (HeartRateVariabilitySummary, error)

HRVSummaryByDateRange the Heart Rate Variability (HRV) data for a date range. HRV data applies specifically to a user’s “main sleep,” which is the longest single period of time asleep on a given date. date must be in the format yyyy-MM-dd

func (*Session) HeartIntraday

func (m *Session) HeartIntraday(day string, resolution string, timeFrom string, timeTo string) (HeartIntraday, error)

HeartIntraday returns the heart log by a given date in the given resolution date must be in the format yyyy-MM-dd, default is today resolution can be 1min or 1sec, 1sec is default timeFrom and timeTo are in the format 00:00 for hour:minute, default entire day

func (*Session) HeartLogByDateRange

func (m *Session) HeartLogByDateRange(startDay string, endDay string) (HeartDay, error)

HeartLogByDateRange returns the heart log of a given time range by date in default resolution date must be in the format yyyy-MM-dd

func (*Session) HeartLogByDateRangeIntraday added in v1.1.0

func (m *Session) HeartLogByDateRangeIntraday(startDay string, endDay string, resolution string) (HeartDay, error)

HeartLogByDateRangeIntraday returns the heart log by a given date range in the given resolution date must be in the format yyyy-MM-dd resolution can be 1min or 1sec, 1sec is default

func (*Session) HeartLogByDay

func (m *Session) HeartLogByDay(day string) (HeartDay, error)

HeartLogByDay returns the heart log by a given date date must be in the format yyyy-MM-dd

func (*Session) Introspect

func (m *Session) Introspect() (IntrospectResponse, error)

Introspect checks if the currently used oauth token is still valid

func (*Session) LogActivity

func (m *Session) LogActivity(activity NewActivity) (NewActivityResponse, error)

LogActivity logs a new activity date must be in the format yyyy-MM-dd TODO: TESTME

func (*Session) LoginURL

func (m *Session) LoginURL(csrf string) string

LoginURL returns an OAuth login url to obtain an access token

func (*Session) Profile

func (m *Session) Profile(userID uint64) (Profile, error)

Profile returns the current users profile if 0 is used or the profile of a friend with matching ID

func (*Session) RemoveActivity

func (m *Session) RemoveActivity(id int) error

RemoveActivity deletes an existing activity by activity log id TODO: TESTME

func (*Session) RemoveBodyFat

func (m *Session) RemoveBodyFat(logID int64) error

RemoveBodyFat removes a existing record by it's log ID

func (*Session) RemoveBodyWeight

func (m *Session) RemoveBodyWeight(logID int64) error

RemoveBodyWeight removes a existing record by it's log ID

func (*Session) RemoveFood

func (m *Session) RemoveFood(id uint64) error

RemoveFood removes an existing food log entry

func (*Session) RemoveFoodFavorite

func (m *Session) RemoveFoodFavorite(id uint64) error

RemoveFoodFavorite removes food by id from facorites

func (*Session) RemoveSleep

func (m *Session) RemoveSleep(sleepID uint64) error

RemoveSleep removes a sleep entry

func (*Session) RemoveSubscription

func (m *Session) RemoveSubscription(collectionPath string, uniqueID int) (bool, error)

RemoveSubscription removes a previously added subscription

func (*Session) RemoveWater

func (m *Session) RemoveWater(id uint64) error

RemoveWater removes an existing water log entry

func (*Session) SaveToken

func (m *Session) SaveToken() error

SaveToken triggers the TokenChange function to manually save the token

func (*Session) SetActivitiesGoal

func (m *Session) SetActivitiesGoal(period string, goals ActivitiesGoal) (ActivitiesGoal, error)

SetActivitiesGoal sets a new activities goal on daily or weekly basis

func (*Session) SetBodyFatGoal

func (m *Session) SetBodyFatGoal(targetFat float64) (FoodGoal, error)

SetBodyFatGoal sets the users body fat goal

func (*Session) SetBodyWeightGoal

func (m *Session) SetBodyWeightGoal(startDate string, startWeight float64, weightGoal float64) (BodyWeightGoal, error)

SetBodyWeightGoal sets the users body fat goal

func (*Session) SetFoodGoal

func (m *Session) SetFoodGoal(goals map[string]string) (FoodGoal, error)

SetFoodGoal sets the users food goal

func (*Session) SetProfile

func (m *Session) SetProfile(userID uint64, params map[string]string) (Profile, error)

SetProfile updates the current users profile information userID 0 is current user

func (*Session) SetSleepGoal

func (m *Session) SetSleepGoal(minDuration int) (SleepGoal, error)

SetSleepGoal requests the sleep goal of the user

func (*Session) SetToken

func (m *Session) SetToken(token *oauth2.Token)

SetToken sets the token to use for the session

func (*Session) SetWaterGoal

func (m *Session) SetWaterGoal(goal float64) (WaterGoal, error)

SetWaterGoal sets a new water goal

func (*Session) SleepByDay

func (m *Session) SleepByDay(day string) (SleepDay, error)

SleepByDay returns the sleep data for a given date date must be in the format yyyy-MM-dd

func (*Session) SleepByDayRange

func (m *Session) SleepByDayRange(startDay string, endDay string) (SleepDay, error)

SleepByDayRange returns the sleep data for a given date range date must be in the format yyyy-MM-dd

func (*Session) SleepGoal

func (m *Session) SleepGoal() (SleepGoal, error)

SleepGoal requests the sleep goal of the user

func (*Session) SleepLogList

func (m *Session) SleepLogList(params LogListParameters) (SleepLogList, error)

SleepLogList returns the sleep log list for based on given parameters

func (*Session) SpO2ByDay

func (m *Session) SpO2ByDay(day string) (SpO2, error)

SleepByDay returns the sleep data for a given date date must be in the format yyyy-MM-dd

func (*Session) SpO2ByDayIntraday

func (m *Session) SpO2ByDayIntraday(day string) (SpO2Intraday, error)

SpO2ByDayIntraday returns the sleep data for a given date with intraday accuration date must be in the format yyyy-MM-dd

func (*Session) TemperatureCoreByDateRange

func (m *Session) TemperatureCoreByDateRange(startDay string, endDay string) (TemperatureCore, error)

TemperatureCoreByDateRange returns the core temperature data for a given date range date must be in the format yyyy-MM-dd or today

func (*Session) TemperatureCoreByDay

func (m *Session) TemperatureCoreByDay(day string) (TemperatureCore, error)

TemperatureCoreByDay returns the core temperature data for a given date date must be in the format yyyy-MM-dd or today

func (*Session) TemperatureSkinByDateRange

func (m *Session) TemperatureSkinByDateRange(startDay string, endDay string) (TemperatureSkin, error)

TemperatureSkinByDateRange returns the skin temperature data for a given date range date must be in the format yyyy-MM-dd or today

func (*Session) TemperatureSkinByDay

func (m *Session) TemperatureSkinByDay(day string) (TemperatureSkin, error)

TemperatureSkinByDay returns the skin temperature data for a given date date must be in the format yyyy-MM-dd or today

func (*Session) UpdateFood

func (m *Session) UpdateFood(id uint64, data NewFoodLog) (AddFoodLogResponse, error)

UpdateFood changes a stored food log entry

func (*Session) UpdateWater

func (m *Session) UpdateWater(id uint64, amount float64, unit string) (WaterLog, error)

UpdateWater updates an existing water log entry with new values amount contains the amount of water consumed unit can be ml, fl oz or cup

func (*Session) WaterGoal

func (m *Session) WaterGoal() (WaterGoal, error)

WaterGoal get's the users water goal

func (*Session) WaterLogByDateRange

func (m *Session) WaterLogByDateRange(startDay string, endDay string) (FoodWaterLogDateRange, error)

WaterLogByDateRange returns the calories log of a given time range by date date must be in the format yyyy-MM-dd

func (*Session) WaterLogByDay

func (m *Session) WaterLogByDay(day string) (WaterLog, error)

WaterLogByDay returns the water log by a given date date must be in the format yyyy-MM-dd

type SleepDay

type SleepDay struct {
	Sleep []struct {
		DateOfSleep string `json:"dateOfSleep"`
		Duration    int    `json:"duration"`
		Efficiency  int    `json:"efficiency"`
		EndTime     string `json:"endTime"`
		InfoCode    int    `json:"infoCode"`
		IsMainSleep bool   `json:"isMainSleep"`
		Levels      struct {
			Data []struct {
				DateTime string `json:"dateTime"`
				Level    string `json:"level"`
				Seconds  int    `json:"seconds"`
			} `json:"data"`
			ShortData []struct {
				DateTime string `json:"dateTime"`
				Level    string `json:"level"`
				Seconds  int    `json:"seconds"`
			} `json:"shortData"`
			Summary struct {
				Deep struct {
					Count               int `json:"count"`
					Minutes             int `json:"minutes"`
					ThirtyDayAvgMinutes int `json:"thirtyDayAvgMinutes"`
				} `json:"deep"`
				Light struct {
					Count               int `json:"count"`
					Minutes             int `json:"minutes"`
					ThirtyDayAvgMinutes int `json:"thirtyDayAvgMinutes"`
				} `json:"light"`
				Rem struct {
					Count               int `json:"count"`
					Minutes             int `json:"minutes"`
					ThirtyDayAvgMinutes int `json:"thirtyDayAvgMinutes"`
				} `json:"rem"`
				Wake struct {
					Count               int `json:"count"`
					Minutes             int `json:"minutes"`
					ThirtyDayAvgMinutes int `json:"thirtyDayAvgMinutes"`
				} `json:"wake"`
				Asleep struct {
					Count               int `json:"count"`
					Minutes             int `json:"minutes"`
					ThirtyDayAvgMinutes int `json:"thirtyDayAvgMinutes,omitempty"`
				} `json:"asleep,omitempty"`
				Awake struct {
					Count               int `json:"count"`
					Minutes             int `json:"minutes"`
					ThirtyDayAvgMinutes int `json:"thirtyDayAvgMinutes,omitempty"`
				} `json:"awake,omitempty"`
				Restless struct {
					Count               int `json:"count"`
					Minutes             int `json:"minutes"`
					ThirtyDayAvgMinutes int `json:"thirtyDayAvgMinutes,omitempty"`
				} `json:"restless,omitempty"`
			} `json:"summary"`
		} `json:"levels,omitempty"`
		LogID               int64  `json:"logId"`
		MinutesAfterWakeup  int    `json:"minutesAfterWakeup"`
		MinutesAsleep       int    `json:"minutesAsleep"`
		MinutesAwake        int    `json:"minutesAwake"`
		MinutesToFallAsleep int    `json:"minutesToFallAsleep"`
		LogType             string `json:"logType"`
		StartTime           string `json:"startTime"`
		TimeInBed           int    `json:"timeInBed"`
		Type                string `json:"type"`
	} `json:"sleep"`
	Summary struct {
		Stages struct {
			Deep  int `json:"deep"`
			Light int `json:"light"`
			Rem   int `json:"rem"`
			Wake  int `json:"wake"`
		} `json:"stages"`
		TotalMinutesAsleep int `json:"totalMinutesAsleep"`
		TotalSleepRecords  int `json:"totalSleepRecords"`
		TotalTimeInBed     int `json:"totalTimeInBed"`
	} `json:"summary,omitempty"`
	Meta struct {
		RetryDuration int    `json:"retryDuration"`
		State         string `json:"state"`
	} `json:"meta,omitempty"`
}

SleepDay contains data of a sleep day

type SleepGoal

type SleepGoal struct {
	Consistency struct {
		AwakeRestlessPercentage float64 `json:"awakeRestlessPercentage"`
		FlowID                  int     `json:"flowId"`
		RecommendedSleepGoal    int     `json:"recommendedSleepGoal"`
		TypicalDuration         int     `json:"typicalDuration"`
		TypicalWakeupTime       string  `json:"typicalWakeupTime"`
	} `json:"consistency"`
	Goal struct {
		Bedtime     string    `json:"bedtime"`
		MinDuration int       `json:"minDuration"`
		UpdatedOn   time.Time `json:"updatedOn"`
		WakeupTime  string    `json:"wakeupTime"`
	} `json:"goal"`
}

SleepGoal defines the structure of SleepGoal response

type SleepLogList

type SleepLogList struct {
	Pagination struct {
		AfterDate  string `json:"afterDate"`
		BeforeDate string `json:"beforeDate"`
		Limit      int    `json:"limit"`
		Next       string `json:"next"`
		Offset     int    `json:"offset"`
		Previous   string `json:"previous"`
		Sort       string `json:"sort"`
	} `json:"pagination"`
	Sleep []struct {
		AwakeCount      int    `json:"awakeCount,omitempty"`
		AwakeDuration   int    `json:"awakeDuration,omitempty"`
		AwakeningsCount int    `json:"awakeningsCount,omitempty"`
		DateOfSleep     string `json:"dateOfSleep"`
		Duration        int    `json:"duration"`
		Efficiency      int    `json:"efficiency"`
		EndTime         string `json:"endTime"`
		InfoCode        int    `json:"infoCode"`
		IsMainSleep     bool   `json:"isMainSleep"`
		Levels          struct {
			Data []struct {
				DateTime string `json:"dateTime"`
				Level    string `json:"level"`
				Seconds  int    `json:"seconds"`
			} `json:"data,omitempty"`
			ShortData []struct {
				DateTime string `json:"dateTime"`
				Level    string `json:"level"`
				Seconds  int    `json:"seconds"`
			} `json:"shortData,omitempty"`
			Summary struct {
				Deep struct {
					Count               int `json:"count"`
					Minutes             int `json:"minutes"`
					ThirtyDayAvgMinutes int `json:"thirtyDayAvgMinutes"`
				} `json:"deep,omitempty"`
				Light struct {
					Count               int `json:"count"`
					Minutes             int `json:"minutes"`
					ThirtyDayAvgMinutes int `json:"thirtyDayAvgMinutes"`
				} `json:"light,omitempty"`
				Rem struct {
					Count               int `json:"count"`
					Minutes             int `json:"minutes"`
					ThirtyDayAvgMinutes int `json:"thirtyDayAvgMinutes"`
				} `json:"rem,omitempty"`
				Wake struct {
					Count               int `json:"count"`
					Minutes             int `json:"minutes"`
					ThirtyDayAvgMinutes int `json:"thirtyDayAvgMinutes"`
				} `json:"wake,omitempty"`
			} `json:"summary,omitempty"`
		} `json:"levels,omitempty"`
		LogID               int64  `json:"logId"`
		MinutesAfterWakeup  int    `json:"minutesAfterWakeup"`
		MinutesAsleep       int    `json:"minutesAsleep"`
		MinutesAwake        int    `json:"minutesAwake"`
		MinutesToFallAsleep int    `json:"minutesToFallAsleep"`
		RestlessCount       int    `json:"restlessCount,omitempty"`
		RestlessDuration    int    `json:"restlessDuration,omitempty"`
		LogType             string `json:"logType"`
		StartTime           string `json:"startTime"`
		TimeInBed           int    `json:"timeInBed"`
		Type                string `json:"type"`
		MinuteData          []struct {
			DateTime string `json:"dateTime"`
			Value    string `json:"value"`
		} `json:"minuteData,omitempty"`
	} `json:"sleep"`
}

SleepLogList defines the structure of SleepLogList based on an response

type SpO2

type SpO2 struct {
	DateTime string `json:"dateTime"`
	Value    struct {
		Avg float64 `json:"avg"`
		Min float64 `json:"min"`
		Max float64 `json:"max"`
	} `json:"value"`
}

type SpO2Intraday

type SpO2Intraday struct {
	DateTime string `json:"dateTime"`
	Minutes  []struct {
		Value  float64 `json:"value"`
		Minute string  `json:"minute"`
	} `json:"minutes"`
}

type Subscription

type Subscription struct {
	CollectionType string `json:"collectionType"`
	Date           string `json:"date,omitempty"`
	OwnerID        string `json:"ownerId"`
	OwnerType      string `json:"ownerType"`
	SubscriberID   string `json:"subscriberId"`
	SubscriptionID string `json:"subscriptionId"`
}

Subscription contains response and request data of fitbit eventsx

type SubscriptionList

type SubscriptionList struct {
	APISubscriptions []Subscription `json:"apiSubscriptions"`
}

SubscriptionList contains a list of current active subscriptions

type TemperatureCore

type TemperatureCore struct {
	TempCore []struct {
		DateTime string  `json:"dateTime"`
		Value    float64 `json:"value"`
	} `json:"tempCore"`
}

type TemperatureSkin

type TemperatureSkin struct {
	TempSkin []struct {
		DateTime string `json:"dateTime"`
		Value    struct {
			NightlyRelative float64 `json:"nightlyRelative"`
		} `json:"value"`
		LogType string `json:"logType"`
	} `json:"tempSkin"`
}

type WaterGoal

type WaterGoal struct {
	Goal struct {
		Goal      float64 `json:"goal"`
		StartDate string  `json:"startDate"`
	} `json:"goal"`
}

WaterGoal describes the water goal of the user

type WaterLog

type WaterLog struct {
	Summary struct {
		Water int `json:"water"`
	} `json:"summary"`
	Water []struct {
		Amount int    `json:"amount"`
		LogID  uint64 `json:"logId"`
	} `json:"water"`
}

WaterLog contains the water log of a user

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL