Data Models
Reference for the data structures returned by the Content API.
WorkoutModel:
| Field | Type | Description |
| id | String | Unique identifier |
| title | String | Workout name |
| category | String | Fitness or Rehabilitation |
| calories | Int? | Estimated calories burned |
| totalMinutes | Int? | Total duration in minutes |
| bodyParts | [String] | Targeted body parts |
| difficultyLevel | String? | Difficulty level |
| description | String | Workout description |
| imgURL | String | Workout thumbnail image |
| sequence | [ExerciseModel] | List of exercises |
ExerciseModel:
| Field | Type | Description |
| id | String | Unique identifier |
| title | String | Exercise name |
| bodyParts | [String] | Targeted body parts |
| videoURL | String | Demo video URL |
| thumbnailURL | String | Thumbnail image URL |
| modelId | String | Motion tracking model ID (use in Camera Component) |
| description | String | Exercise description |
| steps | [String] | Step-by-step instructions |
| commonMistakes | String | Common mistakes to avoid |
| tips | String | Tips for proper form |
PlanModel:
| Field | Type | Description |
| id | String | Unique identifier |
| title | String | Plan name |
| imgURL | String | Plan thumbnail image |
| category | PlanModelCategory | Category with description and levels |
| levels | [String: PlanLevel] | Dictionary of levels (1, 2, 3, etc.) |
| createdBy | String | Creator identifier |
PlanLevel:
| Field | Type | Description |
| title | String | Level title |
| description | String | Level description |
| days | [String: PlanDay] | Dictionary of days |
PlanDay:
| Field | Type | Description |
| title | String | Day title |
| description | String | Day description |
| workouts | [WorkoutSummary]? | List of workouts for this day |
Working with Models
1// Accessing workout model properties
2Task {
3 let result = await kinestex.fetchWorkout(id: "9zE1kzOzpU5d5dAJrPOY")
4
5 switch result {
6 case .success(let workout):
7 // Basic properties
8 print("Title: \(workout.title)")
9 print("Category: \(workout.category ?? "N/A")")
10 print("Duration: \(workout.totalMinutes ?? 0) minutes")
11 print("Calories: \(workout.totalCalories ?? 0)")
12 print("Difficulty: \(workout.difficultyLevel ?? "N/A")")
13
14 // Body parts
15 print("Targets: \(workout.bodyParts.joined(separator: ", "))")
16
17 // Exercise sequence
18 print("\nExercises (\(workout.sequence.count)):")
19 for (index, exercise) in workout.sequence.enumerated() {
20 print("\(index + 1). \(exercise.title)")
21 print(" Model ID: \(exercise.modelId)") // Use for Camera Component
22 print(" Reps: \(exercise.workoutReps ?? exercise.averageReps ?? 0)")
23 }
24
25 // Access raw JSON if needed
26 if let rawJSON = workout.rawJSON {
27 print("\nRaw JSON available: \(rawJSON.keys.count) keys")
28 }
29
30 case .failure(let error):
31 print("Error: \(error.localizedDescription)")
32 }
33}
34
35// Working with plan structure
36Task {
37 let result = await kinestex.fetchPlan(id: "22B3qRU2r75hVXHgGiGx")
38
39 switch result {
40 case .success(let plan):
41 print("Plan: \(plan.title)")
42 print("Category: \(plan.category.description)")
43
44 // Iterate through levels
45 for (levelKey, level) in plan.levels {
46 print("\nLevel \(levelKey): \(level.title)")
47
48 // Iterate through days
49 for (dayKey, day) in level.days {
50 print(" Day \(dayKey): \(day.title)")
51
52 // List workouts for this day
53 if let workouts = day.workouts {
54 for workout in workouts {
55 print(" - \(workout.title) (\(workout.totalMinutes) min)")
56 }
57 }
58 }
59 }
60
61 case .failure(let error):
62 print("Error: \(error.localizedDescription)")
63 }
64}