Skip to content
This repository has been archived by the owner on Jan 28, 2023. It is now read-only.

JavaScript module for querying various gif APIs.

License

Notifications You must be signed in to change notification settings

jamescallumyoung/gif-provider

Repository files navigation

⚠️ This package is no longer maintained.

gif-provider

A JavaScript module to search for gifs

npm package License: MIT

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.

Example Usage

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

Docs

Generate a local copy of the docs for offline use:

yarn install
yarn generate-docs
open docs/index.html

Contributing

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.

License

Copyright © 2020 James Young.
This project is MIT licensed. See LICENSE for more details.