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 🙏

© 2026 – Pkg Stats / Ryan Hefner

emoji-hub-api-client

v1.0.0

Published

A lightweight JavaScript and TypeScript client for the EmojiHub API, allowing easy access to emojis by category, group, search, and random selection.

Downloads

109

Readme

emoji-hub-api-banner-2

Emoji Hub API Client

A lightweight JavaScript/TypeScript client for the EmojiHub API (https://github.com/cheatsnake/emojihub), providing easy access to emojis by category, group, search, and random selection. This package is ESM-only and works in modern browsers and Node.js 18+ environments that support the Fetch API.

📦 Installation

npm install emoji-hub-api-client

Note: If you are using Node.js, ensure your project supports ES modules.

🎲 Features

  1. Lightweight & fast — minimal abstraction over the EmojiHub API
  2. Zero dependencies — uses the native fetch API
  3. JavaScript & TypeScript support — includes type definitions out of the box
  4. Search emojis by name
  5. Fetch random emojis
  6. Filter emojis by category or group
  7. Retrieve all available categories and groups

📚 API Functions

The emoji-hub-api-client package exposes the following functions:

  1. getAllEmojiCategories(): Retrieve a list of all available emoji categories.
  2. getAllEmojiGroups(): Retrieve a list of all available emoji groups.
  3. getAllEmojis(): Fetch all emojis available in the EmojiHub API.
  4. getRandomEmoji(): Fetch a single random emoji.
  5. getRandomEmojiByCategory(): Fetch a random emoji from a specific category.
  6. getRandomEmojiByGroup(): Fetch a random emoji from a specific group.
  7. searchEmojisByName(): Search emojis by name.
  8. searchSimilarEmojisByName(): Retrieve emojis with names similar to the provided emoji name.

🔤 Example Usage

  1. Get All Emoji Categories
import { getAllEmojiCategories } from "emoji-hub-api-client";

async function run() {
  const response = await getAllEmojiCategories();
  if (response.code === "api-ok" && response.payload) {
    console.log(response.payload.categories);
  } else {
    console.error("Failed to fetch categories:", response.message);
  }
}
run();

// 200:OK
/*
{
  "code": "api-ok",
  "message": "No error encountered",
  "payload": {
    "categories": [
      "smileys and people",
      "animals and nature",
      "food and drink",
      "travel and places"
      ...
      ...
    ]
  }
}
*/

// Error
/*
{
    code: "api-fail",
    message: "Get All Emoji Categories: Encountered Error!",
    payload: null
}
*/
  1. Get All Emoji Groups
import { getAllEmojiGroups } from "emoji-hub-api-client";

async function run() {
  const response = await getAllEmojiGroups();
  if (response.code === "api-ok" && response.payload) {
    console.log(response.payload.groups);
  } else {
    console.error("Failed to fetch groups:", response.message);
  }
}
run();

// 200:OK
/*
{
  "code": "api-ok",
  "message": "No error encountered",
  "payload": {
    "groups": [
      "face positive",
      "face neutral",
      "face negative",
      "animal mammal",
      "animal bird"
      ...
      ...
      ...
    ]
  }
}
*/

// Error
/* { code: "api-fail", message: "Get All Emoji Groups: Encountered Error", payload: null }; */
  1. Get All Emojis
import { getAllEmojis } from "emoji-hub-api-client";

async function run() {
  const response = await getAllEmojis();
  if (response.code === "api-ok" && response.payload) {
    // Log the first emoji as a sample
    console.log("Sample emoji:", response.payload[0]);
  } else {
    console.error("Failed to fetch emojis:", response.message);
  }
}
run();

// 200:OK
/*
{
  "code": "api-ok",
  "message": "No error encountered",
  "payload": [
    {
      "name": "grinning face",
      "category": "smileys and people",
      "group": "face positive",
      "htmlCode": ["😀"],
      "unicode": ["U+1F600"]
    }
    ...
    ...
    ...
  ]
}
*/

// Error
/*
{
    code: "api-fail",
    message: "Get All Emoji: Encountered Error!",
    payload: null
}
*/
  1. Get A Random Emoji
import { getRandomEmoji } from "emoji-hub-api-client";

async function run() {
  const response = await getRandomEmoji();
  if (response.code === "api-ok" && response.payload) {
    console.log(response.payload);
  } else {
    console.error("Failed to fetch random emoji:", response.message);
  }
}
run();

// 200:OK
/*
{
  "code": "api-ok",
  "message": "No error encountered",
  "payload": {
    "name": "rocket",
    "category": "travel and places",
    "group": "transport air",
    "htmlCode": ["🚀"],
    "unicode": ["U+1F680"]
  }
}
*/

// Error
/*
{
    code: "api-fail",
    message: "Get Random Emoji: Encountered Error!",
    payload: null
}
*/
  1. Get a Random Emoji by Category
/* Note: To get the type of categories, check the getAllEmojiCategories() function response */
import { getRandomEmojiByCategory } from "emoji-hub-api-client";

async function run() {
  const response = await getRandomEmojiByCategory({
    category: "smileys-and-people" /* join with hyphen if there are more than 2 words */
  });

  if (response.code === "api-ok" && response.payload) {
    console.log(response.payload);
  } else {
    console.error("Failed to fetch random emoji by category:", response.message);
  }
}
run();

// 200:OK
/*
{
  "code": "api-ok",
  "message": "No error encountered",
  "payload": {
    "name": "grinning face",
    "category": "smileys and people",
    "group": "face positive",
    "htmlCode": ["😀"],
    "unicode": ["U+1F600"]
  }
}
*/

// Error
/*
{
    code: "api-fail",
    message: "Get Random Emoji By Category: Encountered Error!",
    payload: null
}
*/
  1. Get Random Emoji By Group
/* Note: to get the names of the groups, check the getAllEmojiGroups() function response */
import { getRandomEmojiByGroup } from "emoji-hub-api-client";

async function run() {
  const response = await getRandomEmojiByGroup({
    group: "face-positive" /* join with hyphen if there are more than 2 words*/
  });

  if (response.code === "api-ok" && response.payload) {
    console.log(response.payload);
  } else {
    console.error("Failed to fetch random emoji by group:", response.message);
  }
}
run();

// 200:OK
/*
{
  "code": "api-ok",
  "message": "No error encountered",
  "payload": {
    "name": "smiling face with sunglasses",
    "category": "smileys and people",
    "group": "face positive",
    "htmlCode": ["😎"],
    "unicode": ["U+1F60E"]
  }
}
*/

// Error
/*
{
    code: "api-fail",
    message: "Get Random Emoji By Group: Encountered Error!",
    payload: null
}
*/
  1. Search An Emoji By Name/Query
import { searchEmojisByName } from "emoji-hub-api-client";

async function run() {
  const response = await searchEmojisByName({
    query: "smile"
  });

  if (response.code === "api-ok" && response.payload) {
    console.log(`Total results: ${response.payload.totalResults}`);
    console.log(response.payload.results);
  } else {
    console.error("Failed to search emojis:", response.message);
  }
}
run();

// 200:OK
/*
{
  "code": "api-ok",
  "message": "No error encountered",
  "payload": {
    "totalResults": 2,
    "results": [
      {
        "name": "smiling face",
        "category": "smileys and people",
        "group": "face positive",
        "htmlCode": ["😊"],
        "unicode": ["U+1F642"]
      },
      {
        "name": "smiling face with sunglasses",
        "category": "smileys and people",
        "group": "face positive",
        "htmlCode": ["😎"],
        "unicode": ["U+1F60E"]
      }
    ]
  }
}
*/

// Error
/*
{
    code: "api-fail",
    message: "Search Emoji(s) By Name: Encountered Error!",
    payload: null
}
*/
  1. Get Similar Emoji(s) By Name/Query
import { searchSimilarEmojisByName } from "emoji-hub-api-client";

async function run() {
  const response = await searchSimilarEmojisByName({
    query: "heart"
  });
  if (response.code === "api-ok" && response.payload) {
    console.log(`Total similar emojis found: ${response.payload.totalResults}`);
    console.log(response.payload.results);
  } else {
    console.error("Failed to search similar emojis:", response.message);
  }
}
run();

// 200:OK
/*
{
  "code": "api-ok",
  "message": "No error encountered",
  "payload": {
    "totalResults": 3,
    "results": [
      {
        "name": "red heart",
        "category": "smileys and people",
        "group": "emotion",
        "htmlCode": ["❤"],
        "unicode": ["U+2764"]
      },
      {
        "name": "orange heart",
        "category": "smileys and people",
        "group": "emotion",
        "htmlCode": ["🟧"],
        "unicode": ["U+1F9E7"]
      },
      {
        "name": "yellow heart",
        "category": "smileys and people",
        "group": "emotion",
        "htmlCode": ["💛"],
        "unicode": ["U+1F49B"]
      }
    ]
  }
}
*/

// Error
/*
{
    code: "api-fail",
    message: "Search Similar Emoji(s) By Name: Encountered Error!",
    payload: null
}
*/

📘 Contributing

Contributions, suggestions, and improvements are welcome. Feel free to open issues or pull requests.

❤️ Support

Like this project? Support it with a github star, it would mean a lot to me! Cheers and Happy Coding.