GET
/
api
/
v1
/
search
/
photos
Search photos by text
curl --request GET \
  --url https://api.pexafy.com/api/v1/search/photos \
  --header 'x-api-key: <api-key>'
import requests

url = "https://api.pexafy.com/api/v1/search/photos"

headers = {"x-api-key": "<api-key>"}

response = requests.get(url, headers=headers)

print(response.text)
const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};

fetch('https://api.pexafy.com/api/v1/search/photos', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pexafy.com/api/v1/search/photos",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://api.pexafy.com/api/v1/search/photos"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("x-api-key", "<api-key>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.get("https://api.pexafy.com/api/v1/search/photos")
.header("x-api-key", "<api-key>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.pexafy.com/api/v1/search/photos")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'

response = http.request(request)
puts response.read_body
{
  "success": true,
  "data": [
    {
      "photo_id": "019e1a0d-1a4f-7d62-856f-e6775b49785d",
      "image_url": "https://images.pexels.com/photos/20853949/pexels-photo-20853949.jpeg",
      "urls": {
        "thumb": "https://images.pexels.com/photos/20853949/pexels-photo-20853949.jpeg?w=200",
        "small": "https://images.pexels.com/photos/20853949/pexels-photo-20853949.jpeg?w=400",
        "regular": "https://images.pexels.com/photos/20853949/pexels-photo-20853949.jpeg?w=1280",
        "large": "https://images.pexels.com/photos/20853949/pexels-photo-20853949.jpeg?w=1920",
        "full": "https://images.pexels.com/photos/20853949/pexels-photo-20853949.jpeg?w=2400"
      },
      "width": 8234,
      "height": 5489,
      "blur_hash": "LIKe1dRPpd%N4mRjMxxut.oLDNf,",
      "orientation": "landscape",
      "color_name": "silver (metallic)",
      "color_hex": "#AEABAF",
      "photographer_username": "dip-kheto",
      "source": "Pexels",
      "license_type": "free",
      "relevance_score": 0.8312,
      "source_image_url": "https://www.pexels.com/photo/red-fox-walking-in-snow-20853949",
      "source_description": "A red fox gracefully walks through the snow, showcasing its striking fur in a serene winter scene.",
      "description": "In a snowy field, an orange fox is captured mid-stride, moving towards the right side of the frame with its tail visible behind it. The fox's fur contrasts beautifully against the white snow, and its ears are perked up in alertness. In the background, there are bushes and trees scattered across the landscape, adding depth to the scene.",
      "alt_description": "Red fox walking through a snowy field with bushes and trees behind it",
      "photographer_url": "https://www.pexels.com/search/users/Dip%20Kheto/",
      "photographer_full_name": "Dip Kheto",
      "uploaded_on": "2024-04-03",
      "attribution": {
        "html": "<span class=\"attribution\">Photo by <a href=\"https://www.pexels.com/search/users/Dip%20Kheto/\" target=\"_blank\" rel=\"noopener\">Dip Kheto</a> on <a href=\"https://pexafy.com/legal/licenses/#pexels\" target=\"_blank\" rel=\"noopener\">Pexels</a></span>",
        "plain": "Photo by Dip Kheto on Pexels (https://pexafy.com/legal/licenses/#pexels)"
      }
    },
    {
      "photo_id": "019e1d9d-31f0-73df-85fe-dc1e474f31fa",
      "image_url": "https://images.unsplash.com/photo-1646480106126-ead0ad489ac7",
      "urls": {
        "thumb": "https://images.unsplash.com/photo-1646480106126-ead0ad489ac7?w=200",
        "small": "https://images.unsplash.com/photo-1646480106126-ead0ad489ac7?w=400",
        "regular": "https://images.unsplash.com/photo-1646480106126-ead0ad489ac7?w=1280",
        "large": "https://images.unsplash.com/photo-1646480106126-ead0ad489ac7?w=1920",
        "full": "https://images.unsplash.com/photo-1646480106126-ead0ad489ac7?w=2400"
      },
      "width": 3632,
      "height": 2421,
      "blur_hash": "LcOWpb~q9Fs:_3%MofofIUV@j?og",
      "orientation": "landscape",
      "color_name": "light gray",
      "color_hex": "#CCCBCF",
      "photographer_username": "tomma5588",
      "source": "Unsplash",
      "license_type": "free",
      "relevance_score": 0.7964,
      "source_image_url": "https://unsplash.com/photos/a-fox-standing-in-the-snow-looking-at-the-camera-wybkd-04SPc",
      "source_description": "VOLPE ROSSA",
      "description": "The image depicts a fox standing on all fours, facing to the right side and looking directly at the camera. The fox's fur is a mix of orange and brown colors, blending with the snowy landscape around it. The background is a light gray color, providing a stark contrast that makes the fox stand out prominently. The snowflakes falling from the sky are scattered throughout the image, adding to the wintry atmosphere.",
      "alt_description": "Red fox standing in the snow and looking at the camera as snowflakes fall",
      "photographer_url": "https://unsplash.com/@tomma5588",
      "photographer_full_name": "FRANCESCO TOMMASINI",
      "uploaded_on": "2022-03-05",
      "attribution": {
        "html": "<span class=\"attribution\">Photo by <a href=\"https://unsplash.com/@tomma5588\" target=\"_blank\" rel=\"noopener\">FRANCESCO TOMMASINI</a> on <a href=\"https://pexafy.com/legal/licenses/#unsplash\" target=\"_blank\" rel=\"noopener\">Unsplash</a></span>",
        "plain": "Photo by FRANCESCO TOMMASINI on Unsplash (https://pexafy.com/legal/licenses/#unsplash)"
      }
    }
  ],
  "meta": {
    "request_id": "ad7140d9-2cc2-4134-8bae-6b90ba3dede2",
    "took_ms": 86.42
  },
  "pagination": {
    "next_cursor": "eyJycyI6IjBlYWNjM2Q5MjI0NTRjMmFiYTc4NjBhMGIwZjJkZDlkIiwicCI6MSwicHAiOjJ9",
    "per_page": 2,
    "has_more": true
  },
  "error": null
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

Authorizations

x-api-key
string
header
required

Pass your Pexafy API key in this header.

Get your API key at pexafy.com/dashboard/api-keys/create.

Query Parameters

q
string | null

Your search query in plain language — full descriptive sentences work best (e.g. two people sharing a bench in comfortable silence), though short queries like mountain sunset are fine too. Up to 500 characters. Optional if you provide at least one filter instead.

Maximum string length: 500
color_name
string | null

Keep only photos whose dominant color matches this name (e.g. blue, red, teal). Call GET /api/v1/facets/colors (see the Facets section) to get the list of available color names. Cannot be combined with color_hex.

color_hex
string | null

Keep only photos close to this hex color (e.g. #1E90FF). Cannot be combined with color_name. Use color_tolerance to widen or tighten the match.

color_tolerance
integer | null

How far a photo's colour may sit from the one you asked for, from 0 (strict) to 255 (very loose). Defaults to 20. Applies to both color_hex and color_name: for a hex it is the radius around that exact shade, for a name it widens or narrows the colour family. How far a photo's colour may sit from the one you asked for, from 0 (strict) to 255 (very loose). Defaults to 20. Applies to both color_hex and color_name: for a hex it is the radius around that exact shade, for a name it widens or narrows the colour family. The published spec used to say it applied to color_hex only, which was never true of the code.

Required range: 0 <= x <= 255
orientation
string[] | null

Keep only photos with these shapes: landscape, portrait and/or square. Repeat the parameter to pass several. See GET /api/v1/facets/orientations.

source
string[] | null

Keep only photos from these providers (e.g. Pexels, Unsplash, Pixabay). Repeat the parameter to pass several. Call GET /api/v1/facets/sources to list every available source.

license_type
string[] | null

Keep only photos with these license types (e.g. free). Call GET /api/v1/facets/licenses to list the available license types.

per_page
integer | null

Number of photos per page, from 1 to 100. Defaults to 20.

Required range: 1 <= x <= 100
limit
integer | null

Maximum TOTAL number of results to return across all pages — NOT the page size (use per_page for that). e.g. limit=4 with per_page=2 returns two pages of 2 results, then stops. Omit for no cap.

Required range: 1 <= x <= 100
score_threshold
number | null

Minimum relevance a photo must reach to appear, from 0 to 1. Raise it (e.g. 0.3) to keep only strong matches and drop loosely related photos; leave it unset to get the widest set of results.

Required range: 0 <= x <= 1
cursor
string | null

Token used to fetch the next page. Take the pagination.next_cursor value from a previous response and pass it back here. See the Pagination guide.

fields
string | null

Comma-separated list to return only the fields you need (e.g. photo_id,urls,attribution), which makes responses smaller. Omit to get every field your plan allows.

Valid values: photo_id, source_photo_id, image_url, urls, source_image_url, width, height, orientation, blur_hash, color_name, color_hex, source, license_type, photographer_username, photographer_full_name, photographer_url, source_description, description, alt_description, relevance_score, uploaded_on, attribution. There is no photographer field — the credit is carried by photographer_username, photographer_full_name and photographer_url. An unknown name returns 400 INVALID_FIELDS listing the values your plan accepts.

after_date
string | null

Only return photos published on or after this date, formatted YYYY-MM-DD.

sort_by
enum<string> | null

Order of the results: relevance (default — best match first) or newest (most recently added first).

Available options:
relevance,
newest
photographer
string | null

Only return photos from this photographer's username. Use GET /api/v1/facets/photographers/suggest to find usernames.

Response

Successful Response

success
boolean
data
object[]
meta
object
error
object | null
pagination
object | null