GarminRunerz.Workout.Models
1.1.0
dotnet add package GarminRunerz.Workout.Models --version 1.1.0
NuGet\Install-Package GarminRunerz.Workout.Models -Version 1.1.0
<PackageReference Include="GarminRunerz.Workout.Models" Version="1.1.0" />
<PackageVersion Include="GarminRunerz.Workout.Models" Version="1.1.0" />
<PackageReference Include="GarminRunerz.Workout.Models" />
paket add GarminRunerz.Workout.Models --version 1.1.0
#r "nuget: GarminRunerz.Workout.Models, 1.1.0"
#:package GarminRunerz.Workout.Models@1.1.0
#addin nuget:?package=GarminRunerz.Workout.Models&version=1.1.0
#tool nuget:?package=GarminRunerz.Workout.Models&version=1.1.0
GarminRunerz.Workout.Models
A .NET library providing comprehensive data models for Garmin workout structures. This library enables developers to work with Garmin workout data in a strongly-typed manner, supporting JSON serialization and deserialization.
Overview
GarminRunerz.Workout.Models is designed to represent the complete data structure of Garmin workouts, including workout metadata, segments, steps, and all associated properties. The models are optimized for working with Garmin Connect's workout data format.
Features
- Complete Workout Representation: Full model coverage for Garmin workout data structures
- JSON Serialization: Built-in support for JSON serialization/deserialization using System.Text.Json
- Strongly Typed: Type-safe models with comprehensive property definitions
- Nullable Support: Proper handling of optional properties with nullable reference types
- NuGet Package: Available as a .NET package for easy integration
Installation
Install the package via NuGet Package Manager:
Install-Package GarminRunerz.Workout.Models
Or via .NET CLI:
dotnet add package GarminRunerz.Workout.Models
Quick Start
Basic Usage
using GarminRunerz.Workout.Models;
using System.Text.Json;
// Deserialize from JSON
string jsonData = "{ ... }"; // Your workout JSON data
Workout workout = JsonSerializer.Deserialize<Workout>(jsonData);
// Access workout properties
Console.WriteLine($"Workout: {workout.WorkoutName}");
Console.WriteLine($"Description: {workout.Description}");
Console.WriteLine($"Sport: {workout.SportType?.SportTypeKey}");
// Work with workout segments
foreach (var segment in workout.WorkoutSegments ?? [])
{
Console.WriteLine($"Segment Order: {segment.SegmentOrder}");
Console.WriteLine($"Sport Type: {segment.SportType?.SportTypeKey}");
// Process workout steps in each segment
foreach (var step in segment.WorkoutSteps ?? [])
{
Console.WriteLine($"Step: {step.Description}");
Console.WriteLine($"Step Type: {step.StepType?.StepTypeKey}");
Console.WriteLine($"End Condition: {step.EndCondition?.ConditionTypeKey}");
}
}
Creating a Workout
var workout = new Workout
{
WorkoutName = "Morning Run",
Description = "Easy 5K run with warm-up and cool-down",
SportType = new SportType
{
SportTypeId = 1,
SportTypeKey = "running"
},
EstimatedDurationInSecs = 1800, // 30 minutes
Author = new Author
{
DisplayName = "Runner123",
FullName = "John Doe"
},
WorkoutSegments = new List<WorkoutSegment>
{
new WorkoutSegment
{
SegmentOrder = 1,
SportType = new SportType { SportTypeKey = "running" },
WorkoutSteps = new List<WorkoutStep>
{
new WorkoutStep
{
StepOrder = 1,
Description = "Warm-up",
StepType = new StepType { StepTypeKey = "warmup" },
EndCondition = new EndCondition { ConditionTypeKey = "time" },
EndConditionValue = 300 // 5 minutes
}
}
}
}
};
// Serialize to JSON
string json = JsonSerializer.Serialize(workout, new JsonSerializerOptions
{
WriteIndented = true
});
Data Models
Core Models
Workout
The main workout container that includes all workout metadata and segments.
Key Properties:
WorkoutId
: Unique identifier for the workoutWorkoutName
: Display name of the workoutDescription
: Detailed descriptionSportType
: The primary sport type for this workoutAuthor
: Information about the workout creatorWorkoutSegments
: List of workout segmentsEstimatedDurationInSecs
: Estimated workout durationEstimatedDistanceInMeters
: Estimated distance (if applicable)
WorkoutSegment
Represents a segment within a workout, typically used for multi-sport workouts.
Key Properties:
SegmentOrder
: Order of this segment in the workoutSportType
: Sport type for this specific segmentWorkoutSteps
: List of steps within this segmentEstimatedDurationInSecs
: Estimated duration for this segment
WorkoutStep
Individual step within a workout segment, representing a specific exercise or activity phase.
Key Properties:
StepOrder
: Order of this step within the segmentStepType
: Type of step (interval, rest, warmup, etc.)Description
: Human-readable descriptionEndCondition
: Condition that determines when the step endsEndConditionValue
: Value associated with the end conditionTargetType
: Type of target (heart rate, pace, power, etc.)TargetValueOne/Two
: Target range valuesNumberOfIterations
: For repeat steps
Supporting Models
Author
Information about the workout creator.
SportType
Defines the sport/activity type (running, cycling, swimming, etc.).
EndCondition
Defines how a workout step should end (time, distance, heart rate, etc.).
TargetType
Defines the target metric for a workout step (heart rate zone, pace, power, etc.).
StepType
Categorizes the type of workout step (warmup, interval, rest, cooldown, etc.).
EquipmentType
Specifies required equipment for specific steps.
StrokeType
For swimming workouts, specifies the stroke type.
EstimatedDistanceUnit
Unit of measurement for estimated distances.
JSON Structure Example
{
"workoutId": 12345,
"workoutName": "5K Training Run",
"description": "Interval training for 5K improvement",
"sportType": {
"sportTypeId": 1,
"sportTypeKey": "running",
"displayOrder": 1
},
"author": {
"userProfilePk": 67890,
"displayName": "TrainingCoach",
"fullName": "Jane Smith"
},
"estimatedDurationInSecs": 2400,
"workoutSegments": [
{
"segmentOrder": 1,
"sportType": {
"sportTypeKey": "running"
},
"workoutSteps": [
{
"stepOrder": 1,
"description": "Warm-up jog",
"stepType": {
"stepTypeKey": "warmup"
},
"endCondition": {
"conditionTypeKey": "time"
},
"endConditionValue": 600,
"targetType": {
"workoutTargetTypeKey": "heart.rate.zone"
},
"targetValueOne": 2
}
]
}
]
}
Requirements
- .NET 8.0 or higher
- System.Text.Json (included in .NET)
Contributing
Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.
License
This project is open source. Please refer to the license file for more information.
Related Projects
This library is part of the GarminRunerz ecosystem for working with Garmin fitness data.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- No dependencies.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.1.0 | 2 | 9/15/2025 |