Search⌘ K
AI Features

Fetch the GIF(s)

Explore how to use the GIPHY SDK functions to fetch GIFs by their unique IDs or by specific categories and subcategories. Learn practical examples of retrieving single and multiple GIFs and understand how these SDK methods simplify interactive media integration.

In this lesson, we’ll explore two SDK functions: gif (fetches GIF by ID) and gifs (fetches multiple GIFs by IDs).

GIF by ID

Earlier in the course, we discussed how we can use the API endpoint, GIF by ID, to fetch a GIF by using its ID. Now, we’ll see how we can do the same using the SDK function, gif. This SDK function takes in the GIF ID and returns the details of the requested GIF.

The base signature for this SDK is mentioned in the code widget below:

gif(id: string): Promise<GifResult>

Here is an example call for this function:

import { GiphyFetch } from '@giphy/js-fetch-api'
const gf = new GiphyFetch('yourGIPHYapikey')
const { data: gif } = await gf.gif('bzUwzbxcvJ3XQlcnoi')

The function above is used to get the ...