Pexels API
api.pexels.com · Media
Free stock photos and videos — search millions of curated images and videos from Pexels contributors. Includes video search and curation endpoints. Completely free with API key.
Authentication
Sample Requests
Search Pexels for sunset photos.
Hover any highlighted part to learn what it does
| Authorization | YOUR_API_KEY |
curl -X GET "https://api.pexels.com/v1/search?query=sunset&per_page=3" \ -H "Authorization: YOUR_API_KEY"
import requests
params = {
"query": "sunset",
"per_page": "3"
}
headers = {
"Authorization": "YOUR_API_KEY"
}
response = requests.get(
"https://api.pexels.com/v1/search",
params=params,
headers=headers,
)
print(response.json())const url = new URL('https://api.pexels.com/v1/search');
url.searchParams.set('query', 'sunset');
url.searchParams.set('per_page', '3');
const response = await fetch(url, {
headers: {
'Authorization': 'YOUR_API_KEY'
},
});
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.pexels.com/v1/search")
q := baseURL.Query()
q.Set("query", "sunset")
q.Set("per_page", "3")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
req.Header.Set("Authorization", "YOUR_API_KEY")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.pexels.com/v1/search")
uri.query = URI.encode_www_form({
"query" => "sunset",
"per_page" => "3"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "YOUR_API_KEY"
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.pexels.com/v1/search?" . http_build_query([
"query" => "sunset",
"per_page" => "3"
]);
$opts = ["http" => [
"method" => "GET",
"header" => implode("\r\n", [
"Authorization: YOUR_API_KEY"
]),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Get daily curated photos from Pexels.
Hover any highlighted part to learn what it does
| Authorization | YOUR_API_KEY |
curl -X GET "https://api.pexels.com/v1/curated?per_page=5" \ -H "Authorization: YOUR_API_KEY"
import requests
params = {
"per_page": "5"
}
headers = {
"Authorization": "YOUR_API_KEY"
}
response = requests.get(
"https://api.pexels.com/v1/curated",
params=params,
headers=headers,
)
print(response.json())const url = new URL('https://api.pexels.com/v1/curated');
url.searchParams.set('per_page', '5');
const response = await fetch(url, {
headers: {
'Authorization': 'YOUR_API_KEY'
},
});
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.pexels.com/v1/curated")
q := baseURL.Query()
q.Set("per_page", "5")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
req.Header.Set("Authorization", "YOUR_API_KEY")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.pexels.com/v1/curated")
uri.query = URI.encode_www_form({
"per_page" => "5"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "YOUR_API_KEY"
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.pexels.com/v1/curated?" . http_build_query([
"per_page" => "5"
]);
$opts = ["http" => [
"method" => "GET",
"header" => implode("\r\n", [
"Authorization: YOUR_API_KEY"
]),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- Get a free API key at pexels.com/api
- Set Authorization: YOUR_API_KEY header (no "Bearer" prefix)
- Search: GET /v1/search?query=coffee&per_page=5
- Videos: GET https://api.pexels.com/videos/search?query=rain&per_page=5
- No attribution required — but credit is appreciated
What can you build with Pexels API?
Pexels API is a Media API. Developers commonly use media APIs for:
- storing and delivering images, video, and audio
- building digital asset management and media libraries
- transcoding and optimising media for the web
- adding video streaming and playback to your app
- automating content tagging and metadata extraction
API Key authentication. You'll receive a key after signing up. Send it with every request — in a header or query parameter. Keep it out of client-side code and never commit it to version control. Pexels API is free to use up to a usage limit, making it a low-risk choice to experiment with.
New to APIs? Read our beginner's guide