GET /api/breeds/image/random • HTTP 200 OK
Dog CEO Random Media Public API Example — Request & Response Example
A fun, lightweight public API demonstrating how JSON payloads serve image CDN URLs to frontend user interfaces.
1. HTTP Client Request (GET)
GET /api/breeds/image/random HTTP/1.1
{
"Accept": "application/json"
}
2. Server JSON Response (HTTP 200 OK)
{
"message": "https://images.dog.ceo/breeds/husky/n02110185_1469.jpg",
"status": "success"
}
Copy-Paste Code Snippets (cURL, JavaScript Fetch, Python, Node.js)
curl "https://dog.ceo/api/breeds/image/random"
fetch('https://dog.ceo/api/breeds/image/random')
.then(res => res.json())
.then(data => console.log(data.message));
import requests
res = requests.get('https://dog.ceo/api/breeds/image/random')
print(res.json()['message'])
How This API Call Works Step-by-Step
- 1. Client makes GET request.
- 2. Server selects random media asset URL from catalog.
- 3. Client inserts message string into <img src="..." /> tag in HTML.
Backend API Functions: The API function getRandomDogImage() queries an S3 storage bucket inventory and returns an HTTPS URL.
Frequently Asked Questions
Do APIs return images directly or URLs?
Modern REST APIs almost always return CDN URLs to images inside JSON rather than raw image bytes, enabling browsers to parallelize asset downloading and browser caching.