giphy-api-without-credentials
Simple to use Node.js module for the giphy.com API. All search parameters and endpoints can be found on the Giphy API documentation.
This version is a minor tweak of Austin Kelleher's giphy-api module that simply sets withCredentials
to false
in the HTTP request.
Are you seeing this error in your browser app?
A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true.
If so, this right here is the module you're looking for.
Installation
npm i giphy-api-without-credentials -S
Importing
Since the original module receives the API key by invocation which is not supported by ES6 import
, you'll have to use require()
// If you have your own API key, use import the module like thisconst giphy = 'API KEY HERE';// If you're using the public api key you can just invoke without an argumentconst giphy = ;
Phrase search
Search all Giphy GIFs for a word or phrase. Supported parameters:
- q - search query term or phrase
- limit - (optional) number of results to return, maximum 100. Default 25.
- offset - (optional) results offset, defaults to 0.
- rating - limit results to those rated (y,g, pg, pg-13 or r).
- fmt - (optional) return results in html or json format (useful for viewing responses as GIFs to debug/test)
// Search with a plain stringgiphy;
// Search with optionsgiphy;
Giphy Id search
Search all Giphy gifs for a single Id or an array of Id's
//Search with a single Idgiphyid'feqkVgjJpYtjy' { };
// Search with an array of Id'sgiphyid 'feqkVgjJpYtjy' '7rzbxdu0ZEXLy' { };
Translate search
Experimental search endpoint for gif dialects. Supported parameters:
- s - term or phrase to translate into a GIF
- rating - limit results to those rated (y,g, pg, pg-13 or r).
- fmt - (optional) return results in html or json format (useful for viewing responses as GIFs to debug/test)
// Translate search with a plain stringgiphy;
// Translate search with optionsgiphy;
Random
Random gif(s) filtered by tag. Supported parameters:
- tag - the GIF tag to limit randomness by
- rating - limit results to those rated (y,g, pg, pg-13 or r).
- fmt - (optional) return results in html or json format (useful for viewing responses as GIFs to debug/test)
// Random gif by taggiphy;
// Random gif with optionsgiphy;
Trending
Trending gifs on The Hot 100 list
- limit (optional) limits the number of results returned. By default returns 25 results.
- rating - limit results to those rated (y,g, pg, pg-13 or r).
- fmt - (optional) return results in html or json format (useful for viewing responses as GIFs to debug/test)
// Trending Hot 100 gifsgiphy;
// Trending Hot 100 gifs with optionsgiphy;
Stickers
Animated stickers are gifs with transparent backgrounds. All giphy-api functions
support stickers except id, which is not a supported Giphy sticker endpoint.
In order to use the sticker API instead of the gif API, simply pass the api
property to a giphy-api function.
giphy;