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:
- TypeScript/Node.js - Server-side TypeScript examples
- JavaScript - Browser and Node.js JavaScript examples
- Python - Python client examples
- cURL - Command-line examples for testing
- 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:
- 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: Never expose API keys in client-side code
- 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:
- 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
- Integration Guides - Platform-specific guides
- Error Codes - Error handling reference
Last Updated: 2025-01-15