@giphy/js-fetch-api

中文文档
5.8.0发布于 2026/05/01MITTypeScriptESM + CJS构建来源已验证近 30 天下载 110.7万

Javascript API to fetch gifs and stickers from the GIPHY API.

原始使用文档
文档目录16 节
  1. Try it out:
  2. search
  3. trending
  4. gif by id
  5. gifs by ids, or category and subcategory
  6. animate
  7. related
  8. emoji
  9. emoji default variations
  10. emoji variations
  11. random
  12. categories
  13. subcategories
  14. Pagination Options
  15. Rating Option
  16. Type Option

@giphy/js-fetch-api

Javascript API to fetch gifs and stickers from the GIPHY API.

Get started with your own api key: https://developers.giphy.com/docs/

import { GiphyFetch } from '@giphy/js-fetch-api'

const gf = new GiphyFetch('your api key')

// fetch 10 gifs
const { data: gifs } = await gf.trending({ limit: 10 })

Try it out:

Edit @giphy/js-fetch-api

Fetch GIFs, Stickers, and Animated Text

Search all Giphy GIFs for a word or phrase. Punctuation will be stripped and ignored.

Signature:
search(term: string, options?: SearchOptions): Promise<GifsResult>
Search Options:
optiontypedescriptiondefault
langstringSee list of supported languages here.en
sortnumberSpecifies the starting position of the results.recent

Other Options: Type Option, Rating Option, Pagination Options

Example:
const { data: gifs } = await gf.search('dogs', { sort: 'relevant', lang: 'es', limit: 10, type: 'stickers' })

Fetch GIFs currently trending online. Hand curated by the Giphy editorial team. The data returned mirrors the GIFs showcased on the Giphy homepage.

Signature:
trending(options?: TrendingOptions): Promise<GifsResult>

Trending Options: Type Option, Rating Option, Pagination Options

Example:
const { data: gifs } = await gf.trending({ limit: 10, offset: 25, rating: 'g' })

gif by id

Fetch a gif by id

Signature:
gif(id: string): Promise<GifResult>
Example:
const { data: gif } = await gf.gif('3oEjHGr1Fhz0kyv8Ig')

gifs by ids, or category and subcategory

Signature:
// by id
gifs(ids: string[]): Promise<GifsResult>
// by category and subcategory
gifs(category: string, subcategory: string): Promise<GifsResult>
Example:
// by id
const { data: gifs } = await gf.gifs(['3oEjHGr1Fhz0kyv8Ig'])
// by category and subcategory
const { data: gifs } = await gf.gifs('tv', 'arrested-development')

animate

Create animated text gifs dynamicaly based on the text input. This endpoint will require you to create a new SDK key

Signature:
animate(text: string, options?: PaginationOptions): Promise<GifsResult>

Options: Pagination Options

Example:
const { data: gifs } = await gf.animate('some text to animate!', { limit: 5 })

Fetch related gifs based on the id of a gif

Signature:
related(id: string, options?: RelatedOptions): Promise<GifsResult>

Options: Pagination Options, Type Option

Example:
const { data: gifs } = await gf.related('3oEjHGr1Fhz0kyv8Ig', { limit: 10 })

emoji

Fetch emoji. Emoji are stickers from a currated channel. There's no search or trending emoji.

Signature:
emoji(options?: PaginationOptions): Promise<GifsResult>

Emoji Options: Pagination Options

Example:
const { data: gifs } = await gf.emoji()

emoji default variations

Returns a list of all the default emoji variations.

Signature:
emojiDefaultVariations(options?: PaginationOptions): Promise<GifsResult>

Options: Pagination Options

Example:
const { data: gifs } = await gf.emojiDefaultVariations()

emoji variations

Returns a list of gifs representing all the variations for the emoji.

Signature:
emojiVariations(id: GifID): Promise<NonPaginatedGifsResult>
Example:
const { data: gifs } = await gf.emojiVariations('iigp4VDyf5dCLRlGkm')

random

Returns a random single GIF

Signature:
random(options?: RandomOptions): Promise<GifResult>
Random Options:
optiontypedescriptiondefault
tagstringThe GIF tag to limit randomness by.undefined

Options: Type Option

Example:
const { data: gif } = await gf.random({ tag: 'beer', type: 'stickers' })

Fetch Categories and Subcategories

categories

categories(options?: CategoriesOptions): Promise<CategoriesResult>
const { data: categories } = await gf.categories()
categories.forEach((category) => {
    console.log(category) // ICategory
})

Options: Pagination Options

subcategories

subcategories(category: string, options?: SubcategoriesOptions): Promise<CategoriesResult>
// Example:
const { data: categories } = await gf.subcategories('tv', { limit: 10, offset: 25, rating: 'g' })
categories.forEach((category) => {
    console.log(category) // ICategory
})

Options: Pagination Options

Shared Options

Pagination Options

optiontypedescriptiondefault
limitnumberNumber of results to return, maximum 10025
offsetnumberSpecifies the starting position of the results.0

Rating Option

optiontypedescriptiondefault
ratingstringlimit results by rating: y, g, pg, pg-13, r.g

Type Option

optiontypedescriptiondefault
typestringgifs / stickers / text / videosgifs

版本与发布记录

@giphy/js-fetch-api 共发布 92 个版本,首次发布于 2019/03/27;过去 12 个月发布了 1 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
5.8.0latest2026/05/016 个月前
5.7.02025/07/091.4 年前
0.0.0-hidden-gifs-20250701132558hidden-gifs2025/07/011.4 年前
0.0.0-hidden-gifs-202506302035092025/07/011.4 年前
0.0.0-hidden-gifs-202506301954452025/07/011.4 年前
0.0.0-hidden-gifs-202506261950552025/06/271.4 年前

其他发布通道:canary → 0.0.0-canary-20230621031504,beta → 5.5.0-beta.1,charlie → 5.5.0-charlie.0,moat-testing → 0.0.0-moat-testing-20240502211419,hidden-gifs → 0.0.0-hidden-gifs-20250701132558。

关于 @giphy/js-fetch-api 的常见问题

@giphy/js-fetch-api 是什么?

Javascript API to fetch gifs and stickers from the GIPHY API.

如何安装 @giphy/js-fetch-api?

在项目目录运行 npm install @giphy/js-fetch-api,或使用 pnpm add / yarn add / bun add。

@giphy/js-fetch-api 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@giphy/js-fetch-api 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@giphy/js-fetch-api 可以商用吗?

@giphy/js-fetch-api 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@giphy/js-fetch-api 的下载量有多少?

根据 npm 官方下载统计,@giphy/js-fetch-api 在 2026/10/17 – 2026/11/15 这 30 天内被下载 1,107,222 次,日均约 36,907 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@giphy/js-fetch-api 还在维护吗?

最新版本 5.8.0 发布于 2026/05/01(6 个月前);至今共发布 92 个版本,其中过去 12 个月发布了 1 个;首次发布于 2019/03/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。