Skip to main content

Quick Start

This guide walks you through a complete Model Health SDK integration — from initialization to retrieving biomechanical data.

Prerequisites

Before you begin, make sure you have:

  1. Installed the SDK
  2. An API key — if you don't have one yet, request access

Overview

A typical flow looks like this:

  1. Initialize the SDK with your API key
  2. Create and configure a session
  3. Calibrate the camera (once per session setup)
  4. Calibrate the subject (biomechanical model scaling)
  5. Record a movement
  6. Run analysis and retrieve results

Quick Start

import ModelHealth

// Initialize the service with your API key
let service = try ModelHealthService(apiKey: "your-api-key-here")

// Create a session
let session = try await service.createSession()

// Calibrate camera
let checkerboardDetails = CheckerboardDetails(
rows: 4,
columns: 5,
squareSize: 35,
placement: .perpendicular
)

try await service.calibrateCamera(
session,
checkerboardDetails: checkerboardDetails
) { status in
print("Calibration status: \(status)")
}

// Select first subject and calibrate it
let subjects = try await service.subjectList()
if let subject = subjects.first {
try await service.calibrateSubject(
subject,
in: session
) { status in
print("Neutral pose status: \(status)")
}
}

// Record an activity
let activity = try await service.startRecording(activityNamed: "cmj", in: session)
// Subject performs the activity...
try await service.stopRecording(session)

// Check processing status
let status = try await service.activityStatus(for: activity)
if case .ready = status {
// Start analysis
let task = try await service.startAnalysis(
.counterMovementJump,
for: activity,
in: session
)

// Poll for completion
var analysisStatus = try await service.analysisStatus(for: task)
while case .processing = analysisStatus {
try await Task.sleep(nanoseconds: 10_000_000_000) // 10 seconds
analysisStatus = try await service.analysisStatus(for: task)
}

// Download results
if case .completed = analysisStatus {
let results = await service.analysisData(
ofType: [.metrics, .report],
for: activity
)
for result in results {
switch result.type {
case .metrics:
print("Metrics:", String(data: result.data, encoding: .utf8) ?? "")
case .report:
// PDF – use result.data
break
case .data:
break
}
}
}
}

Next Steps