0.5.0 • Published 6 years ago
@jych/gif-provider v0.5.0
gif-provider
gif-provider is a JavaScript module that allows you to querying various gif APIs. Queries can be done to a single API at a time, or to multiple, with the results aggregated.
The module currently supports fetching gifs from Giphy and Tenor. Other APIs may be added in the future.
You can easily extend gif-provider to support other APIs, either by contributing on GitHub, or by implementing your own GifProvider class.
See the API documenntation here.
Installation
npm install --save @jych/gif-provider
Getting Started
Installing
In Node and CommonJS build systems:
const {GiphyGifProvider} = require('@jych/gif-provider');
In ES6 Modules and Typescript:
import {GiphyGifProvider} from 'jych/gif-provider';
Example Usage
Querying Giphy:
const {GiphyGifProvider} = require('@jych/gif-provider');
const gifProvider = new GiphyGifProvider();
gifProvider.search("rat mouse")
.then( gifs => {
// ...
} );
Querying multiple sites:
const {CompositeGifProvider, GifProviderFactory} = require('@jych/gif-provider');
const providers = GifProviderFactory.getProviders([ "giphy", "tenor", "some-other-site" ];
const gifProvider = new CompositeGifProvider(providers);
gifProvider.search("rat mouse")
.then( gifs => {
// gifs is a flat array of results from each site
// ...
} );
Docs
A full copy of the docs can be generated for offline use:
npm install @jych/gif-provider
cd node_modules/@jych/gif-provider
npm install
npm run generate-docs
open docs/index.html