SCORM API Code Examples

SCORM API Code Examples

Working code examples for integrating with the SCORM API in various languages and frameworks.

Overview

This library contains practical, tested code examples for common SCORM API use cases. All examples are production-ready and follow best practices for error handling, retry logic, and security.

Organization

Examples are organized by:

  • Language: TypeScript, JavaScript, Python, cURL
  • Framework: React, Next.js, Express.js, WordPress
  • Use Case: Upload, launch, tracking, webhooks, error handling

Quick Start

Choose your language/framework and follow the examples:

  1. TypeScript/Node.js - Server-side TypeScript examples
  2. JavaScript - Browser and Node.js JavaScript examples
  3. Python - Python client examples
  4. cURL - Command-line examples for testing
  5. Frameworks - Framework-specific examples (React, Next.js, Express, WordPress)

Common Use Cases

1. Upload a SCORM Package

2. Launch a Learning Session

3. Update CMI Data

4. Handle Version Conflicts

5. Webhook Handling

6. Error Handling with Retry

Framework Examples

React

Next.js

Express.js

WordPress

Best Practices

All examples follow these best practices:

  1. Environment Variables: API keys stored in environment variables
  2. Error Handling: Comprehensive error handling with retry logic
  3. Version Conflicts: Proper handling of optimistic locking
  4. Rate Limiting: Respect rate limits and handle 429 responses
  5. Security: Never expose API keys in client-side code
  6. Type Safety: TypeScript examples include full type definitions

Testing Examples

All examples can be tested with:

# Set your API key
export SCORM_API_KEY="your-api-key-here"
export SCORM_API_URL="https://scorm-api.allurelms.com"
export TENANT_ID="your-tenant-id"

# Run examples
npm run example:upload
npm run example:launch
npm run example:track

Contributing

When adding new examples:

  1. Follow the existing code style
  2. Include error handling
  3. Add comments explaining key concepts
  4. Test the example before submitting
  5. Update this README with links to new examples

Related Documentation


Last Updated: 2025-01-15