⚠️ This package is no longer maintained.
gif-provider is a JavaScript module that allows you to query 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 class implementing the GifStrategy interface.
The module includes its own optional typings for TypeScript.
See the API documentation here.
const {
GifProviderBuilder,
GiphyStrategy,
TenorStrategy,
GiphyClient,
TenorClient,
} = require('@jych/gif-provider');
const builder = new GifProviderBuilder();
// Querying Giphy
const giphyStrategy = new GiphyStrategy(
GiphyClient.init('my-giphy-api-key').some()
);
builder.addStrategy(giphyStrategy);
const gifProvider = builder.build();
const gifs = await gifProvider.search("rat mouse"); // gifs is an array of results from giphy
// Querying Giphy and Tenor
const tenorStrategy = new TenorStrategy(
TenorClient.init('my-tenor-api-key').some()
);
builder.addStrategy(tenorStrategy);
const gifProvider2 = builder.build();
const gifs = await gifProvider.search("rat mouse"); // gifs is a flat array of results from each site
Generate a local copy of the docs for offline use:
yarn install
yarn generate-docs
open docs/index.html
This package is no longer being maintained.
Contributions, issues and feature requests are no longer welcome! Feel free to check the
issues page for an idea of where to get
started. Contributors must follow the contributing guide and
code of conduct.
Copyright © 2020 James Young.
This project is MIT licensed. See LICENSE for more details.