Skip to main content

Crate hevy

Crate hevy 

Source
Expand description

An async Rust client for the Hevy API.

Hevy is a workout tracking app; this crate wraps its public REST API, giving you typed access to workouts, routines, routine folders, exercise templates, exercise history, body measurements, and user info.

§Getting started

Get an API key from https://hevy.com/settings?developer (requires Hevy Pro), then construct a HevyClient and call its methods:

use hevy::{CreateWorkoutRequest, HevyClient, NewWorkout, WorkoutExerciseInput, WorkoutSetInput};

let client = HevyClient::new("YOUR_API_KEY");

// List the first page of workouts.
let page = client.list_workouts(Some(1), Some(5)).await?;
for workout in &page.workouts {
    println!("{}: {}", workout.id, workout.title);
}

// Log a new workout.
let workout = NewWorkout::new(
    "Friday Leg Day",
    "2024-08-14T12:00:00Z",
    "2024-08-14T12:30:00Z",
)
.with_exercise(
    WorkoutExerciseInput::new("D04AC939").with_set(WorkoutSetInput::normal(100.0, 10)),
);
let created = client.create_workout(&CreateWorkoutRequest::new(workout)).await?;
println!("Created workout {}", created.id);

§Error handling

All fallible operations return Result<T>, with failures represented by HevyError. Non-2xx responses are surfaced as HevyError::Api, carrying the HTTP status code and, when available, the API’s error message.

§Resource groups

Structs§

BodyMeasurement
A body measurement entry for a given date.
BodyMeasurementsPage
A page of BodyMeasurements, as returned by crate::HevyClient::list_body_measurements.
CreateExerciseTemplateRequest
The request body used to create a new custom exercise template.
CreateRoutineFolderRequest
The request body used to create a new routine folder.
CreateRoutineRequest
The request body used to create a new routine.
CreateWorkoutRequest
The request body used to create or update a workout.
CreatedExerciseTemplate
The response returned after successfully creating a custom exercise template.
Exercise
An exercise entry within a Workout, including all logged sets.
ExerciseHistoryEntry
A single historical set entry for a specific exercise template, as returned by crate::HevyClient::exercise_history.
ExerciseTemplate
An exercise template, either built-in or custom to the account.
ExerciseTemplatesPage
A page of ExerciseTemplates, as returned by crate::HevyClient::list_exercise_templates.
HevyClient
An async client for the Hevy API.
NewCustomExercise
The fields accepted when creating a new custom exercise template.
NewRoutine
The routine fields accepted when creating a new routine.
NewRoutineFolder
The routine folder fields accepted when creating a new folder.
NewWorkout
The workout fields accepted by the create/update workout endpoints.
PaginatedWorkoutEvents
A paginated list of WorkoutEvents, as returned by crate::HevyClient::workout_events.
RepRange
A target rep range (e.g. “8-12 reps”) used by routine sets.
Routine
A saved workout routine/template.
RoutineExercise
An exercise entry within a Routine.
RoutineExerciseInput
An exercise to include when creating or updating a routine.
RoutineFolder
A folder used to organize crate::Routines.
RoutineFoldersPage
A page of RoutineFolders, as returned by crate::HevyClient::list_routine_folders.
RoutineSet
A set belonging to an exercise within a Routine, as returned by the API.
RoutineSetInput
A set to include when creating or updating a routine’s exercise.
RoutinesPage
A page of Routines, as returned by crate::HevyClient::list_routines.
Set
A single logged set, as returned by the API within a Workout or crate::Routine.
UpdateBodyMeasurement
The fields accepted when updating an existing body measurement entry.
UpdateRoutineRequest
The request body used to update an existing routine.
UpdatedRoutine
The routine fields accepted when updating an existing routine.
UserInfo
Information about the authenticated Hevy user.
Workout
A completed workout.
WorkoutCount
The total number of workouts on the account.
WorkoutExerciseInput
An exercise to include when creating or updating a workout.
WorkoutSetInput
A set to include when creating or updating a workout.
WorkoutsPage
A page of Workouts, as returned by crate::HevyClient::list_workouts.

Enums§

CustomExerciseType
The type of a custom exercise template.
EquipmentCategory
The equipment category used by an exercise.
HevyError
Errors that can occur while interacting with the Hevy API.
MuscleGroup
A primary or secondary muscle group targeted by an exercise.
SetType
The type of a logged or planned set.
WorkoutEvent
A workout event indicating either an update or a deletion, as returned by crate::HevyClient::workout_events.

Constants§

DEFAULT_BASE_URL
The default base URL for the Hevy API.

Type Aliases§

Result
The result type returned by all fallible operations in this crate.