Table of Contents
- Code Examples Overview
- Available Languages
- [Ruby/Rails Integration](/docs/examples/ruby)
- [Python Integration](/docs/examples/python)
- [JavaScript/Node.js Integration](/docs/examples/javascript)
- [cURL Command Examples](/docs/examples/curl)
- Key Features Covered
- Common Error Patterns
- Insufficient Credits
- Rate Limiting
- Validation Errors
- Micro-Precision Currency
- Quick Start Guide
- Production Checklist
- Need Help?
Code Examples Overview
Ready-to-use code examples for integrating with MediaConvert.io API. All examples include comprehensive error handling, retry logic, and production-ready patterns.
Available Languages
Ruby/Rails Integration
Complete Ruby SDK integration with Rails-specific patterns:
- ActiveJob integration for background processing
- Model integration with ActiveRecord
- Webhook handling with signature verification
- Batch processing with concurrent job management
- Circuit breaker patterns for resilience
- Comprehensive error handling for all scenarios
- Testing patterns with RSpec and Minitest
Python Integration
Python SDK with Django and Flask integration:
- Django model integration with Celery background jobs
- Flask application factory patterns
- Async processing with asyncio
- S3 integration helpers for seamless file handling
- Comprehensive error handling with retry strategies
- Memory-efficient batch processing
- Testing with pytest and unittest
JavaScript/Node.js Integration
Full-stack JavaScript integration for modern applications:
- Node.js Express.js server-side integration
- React and Vue.js frontend components
- TypeScript support with comprehensive type definitions
- Background job processing with Bull queue
- Browser and server-side implementations
- Webhook handling with signature verification
- Performance optimization with connection pooling
cURL Command Examples
Direct API usage for scripting and debugging:
- Complete bash scripts with error handling
- Batch processing workflows
- Monitoring and job status checking
- Webhook testing and signature verification
- Environment setup and configuration scripts
- Production-ready shell scripting patterns
Key Features Covered
All example sets include:
- Authentication: API token management and secure configuration
- Error Handling: Comprehensive patterns for all error types
- Retry Logic: Exponential backoff and rate limit handling
- Monitoring: Progress tracking and job status monitoring
- Webhooks: Signature verification and event handling
- Batch Processing: Efficient processing of multiple files
- Testing: Unit tests, integration tests, and mocking patterns
- S3 Integration: Presigned URL generation and file handling
- Production Patterns: Circuit breakers, connection pooling, caching
Common Error Patterns
Insufficient Credits
{
"error": "insufficient_credits",
"required_credits_micros": 3150000, // €3.15
"available_credits_micros": 500000 // €0.50
}
Rate Limiting
{
"error": "rate_limit_exceeded",
"retry_after": 60,
"limit": 100,
"remaining": 0
}
Validation Errors
{
"error": "validation_failed",
"errors": [
"input_format 'txt' is not supported for job_type 'video'",
"input_size_bytes is required"
]
}
Micro-Precision Currency
All examples demonstrate MediaConvert.io's micro-precision currency system:
- Storage: All amounts stored as integers in micros (1/1,000,000 of currency unit)
- Precision: 6 decimal places for accurate billing calculations
- API Response: Both micro values (recommended) and legacy cent values provided
- Example: €0.001575 = 1,575 micros = 0.16 cents (rounded)
// Micro-precision (recommended)
console.log(`Cost: €${job.costMicros / 1_000_000}`); // €0.001575
// Legacy cents (backward compatibility)
console.log(`Cost: €${job.costCents / 100}`); // €0.00
Quick Start Guide
- Choose Your Language: Select the integration guide for your preferred language
- Configure Authentication: Set up API token and base URL
- Copy Examples: Use copy-paste ready code snippets
- Handle Errors: Implement comprehensive error handling patterns
- Add Webhooks: Set up real-time notifications for job completion
- Test Integration: Use provided test patterns and mock helpers
Production Checklist
Before going live, ensure you have:
- ✅ Error Handling: All error types handled with appropriate user feedback
- ✅ Rate Limiting: Proper retry logic with exponential backoff
- ✅ Webhook Security: Signature verification implemented
- ✅ Job Monitoring: Progress tracking and timeout handling
- ✅ Credit Management: Low balance notifications and auto-refill setup
- ✅ Testing: Unit tests and integration tests in place
- ✅ Logging: Comprehensive logging for debugging production issues
- ✅ Monitoring: Health checks and alerting for your integration
Need Help?
- API Reference: Complete API Documentation
- Webhook Guide: Real-time Notifications
- Authentication Guide: API Token Management
- Support: support@mediaconvert.io