5.5.0 • Published 4 days ago

@giphy/js-fetch-api v5.5.0

Weekly downloads
21,942
License
MIT
Repository
-
Last release
4 days ago

@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

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' })

trending

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 })

related

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
5.5.0

4 days ago

5.5.0-beta.1

13 days ago

5.5.0-charlie.0

12 days ago

5.5.0-beta.0

13 days ago

5.4.0

2 months ago

5.3.0

4 months ago

5.1.0

9 months ago

5.2.0

7 months ago

4.9.3

11 months ago

5.0.0

11 months ago

4.9.0

1 year ago

4.9.2

11 months ago

4.9.1

12 months ago

4.8.2-alpha.0

1 year ago

4.8.1

1 year ago

4.8.0

1 year ago

4.7.1

1 year ago

4.6.0

1 year ago

4.5.0

1 year ago

4.7.0

1 year ago

4.4.0

2 years ago

4.2.2

2 years ago

4.2.1

2 years ago

4.3.1

2 years ago

4.3.0

2 years ago

4.2.0

2 years ago

4.1.2

3 years ago

4.1.1

3 years ago

4.1.0

3 years ago

4.0.3

3 years ago

4.0.2

3 years ago

4.0.1

3 years ago

3.0.2-alpha.0

3 years ago

4.0.0

3 years ago

3.0.3-alpha.0

3 years ago

3.0.1-alpha.0

3 years ago

3.0.0

3 years ago

2.4.0

3 years ago

2.3.0

3 years ago

2.2.2

3 years ago

2.2.0

3 years ago

2.1.0

3 years ago

1.8.1

3 years ago

2.0.1

3 years ago

2.0.1-alpha.0

3 years ago

2.0.0-alpha.0

3 years ago

1.8.0

3 years ago

1.7.0

4 years ago

1.6.2

4 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.5.9

4 years ago

1.5.8

4 years ago

1.5.7

4 years ago

1.5.6

4 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.4

4 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago