Beginner 1-2 hours · 3 APIs
Build a Daily Pet Photo Notifier
Receive a daily push notification with a random cute dog or cat photo to brighten your day.
APIs Used
Data Flow
User Action
API Call
Transform
Output
How It Works
1
Randomly decide whether to fetch a dog or cat photo
2
Fetch a random image from the chosen API
3
Send the image as a rich push notification via OneSignal
4
Schedule to run daily using a cron job or serverless function
Code Outline
Pseudocode / JavaScript
// 1. Randomly pick dog or cat
const isDog = Math.random() > 0.5;
// 2. Fetch random pet image
let imageUrl, petType;
if (isDog) {
const res = await fetch('https://dog.ceo/api/breeds/image/random');
const data = await res.json();
imageUrl = data.message;
petType = 'Dog';
} else {
const res = await fetch('https://api.thecatapi.com/v1/images/search');
const [data] = await res.json();
imageUrl = data.url;
petType = 'Cat';
}
// 3. Send push notification with image
await fetch('https://onesignal.com/api/v1/notifications', {
method: 'POST',
headers: { 'Authorization': 'Basic YOUR_ONESIGNAL_KEY', 'Content-Type': 'application/json' },
body: JSON.stringify({
app_id: 'YOUR_APP_ID',
included_segments: ['All'],
contents: { en: `Your daily ${petType} photo!` },
big_picture: imageUrl
})
}); Recipe Details
Difficulty Beginner
Time 1-2 hours
APIs Used 3
Tags
Related Recipes
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.