Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@giphy/js-fetch-api

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@giphy/js-fetch-api

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

  • 5.6.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
94K
increased by3.1%
Maintainers
1
Weekly downloads
 
Created
Source

@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

FAQs

Package last updated on 28 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc