Get by IDs (comma separated)
Retrieves multiple GIFs from Giphy using a comma-separated list of unique IDs. This node is ideal for batch operations when you need to fetch several specific GIFs in a single API call.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- IDs - Comma-separated list of Giphy GIF IDs. This is a required field and cannot be empty. Example: "FiGiRei2ICzzG,3o7btPCcdNniyf0ArS,xT9IgDEI1iZyb2wqo8"
Options
- Rating - Content rating filter to restrict results. Options:
- g - Suitable for all audiences (default)
- pg - Parental guidance suggested
- pg-13 - Parents strongly cautioned
- r - Restricted to adults
- API Key - Your Giphy API key credential for authentication. Required for all requests.
Output
- resp - API response object containing:
data- Array of GIF objects corresponding to the requested IDspagination- Object with count informationmeta- API status information
How It Works
The Get by IDs node retrieves multiple GIFs in a single request:
- Validates that the IDs parameter is not empty
- Retrieves authentication credentials from the credential manager
- Constructs API request with comma-separated IDs
- Sends GET request to Giphy's bulk retrieval endpoint
- Parses JSON response containing all matching GIFs
- Returns GIFs in the same order as requested (when all IDs are valid)
Example Usage
Retrieve Multiple GIFs
// Fetch 3 specific GIFs
msg.IDs = "FiGiRei2ICzzG,3o7btPCcdNniyf0ArS,xT9IgDEI1iZyb2wqo8";
// After node execution:
let gifUrls = msg.resp.data.map(gif => gif.images.original.url);
console.log(`Retrieved ${msg.resp.data.length} GIFs`);
Load User's Favorites
// Retrieve all saved favorite GIFs
let favoriteIds = database.getUserFavorites(userId); // Returns array
msg.IDs = favoriteIds.join(',');
// After execution:
msg.favoriteGifs = msg.resp.data;
Build a Carousel
// Create a GIF carousel from stored IDs
let carouselIds = ["id1", "id2", "id3", "id4", "id5"];
msg.IDs = carouselIds.join(',');
// After execution, build carousel with:
msg.resp.data.forEach(gif => {
addToCarousel(gif.images.fixed_height.url, gif.title);
});
Verify Multiple GIFs
// Check if multiple GIF IDs are still valid
msg.IDs = "FiGiRei2ICzzG,InvalidID123,3o7btPCcdNniyf0ArS";
// After execution:
let requestedCount = msg.IDs.split(',').length;
let retrievedCount = msg.resp.data.length;
msg.missingCount = requestedCount - retrievedCount;
Create GIF Collection
// Build a themed collection
let holidayGifIds = getHolidayGifIds(); // From database
msg.IDs = holidayGifIds.join(',');
// After execution, create collection page:
msg.collection = msg.resp.data.map(gif => ({
id: gif.id,
title: gif.title,
url: gif.images.downsized.url,
thumbnail: gif.images.fixed_height_small.url
}));
Common Use Cases
- Batch Retrieval - Fetch multiple GIFs efficiently in one API call instead of multiple individual calls
- User Collections - Load all GIFs in a user's favorites, playlist, or collection
- Content Galleries - Build galleries or carousels from curated GIF IDs
- Recommendation Systems - Retrieve a set of recommended GIFs based on stored preferences
- Comparison Tools - Display multiple GIFs side-by-side for user selection
- Bulk Validation - Verify that multiple stored GIF IDs are still accessible
- Report Generation - Include multiple specific GIFs in automated reports or newsletters
Tips
- Use Comma Separation - Ensure IDs are separated by commas without spaces: "id1,id2,id3"
- Limit Batch Size - While Giphy supports many IDs, keep batches reasonable (10-50) for performance
- Handle Missing GIFs - Some IDs may be invalid or deleted; always check the returned count
- Preserve Order - GIFs are typically returned in the order requested (when all are valid)
- Build from Arrays - Use JavaScript's
join(',')to convert ID arrays to comma-separated strings - Validate Input - Check that your ID string is properly formatted before calling the node
- Compare Counts - Always compare requested vs returned count to detect missing GIFs
Error Handling
The node will return errors in the following cases:
- ErrInvalidArg - IDs parameter is empty or missing
- ErrCredentials - API key is missing, invalid, or credential retrieval failed
- ErrRuntime - Network error, API timeout, or invalid API response
Common Errors and Solutions
| Error | Cause | Solution |
|---|---|---|
| IDs cannot be empty | No IDs provided | Ensure msg.IDs is set with comma-separated values |
| Failed to get API key | Credential not configured | Add Giphy API key to credential manager |
| Failed to call Giphy API | Network/connectivity issue | Check internet connection and retry |
| Failed to decode API response | Invalid API response | Verify IDs are correctly formatted |
| Fewer GIFs returned than requested | Some IDs invalid/deleted | Check which IDs are missing and update database |
| 403 Forbidden | Invalid API key | Verify API key is correct and active |
Response Structure
{
"data": [
{
"type": "gif",
"id": "FiGiRei2ICzzG",
"url": "https://giphy.com/gifs/FiGiRei2ICzzG",
"images": {
"original": {
"url": "https://media.giphy.com/media/.../giphy.gif",
"width": "500",
"height": "281"
},
"downsized": { ... }
},
"title": "First GIF",
"rating": "g"
},
{
"type": "gif",
"id": "3o7btPCcdNniyf0ArS",
"url": "https://giphy.com/gifs/3o7btPCcdNniyf0ArS",
"images": { ... },
"title": "Second GIF",
"rating": "g"
}
],
"pagination": {
"count": 2,
"offset": 0
},
"meta": {
"status": 200,
"msg": "OK",
"response_id": "..."
}
}
Best Practices
- Always validate the IDs string format before making the API call
- Compare requested count vs returned count to detect missing/deleted GIFs
- Use this node instead of multiple Get by ID calls for better performance
- Keep batch sizes reasonable (10-50 IDs) for optimal response times
- Implement error handling for partially successful retrievals
- Store the order of requested IDs if order matters for your use case
- Consider chunking very large ID lists into multiple smaller requests
- Cache results if the same batch of GIFs is retrieved frequently
Performance Considerations
Single Request vs Multiple Requests
Get by IDs (Batch)
- 1 API call for 10 GIFs
- Faster overall execution
- Lower API rate limit usage
- Recommended for 2+ GIFs
Get by ID (Individual)
- 10 API calls for 10 GIFs
- Slower overall execution
- Higher API rate limit usage
- Use only when retrieving 1 GIF
Batch Size Recommendations
- Small batch (2-10 IDs): Optimal performance, fast response
- Medium batch (11-25 IDs): Good balance of efficiency and speed
- Large batch (26-50 IDs): Efficient but slower response time
- Very large batch (50+ IDs): Consider splitting into multiple requests
Handling Missing GIFs
// Track which GIFs are missing
let requestedIds = msg.IDs.split(',');
let retrievedIds = msg.resp.data.map(gif => gif.id);
let missingIds = requestedIds.filter(id => !retrievedIds.includes(id));
if (missingIds.length > 0) {
console.log(`Missing GIF IDs: ${missingIds.join(', ')}`);
// Update database to remove invalid IDs
database.removeGifIds(missingIds);
}
Building ID Lists from Arrays
// From array of objects with id property
let gifObjects = [{id: "id1"}, {id: "id2"}, {id: "id3"}];
msg.IDs = gifObjects.map(obj => obj.id).join(',');
// From simple array
let idArray = ["id1", "id2", "id3"];
msg.IDs = idArray.join(',');
// From database result
let dbResults = database.query("SELECT gif_id FROM favorites");
msg.IDs = dbResults.map(row => row.gif_id).join(',');