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 🙏

© 2025 – Pkg Stats / Ryan Hefner

giphy-random

v2.0.8

Published

Get random GIF from Giphy.

Downloads

1,129

Readme

Giphy Random

Build Status Test Covarage Greenkeeper Latest Version

Get random GIF from Giphy.

Installation

$ npm install giphy-random

If you want to use this library directly on the browser, you have to manually include the axios library too:

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>

<script src="https://unpkg.com/giphy-random/dist/giphy-random.umd.min.js"></script>

Usage

const giphyRandom = require("giphy-random");

(async () => {
  const API_KEY = "YOUR API KEY";

  const { data } = await giphyRandom(API_KEY);

  console.log(data);
})();

The data will contain a GIF Object.

To get your Giphy API key, sign up here: developers.giphy.com/dashboard.

Recipes

Filter by Tag

const giphyRandom = require("giphy-random");

(async () => {
  const API_KEY = "YOUR API KEY";

  const { data } = await giphyRandom(API_KEY, {
    tag: "cat"
  });

  console.log(data);
})();

Override the Default Rating

By default, Giphy will use the G—general audience—rating. To override this, pass the rating argument:

const giphyRandom = require("giphy-random");

(async () => {
  const API_KEY = "YOUR API KEY";

  const { data } = await giphyRandom(API_KEY, {
    rating: "pg-13"
  });

  console.log(data);
})();

API

giphyRandom()

giphyRandom(apiKey, [{ tag, rating }])

Parameters

  • apiKey (String): Your Giphy API key.
  • tag (optional String): The tag to filter the result.
  • rating (optional String): MPAA-style rating to filter the result, default to g.

Here's the rating value that you can pass:

You can pass the following value as rating:

  • y: Appropriate for all children
  • g: General audiences (default)
  • pg: Parental guidance suggested
  • pg-13: Parents strongly cautioned
  • r: Restricted

Return

It returns a Promise which when resolved contains a Giphy API response object. Here's an example of the resolved value with some properties that you might be interested in:

{
  data: {
    type: "gif",
    id: "H2fORSKZw4SCQ",
    slug: "cats-cat-gifs-kitten-H2fORSKZw4SCQ",
    url: "https://giphy.com/gifs/cats-cat-gifs-kitten-H2fORSKZw4SCQ",
    embed_url: "https://giphy.com/embed/H2fORSKZw4SCQ",
    source_post_url: "https://kittehkats.tumblr.com/post/101035478921/found-on-lh3-googleusercontent-com",
    images: {
      downsized: {
        url: "https://media1.giphy.com/media/H2fORSKZw4SCQ/giphy-downsized.gif",
        width: "210",
        height: "138",
        size: "1930051"
      },
      original: {
        url: "https://media1.giphy.com/media/H2fORSKZw4SCQ/giphy.gif",
        width: "210",
        height: "138",
        size: "1930051",
        frames: "165",
        mp4: "https://media1.giphy.com/media/H2fORSKZw4SCQ/giphy.mp4",
        mp4_size: "781811",
        webp: "https://media1.giphy.com/media/H2fORSKZw4SCQ/giphy.webp",
        webp_size: "1368374"
      }
      // Omitted...
    },
    title: "cat kitten GIF",
    image_url: "https://media1.giphy.com/media/H2fORSKZw4SCQ/giphy.gif",
    image_mp4_url: "https://media1.giphy.com/media/H2fORSKZw4SCQ/giphy.mp4",
    image_width: "210",
    image_height: "138",
    caption: ""
    // Omitted...
  },
  meta: {
    status: 200,
    msg: "OK",
    response_id: "5be8329e796b703936aff12b"
  }
}

Note that there are many properties omitted from the example above. Check Giphy documentation for more detail.

License

MIT © Risan Bagja Pradana

Legal

This code is in no way affiliated with, authorized, maintained, sponsored or endorsed by Giphy or any of its affiliates or subsidiaries. This is an independent and unofficial API.