# Getting Started

Before using the Content API, ensure your SDK is properly initialized. The API methods are only available after initialization.

**For SDK platforms (Swift, Kotlin, Flutter):** Initialize the SDK with your credentials
**For REST platforms (React Native, React TypeScript, HTML/JS):** Set up your request headers

**Initialize SDK / Setup Headers**

_Swift (iOS)_
```swift
import KinesteXAIKit

// Initialize KinesteXAIKit with your credentials
let kinestex = KinesteXAIKit(
    apiKey: "YOUR_API_KEY",
    companyName: "YOUR_COMPANY",
    userId: "user_123"
)

// Now you can use the Content API methods:
// - kinestex.fetchWorkouts()
// - kinestex.fetchPlans()
// - kinestex.fetchExercises()
// - kinestex.fetchWorkout(id:)
// - kinestex.fetchPlan(id:)
// - kinestex.fetchExercise(id:)
// - kinestex.fetchContent(contentType:, ...)
```

_Kotlin (Android)_
```kotlin
import com.kinestex.kinestexsdkkotlin.KinesteXSDK

// SDK must be initialized before using Content API
// This is typically done in your Application class or Activity

// Access Content API through KinesteXSDK.api
// Available method:
// KinesteXSDK.api.fetchAPIContentData(
//     contentType: ContentType,
//     id: String? = null,
//     title: String? = null,
//     category: String? = null,
//     bodyParts: List<BodyPart>? = null,
//     lastDocId: String? = null,
//     limit: Int? = null
// ): APIContentResult
```

_Flutter_
```dart
import 'package:kinestex_sdk_flutter/kinestex_sdk.dart';

// Initialize the SDK before using Content API
await KinesteXAIFramework.initialize(
  apiKey: "YOUR_API_KEY",
  companyName: "YOUR_COMPANY",
  userId: "user_123",
);

// Access Content API through:
// KinesteXAIFramework.apiService.fetchContent(...)
```

_React Native_
```jsx
// Set up headers for REST API calls
const API_KEY = 'YOUR_API_KEY';
const COMPANY_NAME = 'YOUR_COMPANY';
const BASE_URL = 'https://admin.kinestex.com/api/v1';

const headers = {
  'x-api-key': API_KEY,
  'x-company-name': COMPANY_NAME,
};

// Use these headers in all fetch requests
```

_HTML / JavaScript_
```html
// Set up headers for REST API calls
const API_KEY = 'YOUR_API_KEY';
const COMPANY_NAME = 'YOUR_COMPANY';
const BASE_URL = 'https://admin.kinestex.com/api/v1';

const headers = {
  'x-api-key': API_KEY,
  'x-company-name': COMPANY_NAME,
};

// Use these headers in all fetch requests
```

_React (TypeScript)_
```tsx
// Set up headers for REST API calls
const API_KEY = 'YOUR_API_KEY';
const COMPANY_NAME = 'YOUR_COMPANY';
const BASE_URL = 'https://admin.kinestex.com/api/v1';

const headers: HeadersInit = {
  'x-api-key': API_KEY,
  'x-company-name': COMPANY_NAME,
};

// TypeScript interfaces for API responses
interface WorkoutModel {
  id: string;
  title: string;
  category: string;
  calories: number;
  total_minutes: number;
  body_parts: string[];
  dif_level: string;
  description: string;
  workout_desc_img: string;
  sequence: ExerciseModel[];
}

interface ExerciseModel {
  id: string;
  title: string;
  body_parts: string[];
  video_url: string;
  thumbnail_url: string;
  model_id: string;
}

interface PlanModel {
  id: string;
  title: string;
  img_url: string;
  category: Record<string, any>;
  levels: Record<string, any>;
}
```

**Available SDK Methods** — Swift (iOS)

KinesteXAIKit provides convenient methods that handle all the complexity of API calls for you.

_Convenience Methods (Recommended)_
```swift
// Fetch lists with optional filters
func fetchWorkouts(category: String? = nil, bodyParts: [BodyPart]? = nil, limit: Int? = 10, lastDocId: String? = nil, lang: String = "en") async -> Result<WorkoutsResponse, Error>

func fetchExercises(bodyParts: [BodyPart]? = nil, limit: Int? = 10, lastDocId: String? = nil, lang: String = "en") async -> Result<ExercisesResponse, Error>

func fetchPlans(category: String? = nil, limit: Int? = 10, lastDocId: String? = nil, lang: String = "en") async -> Result<PlansResponse, Error>

// Fetch single items by ID
func fetchWorkout(id: String, lang: String = "en") async -> Result<WorkoutModel, Error>
func fetchExercise(id: String, lang: String = "en") async -> Result<ExerciseModel, Error>
func fetchPlan(id: String, lang: String = "en") async -> Result<PlanModel, Error>
```

_Advanced Method (Full Control)_
```swift
// Use fetchContent for advanced filtering or when you need the raw result type
func fetchContent(
    contentType: ContentType,  // .workout, .plan, .exercise
    id: String? = nil,
    title: String? = nil,
    lang: String = "en",
    category: String? = nil,
    bodyParts: [BodyPart]? = nil,
    lastDocId: String? = nil,
    limit: Int? = nil
) async -> APIContentResult
```

**ContentType Enum** — Kotlin (Android)

Use these values to specify what type of content to fetch.

_Available Content Types_
```kotlin
enum class ContentType {
    WORKOUT,  // Fetch workouts
    PLAN,     // Fetch workout plans
    EXERCISE  // Fetch exercises
}
```

**ContentType Enum** — Flutter

Use these values to specify what type of content to fetch.

_Available Content Types_
```dart
enum ContentType {
  workout,   // Fetch workouts
  plan,      // Fetch workout plans
  exercise   // Fetch exercises
}
```

---
Source: https://kinestex.com/docs/content-api/content-api-initialization · Index: https://kinestex.com/llms.txt
