# pexels-scraper (`knobby_wallpaper/pexels-scraper`) Actor

Extract stock videos and images in bulk from Pexels using the official fast, reliable API.

- **URL**: https://apify.com/knobby\_wallpaper/pexels-scraper.md
- **Developed by:** [Apex Data Solutions](https://apify.com/knobby_wallpaper) (community)
- **Categories:** Automation, Developer tools, Videos
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Pexels Video & Image Bulk Scraper

The most reliable, high-performance, and cost-effective Apify Actor for downloading high-quality stock videos and images in bulk from Pexels. Designed specifically for AI video generators, faceless content creators, and marketing automation pipelines.

---

### 🚀 Why Use This Scraper?

Unlike standard scrapers that try to scrape Pexels' web pages directly—which leads to frequent IP blocks, slow page loads, and Cloudflare 403 Forbidden errors—this Actor is built on top of the **official Pexels REST API**. 

*   **100% Ban-Free & Reliable**: Zero scraping blocks, no CAPTCHAs, and no proxies needed.
*   **Insanely Fast**: Crawls and structures hundreds of videos and images in seconds.
*   **Direct MP4 Links**: Extracts direct high-resolution `.mp4` video downloads and direct image URLs. No page crawling, no scraping, just pure direct media URLs ready for download or AI models.
*   **No Pexels Account Required**: Comes with a built-in fallback API key so you can start scraping immediately. You can also provide your own free key (which gives you 25,000 free requests per month) for heavy scaling.

---

### 🛠️ Configuration Options

This Actor is highly customizable. In the Apify Console, you can configure:

*   `query` (String, **Required**): The keyword you want to search (e.g., `nature`, `cyberpunk`, `meditation`, `office`).
*   `mediaType` (Enum): Filter search results by:
    *   `Both Videos & Images` (Default)
    *   `Videos Only`
    *   `Images Only`
*   `maxResults` (Integer): The maximum number of results you want to retrieve.
*   `apiKey` (String, **Optional**): Your custom Pexels API key. If left blank, the Actor uses a default fallback key.

---

### 📊 Output Data Structure

The results are pushed directly to your default Apify Dataset. Below are examples of the data structure.

#### For Videos:
```json
{
  "id": 857064,
  "type": "video",
  "search_query": "waterfall",
  "alt_text": "Video by Kelly Lacy",
  "url": "https://www.pexels.com/video/drone-shot-of-a-beautiful-waterfall-857064/",
  "width": 3840,
  "height": 2160,
  "duration_seconds": 15,
  "author_name": "Kelly Lacy",
  "author_url": "https://www.pexels.com/@kelly-lacy",
  "author_id": 12345,
  "preview_url": "https://images.pexels.com/videos/857064/pictures/preview.jpg",
  "download_url": "https://player.vimeo.com/external/371433846.hd.mp4?s=...",
  "alternative_resolutions": [
    {
      "quality": "hd",
      "file_type": "video/mp4",
      "width": 1920,
      "height": 1080,
      "link": "https://player.vimeo.com/external/371433846.hd.mp4?s=..."
    },
    {
      "quality": "sd",
      "file_type": "video/mp4",
      "width": 960,
      "height": 540,
      "link": "https://player.vimeo.com/external/371433846.sd.mp4?s=..."
    }
  ]
}
````

#### For Images:

```json
{
  "id": 3408744,
  "type": "image",
  "search_query": "waterfall",
  "alt_text": "Scenic View of Waterfall",
  "url": "https://www.pexels.com/photo/scenic-view-of-waterfall-3408744/",
  "width": 4000,
  "height": 6000,
  "avg_color": "#4A5247",
  "author_name": "Tomáš Malík",
  "author_url": "https://www.pexels.com/@maliktomas",
  "author_id": 98765,
  "preview_url": "https://images.pexels.com/photos/3408744/pexels-photo-3408744.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500",
  "download_url": "https://images.pexels.com/photos/3408744/pexels-photo-3408744.jpeg",
  "alternative_resolutions": {
    "original": "https://images.pexels.com/photos/3408744/pexels-photo-3408744.jpeg",
    "large2x": "https://images.pexels.com/photos/3408744/pexels-photo-3408744.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
    "large": "https://images.pexels.com/photos/3408744/pexels-photo-3408744.jpeg?auto=compress&cs=tinysrgb&h=650&w=940",
    "medium": "https://images.pexels.com/photos/3408744/pexels-photo-3408744.jpeg?auto=compress&cs=tinysrgb&h=350&w=300",
    "small": "https://images.pexels.com/photos/3408744/pexels-photo-3408744.jpeg?auto=compress&cs=tinysrgb&h=130&w=200",
    "portrait": "https://images.pexels.com/photos/3408744/pexels-photo-3408744.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=1200&w=800",
    "landscape": "https://images.pexels.com/photos/3408744/pexels-photo-3408744.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=627&w=1200",
    "tiny": "https://images.pexels.com/photos/3408744/pexels-photo-3408744.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=200&w=280"
  }
}
```

***

### 💵 Monetization (Pay-Per-Event)

This Actor uses the **Pay-Per-Event (PPE)** pricing model. You only pay for the exact amount of items extracted.

- **Price**: **$1.00 per 1,000 media items** ($0.001 per item).
- **Minimum compute overhead**: Uses ultra-lightweight async Python, running in seconds on the minimal 256MB RAM allocation, keeping Apify compute usage costs near $0.

***

### 🔑 Getting Your Own Free Pexels API Key

If you are running bulk extractions (over 5,000 items per day), it is recommended to get your own API key:

1. Go to [Pexels API Page](https://www.pexels.com/api/).
2. Click **Get Started** and register a free account.
3. Fill in your project name and description to instantly generate your key (it is completely free and takes 10 seconds!).

# Actor input Schema

## `query` (type: `string`):

The search keyword (e.g., 'nature', 'technology', 'fitness').

## `mediaType` (type: `string`):

Choose whether to scrap videos, images, or both.

## `maxResults` (type: `integer`):

Maximum number of items to extract.

## `apiKey` (type: `string`):

Your custom Pexels API key. If left blank, the Actor will use a built-in fallback key. Get your free key at https://www.pexels.com/api/

## Actor input object example

```json
{
  "query": "waterfall",
  "mediaType": "both",
  "maxResults": 50
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "query": "waterfall"
};

// Run the Actor and wait for it to finish
const run = await client.actor("knobby_wallpaper/pexels-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "query": "waterfall" }

# Run the Actor and wait for it to finish
run = client.actor("knobby_wallpaper/pexels-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "query": "waterfall"
}' |
apify call knobby_wallpaper/pexels-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=knobby_wallpaper/pexels-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "pexels-scraper",
        "description": "Extract stock videos and images in bulk from Pexels using the official fast, reliable API.",
        "version": "0.0",
        "x-build-id": "00w8i4qaBlvzg5x3m"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/knobby_wallpaper~pexels-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-knobby_wallpaper-pexels-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/knobby_wallpaper~pexels-scraper/runs": {
            "post": {
                "operationId": "runs-sync-knobby_wallpaper-pexels-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/knobby_wallpaper~pexels-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-knobby_wallpaper-pexels-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "query"
                ],
                "properties": {
                    "query": {
                        "title": "Search Query",
                        "type": "string",
                        "description": "The search keyword (e.g., 'nature', 'technology', 'fitness')."
                    },
                    "mediaType": {
                        "title": "Media Type",
                        "enum": [
                            "videos",
                            "images",
                            "both"
                        ],
                        "type": "string",
                        "description": "Choose whether to scrap videos, images, or both.",
                        "default": "both"
                    },
                    "maxResults": {
                        "title": "Max Results",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Maximum number of items to extract.",
                        "default": 50
                    },
                    "apiKey": {
                        "title": "Pexels API Key (Optional)",
                        "type": "string",
                        "description": "Your custom Pexels API key. If left blank, the Actor will use a built-in fallback key. Get your free key at https://www.pexels.com/api/"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
