Skip to main content

Search Gifs

Searches for GIFs on Giphy using a query term or phrase. This node returns a collection of GIFs matching your search criteria, with support for pagination, rating filters, and multi-language results.

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

  • Q - Search query term or phrase. This is a required field and cannot be empty. Use specific keywords for better results (e.g., "happy cat" instead of just "cat").

Options

  • Limit - The maximum number of GIFs to return. Default: 25. Maximum recommended: 50. Higher values may impact performance.
  • Offset - Results offset for pagination. Default: 0. Use this with Limit to implement pagination (e.g., Offset=25 and Limit=25 for page 2).
  • 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
  • Language - Language code for localized results. Default: en (English). Supports 30+ languages including es, fr, de, ja, zh-CN, pt, and more.
  • Bundle - Rendering optimization type. Options:
    • Efficient Clip Grid - Optimized for grid display of video clips
    • Quick GIFs - Fast-loading GIFs for messaging (default)
    • Efficient Sticker Layering - Optimized for sticker overlays
    • Low Data Usage GIFs - Smaller file sizes for bandwidth-constrained environments
  • API Key - Your Giphy API key credential for authentication. Required for all requests.

Output

  • resp - API response object containing:
    • data - Array of GIF objects with URLs, metadata, and user information
    • pagination - Object with total_count, count, and offset
    • meta - API status information

How It Works

The Search Gifs node queries the Giphy API with your search term and returns matching GIFs:

  1. Validates that the search query is not empty
  2. Retrieves authentication credentials from the credential manager
  3. Constructs API request with query parameters (search term, limit, offset, rating, language, bundle)
  4. Sends GET request to Giphy's search endpoint
  5. Parses JSON response and stores it in the output variable
  6. Each GIF object in the response includes multiple URL formats (original, downsized, preview, etc.)

Example Usage

// Search for cat GIFs
msg.Q = "funny cats";
// After node execution, access results:
// msg.resp.data[0].images.original.url - First GIF URL
// msg.resp.pagination.total_count - Total results available
// Get first page
msg.Limit = 10;
msg.Offset = 0;
// Run search...

// Get second page
msg.Offset = 10;
// Run search again...
// Search with specific filters
msg.Q = "birthday celebration";
msg.Limit = 20;
msg.Rating = "g"; // Family-friendly only
msg.Language = "es"; // Spanish results

Extract GIF URLs

// After search, extract all GIF URLs
let gifUrls = msg.resp.data.map(gif => gif.images.original.url);
msg.gifList = gifUrls;

Common Use Cases

  1. Social Media Content - Find relevant GIFs for automated social media posts based on trending topics or keywords
  2. Email Campaigns - Search for GIFs that match campaign themes (e.g., "holiday sale", "thank you")
  3. Chatbot Responses - Return contextual GIFs based on user input or conversation sentiment
  4. Content Curation - Build libraries of GIFs organized by category or theme
  5. A/B Testing - Search for different GIF styles to test engagement in marketing materials

Tips

  • Be Specific - Use detailed search terms (e.g., "dog playing piano" vs "dog") for more relevant results
  • Use Multiple Keywords - Combine 2-3 keywords for better targeting (e.g., "excited happy dance")
  • Check Total Count - Use msg.resp.pagination.total_count to know if more results are available
  • Implement Retry Logic - Add error handling for network issues or rate limit errors
  • Cache Popular Searches - Store frequently searched GIF URLs to reduce API calls
  • Test Different Ratings - The same search term may yield different results with different rating filters
  • Language Matters - Some search terms work better in certain languages (e.g., "kawaii" in Japanese)

Error Handling

The node will return errors in the following cases:

  • ErrInvalidArg - Query parameter is empty or missing
  • ErrCredentials - API key is missing, invalid, or credential retrieval failed
  • ErrRuntime - Network error, API timeout, or invalid API response
  • Rate Limit Exceeded - Too many requests sent to Giphy API (check your usage limits)

Common Errors and Solutions

ErrorCauseSolution
Query cannot be emptyNo search term providedEnsure msg.Q is set before the node executes
Failed to get API keyCredential not configuredAdd Giphy API key to credential manager
Failed to call Giphy APINetwork/connectivity issueCheck internet connection and retry
Failed to decode API responseInvalid API responseCheck API key validity and Giphy service status
403 ForbiddenInvalid API keyVerify API key is correct and active
429 Too Many RequestsRate limit exceededImplement rate limiting or upgrade API plan

Response Structure

{
"data": [
{
"type": "gif",
"id": "FiGiRei2ICzzG",
"url": "https://giphy.com/gifs/...",
"images": {
"original": {
"url": "https://media.giphy.com/media/.../giphy.gif",
"width": "500",
"height": "281"
},
"downsized": { ... },
"fixed_height": { ... },
"preview_gif": { ... }
},
"title": "Funny Cat GIF",
"rating": "g",
"user": { ... }
}
],
"pagination": {
"total_count": 157,
"count": 25,
"offset": 0
},
"meta": {
"status": 200,
"msg": "OK"
}
}

Best Practices

  1. Always validate that msg.resp.data is not empty before accessing GIF data
  2. Use try-catch blocks when processing response data to handle unexpected formats
  3. Store GIF IDs rather than URLs for long-term storage (URLs may change)
  4. Implement pagination when dealing with popular search terms that return many results
  5. Use the preview or downsized image URLs for thumbnails to save bandwidth
  6. Monitor your API usage to avoid hitting rate limits
  7. Consider implementing a local cache for frequently requested searches