npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tenor-gif-api

v1.0.3

Published

A simple and easy-to-use wrapper for the Tenor API, enabling quick and effective integrations.

Downloads

220

Readme

tenor-gif-api

Introduction

tenor-gif-api is a simple and easy-to-use wrapper for the Tenor API, enabling quick and effective integrations for searching and sharing GIFs and stickers. This package simplifies the process of interacting with Tenor's extensive multimedia library.

For more detailed information about the Tenor API, visit the official Tenor API documentation.

Installation

Install the package via npm:

npm install tenor-gif-api

Usage

Basic Example Here's a quick example of how to use tenor.js to search for GIFs:

import { TenorClient } from 'tenor.js';

const client = new TenorClient('YOUR_API_KEY');

async function searchGIFs() {
  const response = await client.search.query({ q: 'funny', limit: 5 });
  console.log(response.results);
}

searchGIFs();

Services

Search

Search for GIFs, stickers, and other media.

Copiar código
const response = await client.search.getGIFs({ q: 'hello', limit: 10 });

Featured

Get a list of the current global featured GIFs.

const response = await client.featured.getFeatured({ limit: 5 });

Categories

Retrieve a list of GIF categories.

const response = await client.categories.getCategories();

Suggestions

Get a list of alternative search terms for a given search term.

const response = await client.suggestions.getSuggestions({ q: 'happy' });

Autocomplete

Fetch a list of completed search terms for a given partial search term.

const response = await client.autocomplete.getAutocomplete({ q: 'fun' });

Trending

Fetch a list of the current trending search terms.

const response = await client.trending.getTrendingTerms();

Register Share

Register a user's sharing of a GIF or sticker.

await client.registerShare.registerShare({ id: 'GIF_ID' });

Posts

Fetch GIFs, stickers, or a combination of both for the specified IDs.

const response = await client.posts.getPosts({ ids: 'GIF_ID' });

API Reference

TenorClient

The TenorClient class provides access to all services available through the Tenor API.

Constructor

constructor(apiKey: string, clientKey?: string)
  • apiKey: Your Tenor API key.
  • clientKey: Optional. A unique client key to differentiate integrations.

Services Overview

  • search: Handles searching for GIFs, stickers, and other content.
  • featured: Retrieves featured content.
  • categories: Fetches available categories.
  • suggestions: Provides search suggestions.
  • autocomplete: Autocompletes search terms.
  • trending: Gets trending search terms.
  • registerShare: Registers user shares.
  • posts: Fetches posts by ID.

For detailed parameters and examples for each service, refer to the API documentation.

Configuration

To use tenor.js, you need to configure your API key. Optionally, you can provide a clientKey to differentiate your integrations.

Setting the API Key You can set the API key when initializing TenorClient:

const client = new TenorClient('YOUR_API_KEY');
  • Optional Configuration
  • clientKey: A unique string to differentiate multiple integrations.

Error Handling

All methods return promises that may reject with errors. Use try...catch blocks or .catch() methods to handle errors.

try {
  const response = await client.search.getGIFs({ q: 'oops' });
} catch (error) {
  console.error('Error fetching GIFs:', error);
}

Contributing

Contributions are welcome! Please follow these steps:

  1. Clone the repository.
  2. Create a new branch (git checkout -b feature/my-feature).
  3. Commit your changes (git commit -am 'Add some feature').
  4. Push to the branch (git push origin feature/my-feature).
  5. Create a new Pull Request.

Please make sure your code passes all tests before submitting a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you encounter any issues or have questions, feel free to open an issue on the GitHub repository.

Changelog

All notable changes to this project will be documented in this section.

Acknowledgements Special thanks to the developers at Tenor for providing a robust and versatile API.

FAQ

Q: How do I get an API key?

A: You can obtain an API key by signing up at the Tenor API website.

Q: Can I use this package in a Node.js environment?

A: Yes, tenor.js is designed to work in both browser and Node.js environments.