Build a Pet Adoption Finder
Find adoptable pets near your location with filtering by animal type, breed, and age. Connect with local shelters to find your perfect companion.
Needs a substitute
One API used by this recipe is no longer available: Petfinder. The rest of the recipe still works — swap in an alternative for that step before building it.
APIs Used
Data Flow
How It Works
Detect the user's location automatically via IP Geolocation
User selects animal type (dog, cat, etc.) and optional breed/age filters
Search Petfinder for adoptable pets near the detected location
Display pet profiles with photos, descriptions, and shelter contact info
Code Outline
// 1. Detect user location
const geoRes = await fetch('https://api.ipgeolocation.io/ipgeo?apiKey=YOUR_API_KEY');
const { city, state_prov, zipcode } = await geoRes.json();
// 2. Get Petfinder access token
const tokenRes = await fetch('https://api.petfinder.com/v2/oauth2/token', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
grant_type: 'client_credentials',
client_id: 'YOUR_CLIENT_ID',
client_secret: 'YOUR_CLIENT_SECRET'
})
});
const { access_token } = await tokenRes.json();
// 3. Search for adoptable pets nearby
const petsRes = await fetch(
`https://api.petfinder.com/v2/animals?type=dog&location=${zipcode}&distance=25&limit=10`,
{ headers: { 'Authorization': `Bearer ${access_token}` } }
);
const { animals } = await petsRes.json();
// 4. Display pet profiles
console.log(`Adoptable dogs near ${city}, ${state_prov}:`);
animals.forEach(pet => {
console.log(`${pet.name} - ${pet.breeds.primary} | Age: ${pet.age}`);
console.log(` ${pet.description?.slice(0, 100) || 'No description'}...`);
console.log(` Shelter: ${pet.contact.email}`);
console.log(` Photo: ${pet.photos[0]?.medium || 'No photo'}\n`);
}); Recipe Details
Related Recipes
Related Tutorials
Note: These recipes are AI-generated suggestions based on API capabilities. Actual implementation may vary. Always refer to official API documentation for the latest specifications.