pexel-downloader
Download high-quality photos and videos from Pexels.com with a simple CLI.
Quick Start
1. Install
# Using uv (recommended)
uv tool install pexel-downloader
# Or using pip
pip install pexel-downloader
2. Set your API key
Create a free account at pexels.com to get an API key, then run:
pexel-downloader config --api-key YOUR_API_KEY
Or just run pexel-downloader config and you'll be prompted to enter it.
3. Download
# Download 10 images of nature (uses your configured defaults)
pexel-downloader download nature 10
# Download 5 videos of ocean
pexel-downloader download ocean 5 video
That's it! Files are saved to your configured download directory (default: downloads/) and the full path is shown after each download.
Installation
Prerequisites
- Python 3.10+
- Pexels account for an API key: pexels.com
Install uv
uv is a fast Python package manager.
Linux / macOS:
curl -LsSf https://astral.sh/uv/install.sh | sh
Windows (PowerShell):
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Using pip (any platform):
pip install uv
Install pexel-downloader
As a CLI tool [recommend]:
uv tool install pexel-downloader
As a library in your project:
uv add pexel-downloader
Run without installing:
uvx pexel-downloader download nature 5 image
Configuration
Interactive setup
Run pexel-downloader config to configure all settings at once. You'll be prompted for:
- API key — your Pexels API key
- Download directory — where files are saved (default:
downloads) - Content type —
imageorvideo(default:image) - Size — download size (default:
medium)
pexel-downloader config
Set individual settings
pexel-downloader config --api-key YOUR_API_KEY
pexel-downloader config --download-dir ~/Pictures/pexels
pexel-downloader config --content-type video
pexel-downloader config --size large
The configuration is stored at:
- Linux:
~/.config/pexel-downloader/config.json - macOS:
~/Library/Application Support/pexel-downloader/config.json - Windows:
C:\Users\<user>\AppData\Roaming\pexel-downloader\config.json
API key via environment variable
You can also use the PEXEL_API_KEY environment variable (takes priority over the config file):
Linux / macOS:
export PEXEL_API_KEY="your_api_key"
Windows (Command Prompt):
set PEXEL_API_KEY=your_api_key
Windows (PowerShell):
$env:PEXEL_API_KEY = "your_api_key"
CLI Usage
pexel-downloader download QUERY NUM [CONTENT_TYPE] [OPTIONS]
CONTENT_TYPE is optional — if omitted, uses your configured default (image by default).
Examples
# Download 10 images of "nature" (uses default content type and size)
pexel-downloader download nature 10
# Download 5 videos of "ocean" starting from page 2
pexel-downloader download ocean 5 video --start-page 2
# Specify output directory and size
pexel-downloader download cats 20 image --size large -o ./my_images
# Show help
pexel-downloader --help
pexel-downloader download --help
Options
| Option | Short | Default | Description |
|---|---|---|---|
--size |
from config or medium |
Size of the image or video | |
--save-directory |
-o |
from config or downloads |
Directory to save files |
--start-page |
-p |
1 |
Page number to start from |
Available sizes
Images: original, large2x, large, medium, small, portrait, landscape, tiny
Videos: large, medium, small
Python API
import os
from pexel_downloader import PexelDownloader
api_key = os.environ.get("PEXEL_API_KEY")
downloader = PexelDownloader(api_key=api_key)
# Download images
downloader.download_images(query="beaches", num_images=100, save_directory="./images")
# Download videos
downloader.download_videos(query="nature", num_videos=5, save_directory="./videos", size="medium")
# Search without downloading
results = downloader.search_images(query="sunset", per_page=10)
print(results["photos"])
Demonstration
Development
# Clone the repo
git clone https://github.com/Gabriellgpc/pexel-downloader.git
cd pexel-downloader
# Install dependencies (including dev)
uv sync --group dev
# Run tests
uv run pytest tests/ -v
# Run the CLI locally
uv run pexel-downloader --help
License
MIT License. See LICENSE for details.
Metadata
Release files for pexel-downloader 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pexel_downloader-0.2.0.tar.gz | 674.2 kB | With provenance | Details for pexel_downloader-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pexel_downloader-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for pexel_downloader-0.2.0-py3-none-any.whl |
Total release size: 684.6 kB
Release files / pexel_downloader-0.2.0.tar.gz
| Download URL | pexel_downloader-0.2.0.tar.gz |
|---|---|
| Size | 674.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
24c2733d8d22ec311695e842d0d5f76098fbd0e0d26b977f91979ef9c28d5558
|
|
BLAKE2b-256 checksum How to use checksums |
2855f9c1ef62744d371ec35f0a94a5fd3810798fbeee850f67ffa00934ed6423
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / pexel_downloader-0.2.0-py3-none-any.whl
| Download URL | pexel_downloader-0.2.0-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d8156001624f92ec21703dde09a6738a0db1ec5913df8c6337b6cedb1c5ee316
|
|
BLAKE2b-256 checksum How to use checksums |
71e150faf51a0b5403d287483ee8668d4d0664120827d679f814204d9ad44b90
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logSecurity for pexel-downloader 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pexel_downloader-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.