Git Product home page Git Product logo

gfycat-sdk's Introduction

gfycat-sdk

NPM

Build Status

Javascript API wrapper for Gfycat.com API that supports callbacks and promises.

Installation

npm install gfycat-sdk --save

Usage

Obtain a client_id and client_secret for your integration from the Gfycat developers portal.

const Gfycat = require('gfycat-sdk');

var gfycat = new Gfycat({clientId: YOUR_CLIENT_ID, clientSecret: YOUR_CLIENT_SECRET});

For security reasons, we suggest storing the client id and secret in a secure location.

Methods

Authenticate

Returns a callback, or promise that resolves to the api authentication token that is valid for 1 hour

Callback

gfycat.authenticate((err, data) => {
  //Your app is now authenticated
  assert.equal(data.access_token, gfycat.token);
  console.log('token', gfycat.token);
})

Promise

gfycat.authenticate().then(res => {
  //Your app is now authenticated
  assert.equal(res.access_token, gfycat.token);
  console.log('token', gfycat.token);
});

Search

Returns a promise that resolves to a gfycats object. API supports pagination using cursors and count/first. The optional random attribute will randomize the result returned by the API - do not supply pagination attributes with this.

let options = {
  search_text: 'hello',
  count: 20,
  first: 30
};

gfycat.search(options).then(data => {
  console.log('gfycats', data);
});

Get User Details

Returns user account information by username

let options = {
  userId: 'myUsername'
};

gfycat.getUserDetails(options).then(data => {
  console.log(data);
});

Get Gfycat Details

Return Gfycat json by gfycat name

let options = {
  gfyId: 'richpepperyferret'
};

gfycat.getGifDetails(options).then(data => console.log(data))

Get Related Content

Return a list of Gfycats related to the one provided.

let options = {
  gfyId: 'richpepperyferret'
};

gfycat.getRelatedContent(options).then(data => console.log(data))

Get User Feed

Return the gfycats uploaded and shared by a given username.

let options = {
  userId: 'myUsername'
};

gfycat.userFeed(options).then(data => console.log(data))

Get Trending GIFs

Return JSON of currently trending gifs

let options = {
  count: 10,
  cursor: ''
}

gfycat.trendingGifs(options).then(data => console.log(data))

Get Trending Tags

Return JSON of currently trending tags

let options = {
  count: 10,
  populated: false
}

gfycat.trendingTags(options).then(data => console.log(data))

gfycat-sdk's People

Contributors

abinnewies avatar kngroo avatar koshka avatar nickretallack avatar nytrox avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.