tenor-api-wrapper
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

tenor-api-wrapper GitHub Workflow Status

A Lightweight JavaScript wrapper library for the Tenor API, written in Typescript.

A tool used to access the TenorAPI from anywhere using NodeJS. This package supports both CommonJS and ESM.

Installation

If you wish to install and use this package within your project, please make sure you are using the recommended node version or above before installing and are installing the latest version of this package.

# using NPM
npm install tenor-api-wrapper

# or using Yarn
yarn add tenor-api-wrapper

Usage

  • Attribution

To start of with, to comply with Tenor's policies, you must properly attribute all content retrieved from Tenor. To do so, include one of the following three options:

  • Powered By Tenor ∙ Use this attribution during the GIF browsing experience.
  • Search Tenor ∙ Use this attribution as the placeholder text in your search box.
  • Via Tenor ∙ Use this attribution in the footer of a shared GIF.

You can find attribution logos at the following location: https://media.tenor.com/website/gifapi-assets/index.html

  • Getting started

When using the Tenor API, you will require a API key which you can get one from https://developers.google.com/tenor/guides/quickstart, and this API key will grant this package access to the content posted on Tenor.com.

Assuming you have read the Guide above and have your API key, you can get stuck in with fetching content by doing the following:

// using ESM import
import TenorAPI from "tenor-api-wrapper";
const tenor = new TenorAPI("some-api-key");

// using CJS require
const TenorAPI = require("tenor-api-wrapper");
const tenor = new TenorAPI("some-api-key");

Then you can fetch posts made to Tenor.com as simple as:

// .fetch(by, term, options) => Promise<Result[]>
tenor.fetch('query', 'cats')
  .then(res => {
    // do something here...
  })
  .catch(console.error);

This will return a promise object array matching the fetch term and options provided, this would look like:

[
  {
    "id": "7831032585608380585",
    "debug_url": "https://tenor.googleapis.com/v2/search?q=cat&key=some-api-key&locale=en&limit=30",
    "source": "https://tenor.com/view/kitty-gif-25023528",
    "color": null,
    "data": {
      "title": null,
      "description": "Kitty GIF",
      "url: 'https://tenor.com/bQ9Vs.gif",
      "media": [
        {
          "key": "gif",
          "url": "https://c.tenor.com/bK1qpWGyQKkAAAAC/kitty.gif"
          "dims": [ 392, 498 ], // [ Width, Height ]
          "duration": null, // in Secs (only for mp4)
          "size": 5541234 // in Bytes
        },
        ...
      ],
      "hasCaption": false,
      "hasAudio": false, // (only for mp4)
      "flags": [ 'kitty' ],
      "tags": [ 'kitty' ],
      "timestamp": 1646164280.999305 // in Unix
    }
  }
]

Contributing

If you wish to contribute to this project, see the CONTRIBUTING.md file.

Package Sidebar

Install

npm i tenor-api-wrapper

Weekly Downloads

3

Version

0.1.0

License

Apache-2.0

Unpacked Size

63 kB

Total Files

23

Last publish

Collaborators

  • curingme