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
- Workouts:
HevyClient::list_workouts,HevyClient::get_workout,HevyClient::create_workout,HevyClient::update_workout,HevyClient::workout_count,HevyClient::workout_events - Routines:
HevyClient::list_routines,HevyClient::get_routine,HevyClient::create_routine,HevyClient::update_routine - Routine folders:
HevyClient::list_routine_folders,HevyClient::get_routine_folder,HevyClient::create_routine_folder - Exercise templates:
HevyClient::list_exercise_templates,HevyClient::get_exercise_template,HevyClient::create_exercise_template - Exercise history:
HevyClient::exercise_history - Body measurements:
HevyClient::list_body_measurements,HevyClient::get_body_measurement,HevyClient::create_body_measurement,HevyClient::update_body_measurement - User:
HevyClient::get_user_info
Structs§
- Body
Measurement - A body measurement entry for a given date.
- Body
Measurements Page - A page of
BodyMeasurements, as returned bycrate::HevyClient::list_body_measurements. - Create
Exercise Template Request - The request body used to create a new custom exercise template.
- Create
Routine Folder Request - The request body used to create a new routine folder.
- Create
Routine Request - The request body used to create a new routine.
- Create
Workout Request - The request body used to create or update a workout.
- Created
Exercise Template - The response returned after successfully creating a custom exercise template.
- Exercise
- An exercise entry within a
Workout, including all logged sets. - Exercise
History Entry - A single historical set entry for a specific exercise template, as returned
by
crate::HevyClient::exercise_history. - Exercise
Template - An exercise template, either built-in or custom to the account.
- Exercise
Templates Page - A page of
ExerciseTemplates, as returned bycrate::HevyClient::list_exercise_templates. - Hevy
Client - An async client for the Hevy API.
- NewCustom
Exercise - The fields accepted when creating a new custom exercise template.
- NewRoutine
- The routine fields accepted when creating a new routine.
- NewRoutine
Folder - The routine folder fields accepted when creating a new folder.
- NewWorkout
- The workout fields accepted by the create/update workout endpoints.
- Paginated
Workout Events - A paginated list of
WorkoutEvents, as returned bycrate::HevyClient::workout_events. - RepRange
- A target rep range (e.g. “8-12 reps”) used by routine sets.
- Routine
- A saved workout routine/template.
- Routine
Exercise - An exercise entry within a
Routine. - Routine
Exercise Input - An exercise to include when creating or updating a routine.
- Routine
Folder - A folder used to organize
crate::Routines. - Routine
Folders Page - A page of
RoutineFolders, as returned bycrate::HevyClient::list_routine_folders. - Routine
Set - A set belonging to an exercise within a
Routine, as returned by the API. - Routine
SetInput - A set to include when creating or updating a routine’s exercise.
- Routines
Page - A page of
Routines, as returned bycrate::HevyClient::list_routines. - Set
- A single logged set, as returned by the API within a
Workoutorcrate::Routine. - Update
Body Measurement - The fields accepted when updating an existing body measurement entry.
- Update
Routine Request - The request body used to update an existing routine.
- Updated
Routine - The routine fields accepted when updating an existing routine.
- User
Info - Information about the authenticated Hevy user.
- Workout
- A completed workout.
- Workout
Count - The total number of workouts on the account.
- Workout
Exercise Input - An exercise to include when creating or updating a workout.
- Workout
SetInput - A set to include when creating or updating a workout.
- Workouts
Page - A page of
Workouts, as returned bycrate::HevyClient::list_workouts.
Enums§
- Custom
Exercise Type - The type of a custom exercise template.
- Equipment
Category - The equipment category used by an exercise.
- Hevy
Error - Errors that can occur while interacting with the Hevy API.
- Muscle
Group - A primary or secondary muscle group targeted by an exercise.
- SetType
- The type of a logged or planned set.
- Workout
Event - 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.