@modelhealth/modelhealth
    Preparing search index...

    @modelhealth/modelhealth

    Model Health SDK for TypeScript

    TypeScript/JavaScript SDK for the Model Health biomechanics platform.

    • 📦 Type-safe: Full TypeScript type definitions
    • 🌐 Cross-platform: Works in browsers, Node.js, React, Vue, Svelte, etc.
    • 🔒 API key authentication: Use your Model Health API key
    • Fast: WASM performance with JavaScript ergonomics
    npm install @modelhealth/modelhealth
    
    import { ModelHealthService } from '@modelhealth/modelhealth';

    const client = new ModelHealthService({
    apiKey: 'your-api-key-here',
    });
    await client.init();

    const sessions = await client.sessionList();
    console.log(sessions);
    const client = new ModelHealthService({
    apiKey: 'your-api-key',
    autoInit: false, // Call init() manually when ready
    });
    // Get all sessions
    const sessions = await client.sessionList();

    // Get specific session with trials
    const session = await client.getSession('session-id');

    // Create new session
    const newSession = await client.createSession();
    // Get all subjects
    const subjects = await client.subjectList();
    // Get trials for a session
    const trials = await client.trialList('session-id');

    // Download trial videos
    const videos = await client.downloadTrialVideos(
    trial,
    'raw' // or 'synced'
    );

    // Download result data
    const results = await client.downloadTrialResultData(
    trial,
    ['motData', 'csvData']
    );
    // Convert MOT to CSV
    const motData = new Uint8Array([...]); // MOT file data
    const csv = ModelHealthService.motToCsv(motData);
    import { useState, useEffect } from 'react';
    import { ModelHealthService, Session } from '@modelhealth/modelhealth';

    function App() {
    const [client] = useState(
    () => new ModelHealthService({ apiKey: 'your-api-key' })
    );
    const [sessions, setSessions] = useState<Session[]>([]);
    const [loading, setLoading] = useState(true);

    useEffect(() => {
    async function init() {
    await client.init();
    const data = await client.sessionList();
    setSessions(data);
    setLoading(false);
    }

    init();
    }, [client]);

    if (loading)
    return <div>Loading...</div>;

    return (
    <div>
    <h1>Sessions</h1>
    {sessions.map(session => (
    <div key={session.id}>{session.name}</div>
    ))}
    </div>
    );
    }

    If using Vite, add WASM support:

    // vite.config.ts
    import { defineConfig } from 'vite';
    import wasm from 'vite-plugin-wasm';
    import topLevelAwait from 'vite-plugin-top-level-await';

    export default defineConfig({
    plugins: [
    wasm(),
    topLevelAwait(),
    ],
    });

    Install plugins:

    npm install -D vite-plugin-wasm vite-plugin-top-level-await
    

    All types are fully documented with JSDoc comments. Import types as needed:

    import type {
    Session,
    Subject,
    Trial,
    CheckerboardDetails,
    // ... etc
    } from '@modelhealth/modelhealth';
    # Install dependencies
    npm install

    # Build WASM and TypeScript
    npm run build

    # Development build with watch mode
    npm run dev
    • Node.js 18+
    • Rust 1.70+
    • wasm-pack (cargo install wasm-pack)
    • ✅ Modern browsers (Chrome, Firefox, Safari, Edge)
    • ✅ Node.js 18+ (with WASM support)
    • ✅ React, Vue, Svelte, Angular
    • ✅ React Native (with WASM bridge)
    • ✅ Electron

    All async methods can throw errors. Always use try-catch:

    try {
    const sessions = await client.sessionList();
    } catch (error) {
    console.error('Request failed:', error);
    }

    Apache-2.0 © Model Health