Working code examples for integrating with the SCORM API in various languages and frameworks.
Overview
This library contains practical code examples for common SCORM API use cases. Server-side samples keep API keys in environment variables. Browser-oriented snippets (e.g. some React demos) are illustrative; route API calls through your backend or a serverless proxy so secrets never ship to end users.
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:
- TypeScript/Node.js (opens in a new tab) - Server-side TypeScript examples
- JavaScript (opens in a new tab) - Browser and Node.js JavaScript examples
- Python (opens in a new tab) - Python client examples
- cURL (opens in a new tab) - Command-line examples for testing
- Frameworks (opens in a new tab) - Framework-specific examples (React, Next.js, Express, WordPress)
Common Use Cases
1. Upload a SCORM Package
- TypeScript (opens in a new tab)
- JavaScript (opens in a new tab)
- Python (opens in a new tab)
- cURL (opens in a new tab)
2. Launch a Learning Session
- TypeScript (opens in a new tab)
- JavaScript (opens in a new tab)
- Python (opens in a new tab)
- cURL (opens in a new tab)
3. Update CMI Data
4. Handle Version Conflicts
5. Webhook Handling
6. Error Handling with Retry
Framework Examples
React
- SCORM Player Component (opens in a new tab)
- Session Tracker Hook (opens in a new tab)
- Package Upload Component (opens in a new tab)
Next.js
- API Route Handler (opens in a new tab)
- Server Component (opens in a new tab)
- Client Component (opens in a new tab)
Express.js
- Middleware (opens in a new tab)
- Route Handlers (opens in a new tab)
- Error Handler (opens in a new tab)
WordPress
Best Practices
All examples follow these best practices:
- Environment Variables: API keys stored in environment variables
- Error Handling: Comprehensive error handling with retry logic
- Version Conflicts: Proper handling of optimistic locking
- Rate Limiting: Respect rate limits and handle 429 responses
- Security: Prefer server-side calls for authenticated routes; never commit real API keys
- Type Safety: TypeScript examples include full type definitions
Testing Examples
Clone the repository, set CONNECT_API_KEY, CONNECT_API_BASE_URL, and CONNECT_TENANT_ID, then run the chosen file with the language runtime shown in that example. The repository does not expose generic npm run example:* scripts.
Contributing
When adding new examples:
- Follow the existing code style
- Include error handling
- Add comments explaining key concepts
- Test the example before submitting
- Update this README with links to new examples
Related Documentation
- API Reference - Complete endpoint documentation
- Getting Started - Quick start guide
- Custom LMS Integration - Platform integration guide
- Error Codes - Error handling reference