Play around with Giphy's api in node
Node Giphy is a simple wrapper around Giphy's api.
$ npm install giphy
First you will need to use the development api key to test. It is dc6zaTOxFJmzC
but do not use this for production.
Information about production keys here
var giphy = require( 'giphy' )( 'put key here' );
// or
var Giphy = require( 'giphy' )
, giphy = new Giphy( 'put key here');
To see all available methods
console.log( giphy.getMethods() );
- search
- gifs ( multiple ids )
- gif ( single id )
- trending
- search
- translate
all methods pretty much have same api.
giphy[ methodName ]( [options,] callback );
so this url
http://api.giphy.com/v1/gifs?ids=feqkVgjJpYtjy,7rzbxdu0ZEXLy
would translate into
giphy.gifs( { ids : [ 'feqkVgjJpYtjy', '7rzbxdu0ZEXLy' ]}, handleGifs );
options object is optional as well, eg.
giphy.trending( handleTrending );
giphy uses the convention of error first then data. We also pass back some request information as well in the third argument
function handleTrending( err, trending, res ) {
// ...
}
giphy.trending( handleTrending );