@giphy/js-fetch-api (英语)
Javascript API 从 GIPHY API 取出 gifs 和标签 .
用您自己的 api 键开始 : 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 })
试试看:
获取 GIF 、 标签和动画文本
搜索
搜索所有 Giphy GIFs 的单词或短语 。 平按:"灵枢"作平取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取.
签署:
search(term: string, options?: SearchOptions): Promise<GifsResult>
搜索选项 :
| 选项 | 类型 | 说明 | 默认 |
|---|---|---|---|
| 朗语 | 字符串 | 参见所支持语言列表 这里。 。 。 . | 内 |
| 排序 | 编号 | 指定结果的起始位置. | 近期 |
示例
const { data: gifs } = await gf.search('dogs', { sort: 'relevant', lang: 'es', limit: 10, type: 'stickers' })
趋势
获取当前在线GIFs 趋势 。 由吉菲编辑组主持. 数据还原镜像了Giphy主页上显示的GIFs.
签署:
trending(options?: TrendingOptions): Promise<GifsResult>
示例
const { data: gifs } = await gf.trending({ limit: 10, offset: 25, rating: 'g' })
由 id 编辑
由 id 获取一个 gif
签署:
gif(id: string): Promise<GifResult>
示例
const { data: gif } = await gf.gif('3oEjHGr1Fhz0kyv8Ig')
按标识,或类别和子类别
签署:
// by id
gifs(ids: string[]): Promise<GifsResult>
// by category and subcategory
gifs(category: string, subcategory: string): Promise<GifsResult>
示例
// by id
const { data: gifs } = await gf.gifs(['3oEjHGr1Fhz0kyv8Ig'])
// by category and subcategory
const { data: gifs } = await gf.gifs('tv', 'arrested-development')
动画
基于文本输入创建动画文本 gifs 动态 。 这个终点需要你 创建新的 SDK 密钥
签署:
animate(text: string, options?: PaginationOptions): Promise<GifsResult>
选项 : 缓冲选项
示例
const { data: gifs } = await gf.animate('some text to animate!', { limit: 5 })
相关
基于 gif 的 ID 获取相關的 gifs
签署:
related(id: string, options?: RelatedOptions): Promise<GifsResult>
示例
const { data: gifs } = await gf.related('3oEjHGr1Fhz0kyv8Ig', { limit: 10 })
爱莫吉
去找爱莫吉 爱莫吉是来自曲艺频道的贴纸 没有搜索或趋势 emoji.
签署:
emoji(options?: PaginationOptions): Promise<GifsResult>
Emoji 选项 : 缓冲选项
示例
const { data: gifs } = await gf.emoji()
emoji 默认变化
返回所有默认的 emoji 变换的列表 .
签署:
emojiDefaultVariations(options?: PaginationOptions): Promise<GifsResult>
选项 : 缓冲选项
示例
const { data: gifs } = await gf.emojiDefaultVariations()
情感变化
返回一个代表 emoji 的所有变量的 gifs 列表.
签署:
emojiVariations(id: GifID): Promise<NonPaginatedGifsResult>
示例
const { data: gifs } = await gf.emojiVariations('iigp4VDyf5dCLRlGkm')
随机
返回随机单个 GIF
签署:
random(options?: RandomOptions): Promise<GifResult>
随机选项 :
| 选项 | 类型 | 说明 | 默认 |
|---|---|---|---|
| 标签 | 字符串 | GIF 标记以限制随机性 . | 未定义 |
选项 : 类型选项
示例
const { data: gif } = await gf.random({ tag: 'beer', type: 'stickers' })
获取类别和子类别
类别
categories(options?: CategoriesOptions): Promise<CategoriesResult>
const { data: categories } = await gf.categories()
categories.forEach((category) => {
console.log(category) // ICategory
})
选项 : 缓冲选项
亚类
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
})
选项 : 缓冲选项
共享选项
缓冲选项
| 选项 | 类型 | 说明 | 默认 |
|---|---|---|---|
| 限制 | 编号 | 最多返回100个结果数目 | 第25条 |
| 页:1 | 编号 | 指定结果的起始位置. | 0 个 |
评分选项
| 选项 | 类型 | 说明 | 默认 |
|---|---|---|---|
| 评级 | 字符串 | 通过评级限制结果 : y, g, pg, pg-13, pg-13, r (英语)。 。 。 . | 页:1 |
类型选项
| 选项 | 类型 | 说明 | 默认 |
|---|---|---|---|
| 类型 | 字符串 | gifs / 标签 / 文本 / 视频 | 数字 |