Buyer Guides

Video API Implementation Guide

Implementation determines whether your video enhancement investment succeeds. This guide covers integration best practices, phased rollout, and common pitfalls.

Implementation Phases

Phase 1: Sandbox (Week 1)

  • Get API credentials
  • First successful API call
  • Understand request/response format
  • Test error handling

Phase 2: Integration (Weeks 2-3)

  • Integrate into your application
  • Implement webhook handling
  • Build UI components
  • Internal testing

Phase 3: Pilot (Week 4)

  • Deploy to staging/production
  • Enable for subset of users (5-10%)
  • Monitor closely
  • Gather feedback

Phase 4: Rollout (Weeks 5-6)

  • Gradual rollout (25%, 50%, 100%)
  • Monitor at each stage
  • Address issues before scaling

Phase 5: Optimization (Ongoing)

  • Performance tuning
  • Cost optimization
  • Feature expansion

Integration Patterns

Async Webhook (Recommended)

# Submit job
response = bv.enhance(video_url)
job_id = response.job_id

# Webhook handler
@app.post("/webhooks/bettervideo")
def handle_webhook(payload):
    if payload.event == "job.completed":
        update_video(payload.job_id, payload.output_url)

Polling (Alternative)

# Submit job
response = bv.enhance(video_url)
job_id = response.job_id

# Poll for completion
while True:
    status = bv.get_job(job_id)
    if status.state == "completed":
        break
    time.sleep(30)

Batch Processing

# Submit multiple jobs
for video in videos:
    bv.enhance(video.url, webhook_url=webhook)

# Process webhooks as they arrive
# No need to track individual jobs

Error Handling

API Errors

try:
    response = bv.enhance(video_url)
except RateLimitError:
    # Back off and retry
    time.sleep(60)
    retry()
except ValidationError as e:
    # Invalid input - don't retry
    log_error(e)
    notify_user("Invalid video format")
except ServerError:
    # Transient error - retry with backoff
    retry_with_backoff()

Webhook Failures

  • Return 2xx quickly (within 30 seconds)
  • Process asynchronously if needed
  • Implement idempotency (same webhook may fire twice)
  • Store payload for debugging

Job Failures

  • Check failure reason in webhook
  • Automatic retry for transient errors
  • Notify user for permanent failures
  • Log for debugging

Monitoring

Key Metrics

  • Success rate: Jobs completed / jobs submitted
  • Latency: Time from submit to complete
  • Error rate: By error type
  • Volume: Jobs per hour/day
  • Cost: Running cost tracking

Alerting

  • Success rate < 99%
  • Latency > 2x baseline
  • Error rate spike
  • Webhook delivery failures

Dashboard

  • Real-time job status
  • Historical success rate
  • Cost tracking
  • Error breakdown

Common Pitfalls

Webhook Handling

  • Problem: Webhook times out because handler is slow
  • Solution: Acknowledge immediately, process async

Idempotency

  • Problem: Duplicate jobs from retries
  • Solution: Use idempotency keys

Error Handling

  • Problem: Silent failures
  • Solution: Log all errors, alert on patterns

Testing

  • Problem: Works in dev, fails at scale
  • Solution: Load test before launch

Cost Control

  • Problem: Unexpected bills
  • Solution: Set up usage alerts

Frequently Asked Questions

2-4 weeks for basic integration. 4-6 weeks for full production rollout with monitoring and optimization.

Webhooks for most cases — more efficient and real-time. Polling if webhooks aren't possible in your environment.

Not handling webhooks properly. Return 2xx quickly, process async, implement idempotency.

Ready to get started?

Try BetterVideo's privacy-first video enhancement API — free sandbox, no credit card required.