Skip to main content

Get by ID

Retrieves a specific GIF from Giphy using its unique ID. This node is essential when you need to fetch a particular GIF that you've previously identified, stored, or referenced.

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

  • ID - The unique Giphy GIF ID. This is a required field and cannot be empty. Example: "FiGiRei2ICzzG" or "3o7btPCcdNniyf0ArS".

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 - A single GIF object with complete metadata, all image formats, and user information
    • meta - API status information

How It Works

The Get by ID node retrieves a specific GIF using its unique identifier:

  1. Validates that the ID parameter is not empty
  2. Retrieves authentication credentials from the credential manager
  3. Constructs API request to Giphy's GIF endpoint with the specific ID
  4. Sends GET request to retrieve the GIF data
  5. Parses JSON response containing complete GIF information
  6. Stores the response in the output variable

Example Usage

Retrieve Known GIF

// Fetch a specific GIF by ID
msg.ID = "FiGiRei2ICzzG";
// After node execution:
let gifUrl = msg.resp.data.images.original.url;
let gifTitle = msg.resp.data.title;

Retrieve from Database

// Get GIF ID from database
let favoriteGifId = database.getUserFavoriteGif(userId);
msg.ID = favoriteGifId;
// After node execution, send to user
sendMessage(msg.resp.data.images.downsized.url);

Validate GIF Exists

// Check if a GIF ID is still valid
msg.ID = storedGifId;
// After node execution:
if (msg.resp.data && msg.resp.data.id) {
msg.gifExists = true;
} else {
msg.gifExists = false;
}

Get Multiple Formats

// Retrieve a GIF and get different size formats
msg.ID = "3o7btPCcdNniyf0ArS";
// After execution, access various formats:
msg.original = msg.resp.data.images.original.url; // Full size
msg.mobile = msg.resp.data.images.downsized.url; // Mobile-friendly
msg.thumbnail = msg.resp.data.images.fixed_height_small.url; // Thumbnail

Batch Processing

// Process array of GIF IDs
let gifIds = ["FiGiRei2ICzzG", "xT9IgDEI1iZyb2wqo8", "3o7btPCcdNniyf0ArS"];
msg.gifDetails = [];

// Use Loop node to iterate through IDs
for (let id of gifIds) {
msg.ID = id;
// Run Get by ID node
msg.gifDetails.push({
id: id,
title: msg.resp.data.title,
url: msg.resp.data.images.original.url
});
}

Common Use Cases

  1. Favorites System - Retrieve user's favorite GIFs stored by ID in a database
  2. Content Management - Fetch specific GIFs for scheduled social media posts
  3. Verification - Validate that stored GIF IDs are still active and accessible
  4. Deep Linking - Resolve GIF IDs from URLs or QR codes to display content
  5. Caching - Store GIF IDs instead of URLs (which may change) and retrieve on-demand
  6. Collections - Build curated GIF collections by storing and retrieving specific IDs
  7. Attribution - Get complete GIF metadata including creator information

Tips

  • Store IDs, Not URLs - GIF IDs are permanent, but URLs may change; always store IDs in your database
  • Extract ID from URL - You can extract GIF IDs from Giphy URLs: https://giphy.com/gifs/ID-HERE
  • Validate Before Use - Check that msg.resp.data exists before accessing properties
  • Use for Consistency - When you need the exact same GIF every time, use Get by ID instead of Search
  • Combine with Search - Search first, store the IDs of good results, then retrieve them later
  • Check Rating - Even with a known ID, verify the rating matches your requirements
  • Handle Deleted GIFs - Some GIFs may be removed; implement error handling for missing content

Error Handling

The node will return errors in the following cases:

  • ErrInvalidArg - ID parameter is empty or missing
  • ErrCredentials - API key is missing, invalid, or credential retrieval failed
  • ErrRuntime - Network error, API timeout, invalid API response, or GIF not found

Common Errors and Solutions

ErrorCauseSolution
ID cannot be emptyNo ID providedEnsure msg.ID 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 responseVerify GIF ID is correct and still exists
404 Not FoundGIF ID doesn't existVerify the ID is correct; GIF may have been deleted
403 ForbiddenInvalid API keyVerify API key is correct and active

Response Structure

{
"data": {
"type": "gif",
"id": "FiGiRei2ICzzG",
"url": "https://giphy.com/gifs/FiGiRei2ICzzG",
"slug": "funny-cat-FiGiRei2ICzzG",
"bitly_url": "http://gph.is/1bAzL7B",
"embed_url": "https://giphy.com/embed/FiGiRei2ICzzG",
"images": {
"original": {
"url": "https://media.giphy.com/media/FiGiRei2ICzzG/giphy.gif",
"width": "500",
"height": "281",
"size": "245123"
},
"downsized": { ... },
"fixed_height": { ... },
"fixed_width": { ... },
"preview_gif": { ... }
},
"title": "Funny Cat GIF",
"rating": "g",
"create_datetime": "2014-03-15 12:00:00",
"update_datetime": "2024-01-15 08:30:00",
"username": "username",
"user": {
"avatar_url": "...",
"display_name": "User Name",
"username": "username"
}
},
"meta": {
"status": 200,
"msg": "OK",
"response_id": "..."
}
}

Best Practices

  1. Always validate that the GIF ID is in the correct format (alphanumeric string)
  2. Implement error handling for cases where GIFs have been removed or deleted
  3. Store GIF IDs in your database rather than full URLs for long-term reliability
  4. Use this node in combination with search to build curated content libraries
  5. Cache retrieved GIF data if you'll be accessing the same GIF multiple times
  6. Consider the different image formats available and choose appropriate ones for your use case
  7. Respect user privacy when storing user-selected GIF IDs

Available Image Formats

When you retrieve a GIF by ID, the response includes multiple image formats:

  • original - Full resolution GIF
  • downsized - Smaller file size for faster loading
  • fixed_height - Standardized height for consistent layouts
  • fixed_width - Standardized width for consistent layouts
  • fixed_height_small - Thumbnail size with fixed height
  • fixed_width_small - Thumbnail size with fixed width
  • preview_gif - Very small preview for quick loading
  • downsized_still - Static image (first frame)

Choose the appropriate format based on your use case to optimize performance and user experience.