Documentation
¶
Index ¶
- Constants
- Variables
- type APIError
- type Client
- func (c *Client) CreateCustomExercise(req *CreateCustomExerciseRequest) (*ExerciseTemplate, error)
- func (c *Client) CreateRoutine(req *CreateRoutineRequest) (*Routine, error)
- func (c *Client) CreateRoutineFolder(req *CreateRoutineFolderRequest) (*RoutineFolder, error)
- func (c *Client) CreateWorkout(req *CreateWorkoutRequest) (*Workout, error)
- func (c *Client) DeleteWorkout(id string) error
- func (c *Client) GetAllWorkouts() ([]Workout, error)
- func (c *Client) GetExerciseTemplate(id string) (*ExerciseTemplate, error)
- func (c *Client) GetExerciseTemplates(page, pageSize int) (*ExerciseTemplatesResponse, error)
- func (c *Client) GetRoutine(id string) (*Routine, error)
- func (c *Client) GetRoutineFolder(id string) (*RoutineFolder, error)
- func (c *Client) GetRoutineFolders(page, pageSize int) (*RoutineFoldersResponse, error)
- func (c *Client) GetRoutines(page, pageSize int) (*RoutinesResponse, error)
- func (c *Client) GetWorkout(id string) (*Workout, error)
- func (c *Client) GetWorkoutCount() (int, error)
- func (c *Client) GetWorkouts(page, pageSize int) (*WorkoutsResponse, error)
- func (c *Client) UpdateRoutine(id string, req *UpdateRoutineRequest) (*Routine, error)
- func (c *Client) UpdateWorkout(id string, req *UpdateWorkoutRequest) (*Workout, error)
- func (c *Client) ValidateAuth() error
- type ClientOption
- type CreateCustomExerciseData
- type CreateCustomExerciseRequest
- type CreateRoutineData
- type CreateRoutineExercise
- type CreateRoutineFolderData
- type CreateRoutineFolderRequest
- type CreateRoutineRequest
- type CreateRoutineSet
- type CreateWorkoutData
- type CreateWorkoutExercise
- type CreateWorkoutRequest
- type CreateWorkoutSet
- type EquipmentCategory
- type EventType
- type Exercise
- type ExerciseTemplate
- type ExerciseTemplateResponse
- type ExerciseTemplatesResponse
- type ExerciseType
- type MuscleGroup
- type RepRange
- type Routine
- type RoutineFolder
- type RoutineFolderResponse
- type RoutineFoldersResponse
- type RoutineResponse
- type RoutinesResponse
- type Set
- type SetType
- type UpdateRoutineData
- type UpdateRoutineRequest
- type UpdateWorkoutData
- type UpdateWorkoutRequest
- type Workout
- type WorkoutCountResponse
- type WorkoutEvent
- type WorkoutEventsResponse
- type WorkoutResponse
- type WorkoutsResponse
Constants ¶
const ( // DefaultBaseURL is the default Hevy API base URL DefaultBaseURL = "https://api.hevyapp.com/v1" // DefaultTimeout is the default request timeout DefaultTimeout = 30 * time.Second // UserAgent is the user agent string for API requests UserAgent = "hevycli/1.0" )
const ( ExitSuccess = 0 ExitGeneralError = 1 ExitInvalidArgs = 2 ExitAuthError = 3 ExitRateLimited = 4 ExitNetworkError = 5 ExitNotFound = 6 ExitValidationError = 7 )
Exit codes for different error types
Variables ¶
var ( ErrInvalidAPIKey = NewAPIErrorWithDetails( "INVALID_API_KEY", "The provided API key is invalid or expired", "Please verify your API key at https://hevy.com/settings?developer", ) ErrForbidden = NewAPIErrorWithDetails( "FORBIDDEN", "Access forbidden", "Hevy Pro subscription required for API access", ) ErrNotFound = NewAPIError( "NOT_FOUND", "Resource not found", ) ErrRateLimited = NewAPIError( "RATE_LIMITED", "Rate limit exceeded. Please try again later", ) ErrNetworkError = NewAPIError( "NETWORK_ERROR", "Failed to connect to Hevy API", ) )
Common API errors
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
ErrorCode string `json:"code"`
ErrorMessage string `json:"message"`
ErrorDetails string `json:"details,omitempty"`
}
APIError represents an error from the Hevy API
func NewAPIError ¶
NewAPIError creates a new API error
func NewAPIErrorWithDetails ¶
NewAPIErrorWithDetails creates a new API error with additional details
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents the Hevy API client
func NewClient ¶
func NewClient(apiKey string, opts ...ClientOption) *Client
NewClient creates a new Hevy API client
func (*Client) CreateCustomExercise ¶
func (c *Client) CreateCustomExercise(req *CreateCustomExerciseRequest) (*ExerciseTemplate, error)
CreateCustomExercise creates a new custom exercise template
func (*Client) CreateRoutine ¶
func (c *Client) CreateRoutine(req *CreateRoutineRequest) (*Routine, error)
CreateRoutine creates a new routine
func (*Client) CreateRoutineFolder ¶
func (c *Client) CreateRoutineFolder(req *CreateRoutineFolderRequest) (*RoutineFolder, error)
CreateRoutineFolder creates a new routine folder
func (*Client) CreateWorkout ¶
func (c *Client) CreateWorkout(req *CreateWorkoutRequest) (*Workout, error)
CreateWorkout creates a new workout
func (*Client) DeleteWorkout ¶
DeleteWorkout deletes a workout by ID
func (*Client) GetAllWorkouts ¶
GetAllWorkouts fetches all workouts using pagination
func (*Client) GetExerciseTemplate ¶
func (c *Client) GetExerciseTemplate(id string) (*ExerciseTemplate, error)
GetExerciseTemplate fetches a single exercise template by ID
func (*Client) GetExerciseTemplates ¶
func (c *Client) GetExerciseTemplates(page, pageSize int) (*ExerciseTemplatesResponse, error)
GetExerciseTemplates fetches exercise templates with pagination
func (*Client) GetRoutine ¶
GetRoutine fetches a single routine by ID
func (*Client) GetRoutineFolder ¶
func (c *Client) GetRoutineFolder(id string) (*RoutineFolder, error)
GetRoutineFolder fetches a single routine folder by ID
func (*Client) GetRoutineFolders ¶
func (c *Client) GetRoutineFolders(page, pageSize int) (*RoutineFoldersResponse, error)
GetRoutineFolders fetches routine folders
func (*Client) GetRoutines ¶
func (c *Client) GetRoutines(page, pageSize int) (*RoutinesResponse, error)
GetRoutines fetches all routines
func (*Client) GetWorkout ¶
GetWorkout fetches a single workout by ID
func (*Client) GetWorkoutCount ¶
GetWorkoutCount fetches the total number of workouts
func (*Client) GetWorkouts ¶
func (c *Client) GetWorkouts(page, pageSize int) (*WorkoutsResponse, error)
GetWorkouts fetches workouts with pagination
func (*Client) UpdateRoutine ¶
func (c *Client) UpdateRoutine(id string, req *UpdateRoutineRequest) (*Routine, error)
UpdateRoutine updates an existing routine
func (*Client) UpdateWorkout ¶
func (c *Client) UpdateWorkout(id string, req *UpdateWorkoutRequest) (*Workout, error)
UpdateWorkout updates an existing workout
func (*Client) ValidateAuth ¶
ValidateAuth tests if the API key is valid by calling /workouts endpoint
type ClientOption ¶
type ClientOption func(*Client)
ClientOption is a function that configures the client
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout sets a custom timeout
type CreateCustomExerciseData ¶
type CreateCustomExerciseData struct {
Title string `json:"title"`
ExerciseType ExerciseType `json:"exercise_type"`
EquipmentCategory EquipmentCategory `json:"equipment_category"`
MuscleGroup MuscleGroup `json:"muscle_group"`
OtherMuscles []MuscleGroup `json:"other_muscles,omitempty"`
}
CreateCustomExerciseData represents the custom exercise data for creation
type CreateCustomExerciseRequest ¶
type CreateCustomExerciseRequest struct {
Exercise CreateCustomExerciseData `json:"exercise"`
}
CreateCustomExerciseRequest represents the request body for POST /exercise_templates
type CreateRoutineData ¶
type CreateRoutineData struct {
Title string `json:"title"`
FolderID *int `json:"folder_id,omitempty"`
Notes *string `json:"notes,omitempty"`
Exercises []CreateRoutineExercise `json:"exercises"`
}
CreateRoutineData represents the routine data for creation
type CreateRoutineExercise ¶
type CreateRoutineExercise struct {
ExerciseTemplateID string `json:"exercise_template_id"`
SupersetID *int `json:"superset_id,omitempty"`
RestSeconds *int `json:"rest_seconds,omitempty"`
Notes *string `json:"notes,omitempty"`
Sets []CreateRoutineSet `json:"sets"`
}
CreateRoutineExercise represents an exercise in a routine creation request
type CreateRoutineFolderData ¶
type CreateRoutineFolderData struct {
Title string `json:"title"`
}
CreateRoutineFolderData represents the folder data for creation
type CreateRoutineFolderRequest ¶
type CreateRoutineFolderRequest struct {
RoutineFolder CreateRoutineFolderData `json:"routine_folder"`
}
CreateRoutineFolderRequest represents the request body for POST /routine_folders
type CreateRoutineRequest ¶
type CreateRoutineRequest struct {
Routine CreateRoutineData `json:"routine"`
}
CreateRoutineRequest represents the request body for POST /routines
type CreateRoutineSet ¶
type CreateRoutineSet struct {
Type SetType `json:"type"`
WeightKg *float64 `json:"weight_kg,omitempty"`
Reps *int `json:"reps,omitempty"`
DistanceMeters *int `json:"distance_meters,omitempty"`
DurationSeconds *int `json:"duration_seconds,omitempty"`
CustomMetric *float64 `json:"custom_metric,omitempty"`
RepRange *RepRange `json:"rep_range,omitempty"`
}
CreateRoutineSet represents a set in a routine creation request
type CreateWorkoutData ¶
type CreateWorkoutData struct {
Title string `json:"title"`
Description *string `json:"description,omitempty"`
StartTime string `json:"start_time"`
EndTime string `json:"end_time"`
IsPrivate bool `json:"is_private,omitempty"`
Exercises []CreateWorkoutExercise `json:"exercises"`
}
CreateWorkoutData represents the workout data for creation
type CreateWorkoutExercise ¶
type CreateWorkoutExercise struct {
ExerciseTemplateID string `json:"exercise_template_id"`
SupersetID *int `json:"superset_id,omitempty"`
Notes *string `json:"notes,omitempty"`
Sets []CreateWorkoutSet `json:"sets"`
}
CreateWorkoutExercise represents an exercise in a workout creation request
type CreateWorkoutRequest ¶
type CreateWorkoutRequest struct {
Workout CreateWorkoutData `json:"workout"`
}
CreateWorkoutRequest represents the request body for POST /workouts
type CreateWorkoutSet ¶
type CreateWorkoutSet struct {
Type SetType `json:"type"`
WeightKg *float64 `json:"weight_kg,omitempty"`
Reps *int `json:"reps,omitempty"`
DistanceMeters *int `json:"distance_meters,omitempty"`
DurationSeconds *int `json:"duration_seconds,omitempty"`
CustomMetric *float64 `json:"custom_metric,omitempty"`
RPE *float64 `json:"rpe,omitempty"`
}
CreateWorkoutSet represents a set in a workout creation request
type EquipmentCategory ¶
type EquipmentCategory string
EquipmentCategory represents equipment types
const ( EquipmentNone EquipmentCategory = "none" EquipmentBarbell EquipmentCategory = "barbell" EquipmentDumbbell EquipmentCategory = "dumbbell" EquipmentKettlebell EquipmentCategory = "kettlebell" EquipmentMachine EquipmentCategory = "machine" EquipmentPlate EquipmentCategory = "plate" EquipmentResistanceBand EquipmentCategory = "resistance_band" EquipmentSuspension EquipmentCategory = "suspension" EquipmentOther EquipmentCategory = "other" )
type Exercise ¶
type Exercise struct {
Index int `json:"index"`
Title string `json:"title"`
Notes string `json:"notes,omitempty"`
ExerciseTemplateID string `json:"exercise_template_id"`
SupersetID *int `json:"superset_id,omitempty"`
Sets []Set `json:"sets"`
}
Exercise represents an exercise within a workout
type ExerciseTemplate ¶
type ExerciseTemplate struct {
ID string `json:"id"`
Title string `json:"title"`
Type string `json:"type,omitempty"`
PrimaryMuscleGroup string `json:"primary_muscle_group"`
SecondaryMuscleGroups []string `json:"secondary_muscle_groups,omitempty"`
Equipment string `json:"equipment,omitempty"`
IsCustom bool `json:"is_custom"`
}
ExerciseTemplate represents an exercise definition from the Hevy database
type ExerciseTemplateResponse ¶
type ExerciseTemplateResponse struct {
ExerciseTemplate ExerciseTemplate `json:"exercise_template"`
}
ExerciseTemplateResponse represents the response from POST /exercise_templates
type ExerciseTemplatesResponse ¶
type ExerciseTemplatesResponse struct {
Page int `json:"page"`
PageCount int `json:"page_count"`
ExerciseTemplates []ExerciseTemplate `json:"exercise_templates"`
}
ExerciseTemplatesResponse represents the /exercise_templates endpoint response
type ExerciseType ¶
type ExerciseType string
ExerciseType represents the type of exercise tracking
const ( ExerciseTypeWeightReps ExerciseType = "weight_reps" ExerciseTypeRepsOnly ExerciseType = "reps_only" ExerciseTypeBodyweightReps ExerciseType = "bodyweight_reps" ExerciseTypeBodyweightAssisted ExerciseType = "bodyweight_assisted_reps" ExerciseTypeDuration ExerciseType = "duration" ExerciseTypeWeightDuration ExerciseType = "weight_duration" ExerciseTypeDistanceDuration ExerciseType = "distance_duration" ExerciseTypeShortDistanceWeight ExerciseType = "short_distance_weight" )
type MuscleGroup ¶
type MuscleGroup string
MuscleGroup represents muscle groups for exercises
const ( MuscleGroupAbdominals MuscleGroup = "abdominals" MuscleGroupShoulders MuscleGroup = "shoulders" MuscleGroupBiceps MuscleGroup = "biceps" MuscleGroupTriceps MuscleGroup = "triceps" MuscleGroupForearms MuscleGroup = "forearms" MuscleGroupQuadriceps MuscleGroup = "quadriceps" MuscleGroupHamstrings MuscleGroup = "hamstrings" MuscleGroupCalves MuscleGroup = "calves" MuscleGroupGlutes MuscleGroup = "glutes" MuscleGroupAbductors MuscleGroup = "abductors" MuscleGroupAdductors MuscleGroup = "adductors" MuscleGroupLats MuscleGroup = "lats" MuscleGroupUpperBack MuscleGroup = "upper_back" MuscleGroupTraps MuscleGroup = "traps" MuscleGroupLowerBack MuscleGroup = "lower_back" MuscleGroupChest MuscleGroup = "chest" MuscleGroupCardio MuscleGroup = "cardio" MuscleGroupNeck MuscleGroup = "neck" MuscleGroupFullBody MuscleGroup = "full_body" MuscleGroupOther MuscleGroup = "other" )
type Routine ¶
type Routine struct {
ID string `json:"id"`
Title string `json:"title"`
FolderID *string `json:"folder_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Exercises []Exercise `json:"exercises"`
}
Routine represents a workout routine template
type RoutineFolder ¶
type RoutineFolder struct {
ID string `json:"id"`
Title string `json:"title"`
Index int `json:"index"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
RoutineFolder represents a folder for organizing routines
type RoutineFolderResponse ¶
type RoutineFolderResponse struct {
RoutineFolder RoutineFolder `json:"routine_folder"`
}
RoutineFolderResponse represents the response from POST /routine_folders
type RoutineFoldersResponse ¶
type RoutineFoldersResponse struct {
Page int `json:"page"`
PageCount int `json:"page_count"`
RoutineFolders []RoutineFolder `json:"routine_folders"`
}
RoutineFoldersResponse represents the /routine_folders endpoint response
type RoutineResponse ¶
type RoutineResponse struct {
Routine Routine `json:"routine"`
}
RoutineResponse represents the response from POST/PUT /routines
type RoutinesResponse ¶
type RoutinesResponse struct {
Page int `json:"page"`
PageCount int `json:"page_count"`
Routines []Routine `json:"routines"`
}
RoutinesResponse represents the /routines endpoint response
type Set ¶
type Set struct {
Index int `json:"index"`
SetType SetType `json:"type"`
WeightKg *float64 `json:"weight_kg,omitempty"`
Reps *int `json:"reps,omitempty"`
DistanceMeters *float64 `json:"distance_meters,omitempty"`
DurationSeconds *int `json:"duration_seconds,omitempty"`
RPE *float64 `json:"rpe,omitempty"`
}
Set represents a single set of an exercise
type UpdateRoutineData ¶
type UpdateRoutineData struct {
Title string `json:"title"`
Notes *string `json:"notes,omitempty"`
Exercises []CreateRoutineExercise `json:"exercises"`
}
UpdateRoutineData represents the routine data for update
type UpdateRoutineRequest ¶
type UpdateRoutineRequest struct {
Routine UpdateRoutineData `json:"routine"`
}
UpdateRoutineRequest represents the request body for PUT /routines/{id}
type UpdateWorkoutData ¶
type UpdateWorkoutData struct {
Title string `json:"title"`
Description *string `json:"description,omitempty"`
StartTime string `json:"start_time"`
EndTime string `json:"end_time"`
Exercises []CreateWorkoutExercise `json:"exercises"`
}
UpdateWorkoutData represents the workout data for update
type UpdateWorkoutRequest ¶
type UpdateWorkoutRequest struct {
Workout UpdateWorkoutData `json:"workout"`
}
UpdateWorkoutRequest represents the request body for PUT /workouts/{id}
type Workout ¶
type Workout struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Exercises []Exercise `json:"exercises"`
}
Workout represents a workout session
func (*Workout) ExerciseCount ¶
ExerciseCount returns the number of exercises in the workout
type WorkoutCountResponse ¶
type WorkoutCountResponse struct {
WorkoutCount int `json:"workout_count"`
}
WorkoutCountResponse represents the /workouts/count endpoint response
type WorkoutEvent ¶
type WorkoutEvent struct {
ID string `json:"id"`
Type EventType `json:"type"`
WorkoutID string `json:"workout_id"`
Timestamp time.Time `json:"timestamp"`
}
WorkoutEvent represents a change event for workout sync
type WorkoutEventsResponse ¶
type WorkoutEventsResponse struct {
Page int `json:"page"`
PageCount int `json:"page_count"`
WorkoutEvents []WorkoutEvent `json:"workout_events"`
}
WorkoutEventsResponse represents the /workouts/events endpoint response
type WorkoutResponse ¶
type WorkoutResponse struct {
Workout Workout `json:"workout"`
}
WorkoutResponse represents the response from POST/PUT /workouts
type WorkoutsResponse ¶
type WorkoutsResponse struct {
Page int `json:"page"`
PageCount int `json:"page_count"`
Workouts []Workout `json:"workouts"`
}
WorkoutsResponse represents the /workouts endpoint response