Demo
GET /api/v1/facts
Click "Test" to see the response
Example Code
// Get 2 facts as JSON
fetch('https://dogapi.dog/api/v1/facts?number=2')
.then(response => response.json())
.then(data => console.log(data.facts));
// Get 1 fact as plain text
fetch('https://dogapi.dog/api/v1/facts?number=1&raw=true')
.then(response => response.text())
.then(fact => console.log(fact));
GET /api/v2/facts
Click "Test" to see the response
// V2 returns JSON API format
fetch('https://dogapi.dog/api/v2/facts?limit=2')
.then(response => response.json())
.then(data => {
data.data.forEach(fact => {
console.log(fact.attributes.body);
});
});
GET /api/v2/breeds
Click "Test" to see the response
// Get first 10 breeds
fetch('https://dogapi.dog/api/v2/breeds?page[size]=10')
.then(response => response.json())
.then(data => console.log(data.data));
// Get all breeds in one request
fetch('https://dogapi.dog/api/v2/breeds?page[size]=1000')
.then(response => response.json())
.then(data => console.log(`Found ${data.data.length} breeds`));
GET /api/v2/breeds/{id}
Click "Test" to see the response
// Get specific breed details
const breedId = "your-breed-id-here";
fetch(`https://dogapi.dog/api/v2/breeds/${breedId}`)
.then(response => response.json())
.then(data => {
const breed = data.data.attributes;
console.log(`Name: ${breed.name}`);
console.log(`Description: ${breed.description}`);
console.log(`Life span: ${breed.life.min}-${breed.life.max} years`);
});
GET /api/v2/groups
Click "Test" to see the response
// Get all dog groups with their breeds
fetch('https://dogapi.dog/api/v2/groups')
.then(response => response.json())
.then(data => {
data.data.forEach(group => {
console.log(`${group.attributes.name}: ${group.relationships.breeds.data.length} breeds`);
});
});
GET /api/v2/groups/{id}
Click "Test" to see the response
// Get specific group details with breeds
const groupId = "your-group-id-here";
fetch(`https://dogapi.dog/api/v2/groups/${groupId}`)
.then(response => response.json())
.then(data => {
const group = data.data.attributes;
const breedCount = data.data.relationships.breeds.data.length;
console.log(`Group: ${group.name}`);
console.log(`Contains ${breedCount} breeds`);
});