React Video Editor Documentation
Pexels Video Adapter
Integrate Pexels videos with React Video Editor
Pexels Video Adapter
The Pexels video adapter integrates with the Pexels API to access their extensive video library.
Overview
The Pexels adapter allows you to:
- Search and browse Pexels videos
- Download videos for editing
- Access video metadata
- Handle Pexels API authentication
Setup
First, you'll need a Pexels API key:
- Sign up at Pexels
- Get your API key from the dashboard
- Configure the adapter with your key
Usage
import { PexelsVideoAdapter } from 'react-video-editor';
const adapter = new PexelsVideoAdapter({
apiKey: 'your-pexels-api-key'
});
// Search for videos
const videos = await adapter.search('nature', {
page: 1,
perPage: 20
});
// Load a specific video
const video = await adapter.load('pexels-video-id');
Configuration
Option | Type | Default | Description |
---|---|---|---|
apiKey | string | Required | Your Pexels API key |
baseUrl | string | 'https://api.pexels.com' | Pexels API base URL |
timeout | number | 30000 | Request timeout in milliseconds |
API Methods
Search Videos
const results = await adapter.search(query, options);
Get Popular Videos
const popular = await adapter.getPopular(options);
Get Video by ID
const video = await adapter.getById(videoId);
Error Handling
The Pexels adapter handles:
- API rate limiting
- Authentication errors
- Network timeouts
- Invalid video IDs
Examples
// Search for nature videos
const natureVideos = await adapter.search('nature', {
page: 1,
perPage: 10,
orientation: 'landscape'
});
// Get a specific video
const video = await adapter.getById('1234567');
console.log('Video URL:', video.video_files[0].link);