RVE LogoReact Video EditorDOCS
React Video Editor Documentation

Pexels Image Adapter

Integrate Pexels images with React Video Editor

Pexels Image Adapter

The Pexels image adapter integrates with the Pexels API to access their extensive photo library.

Overview

The Pexels adapter allows you to:

  • Search and browse Pexels photos
  • Download images for overlays and backgrounds
  • Access image metadata
  • Handle Pexels API authentication

Setup

First, you'll need a Pexels API key:

  1. Sign up at Pexels
  2. Get your API key from the dashboard
  3. Configure the adapter with your key

Usage

import { PexelsImageAdapter } from 'react-video-editor';

const adapter = new PexelsImageAdapter({
  apiKey: 'your-pexels-api-key'
});

// Search for images
const images = await adapter.search('landscape', {
  page: 1,
  perPage: 20
});

// Load a specific image
const image = await adapter.load('pexels-image-id');

Configuration

OptionTypeDefaultDescription
apiKeystringRequiredYour Pexels API key
baseUrlstring'https://api.pexels.com'Pexels API base URL
timeoutnumber30000Request timeout in milliseconds

API Methods

Search Images

const results = await adapter.search(query, options);
const popular = await adapter.getPopular(options);

Get Image by ID

const image = await adapter.getById(imageId);

Get Curated Images

const curated = await adapter.getCurated(options);

Search Options

OptionTypeDescription
querystringSearch term
pagenumberPage number (default: 1)
perPagenumberResults per page (max: 80)
orientation'landscape' | 'portrait' | 'square'Image orientation
size'large' | 'medium' | 'small'Image size

Error Handling

The Pexels adapter handles:

  • API rate limiting
  • Authentication errors
  • Network timeouts
  • Invalid image IDs

Examples

// Search for landscape images
const landscapeImages = await adapter.search('mountain', {
  page: 1,
  perPage: 10,
  orientation: 'landscape',
  size: 'large'
});

// Get a specific image
const image = await adapter.getById('1234567');
console.log('Image URL:', image.src.original);