Unsplash API
api.unsplash.com · Media
High-resolution free stock photos — search 5M+ professional photographs, get random images, download triggers, and photo statistics. Free tier: 50 requests/hour.
Authentication
Sample Requests
Search Unsplash for mountain photos.
Hover any highlighted part to learn what it does
curl -X GET "https://api.unsplash.com/search/photos?query=mountains&per_page=3&client_id=YOUR_KEY"
import requests
params = {
"query": "mountains",
"per_page": "3",
"client_id": "YOUR_KEY"
}
response = requests.get(
"https://api.unsplash.com/search/photos",
params=params,
)
print(response.json())const url = new URL('https://api.unsplash.com/search/photos');
url.searchParams.set('query', 'mountains');
url.searchParams.set('per_page', '3');
url.searchParams.set('client_id', 'YOUR_KEY');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.unsplash.com/search/photos")
q := baseURL.Query()
q.Set("query", "mountains")
q.Set("per_page", "3")
q.Set("client_id", "YOUR_KEY")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
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.unsplash.com/search/photos")
uri.query = URI.encode_www_form({
"query" => "mountains",
"per_page" => "3",
"client_id" => "YOUR_KEY"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.unsplash.com/search/photos?" . http_build_query([
"query" => "mountains",
"per_page" => "3",
"client_id" => "YOUR_KEY"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Get a random ocean photo.
Hover any highlighted part to learn what it does
curl -X GET "https://api.unsplash.com/photos/random?query=ocean&client_id=YOUR_KEY"
import requests
params = {
"query": "ocean",
"client_id": "YOUR_KEY"
}
response = requests.get(
"https://api.unsplash.com/photos/random",
params=params,
)
print(response.json())const url = new URL('https://api.unsplash.com/photos/random');
url.searchParams.set('query', 'ocean');
url.searchParams.set('client_id', 'YOUR_KEY');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.unsplash.com/photos/random")
q := baseURL.Query()
q.Set("query", "ocean")
q.Set("client_id", "YOUR_KEY")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
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.unsplash.com/photos/random")
uri.query = URI.encode_www_form({
"query" => "ocean",
"client_id" => "YOUR_KEY"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.unsplash.com/photos/random?" . http_build_query([
"query" => "ocean",
"client_id" => "YOUR_KEY"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- Register at unsplash.com/developers for a free access key
- Pass client_id=YOUR_KEY as query param
- Search: GET /search/photos?query=cityscape&client_id=YOUR_KEY
- Random: GET /photos/random?client_id=YOUR_KEY
- Attribution required — display photographer credit
What can you build with Unsplash API?
Unsplash 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. Unsplash 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