Skip to content

Unofficial static export of emoji technical information from Emojipedia. πŸ“™

License

Notifications You must be signed in to change notification settings

JoshuaKGoldberg/emojipedia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

The Emojipedia Technical Information Library

Unofficial static export of emoji technical information from Emojipedia. πŸ“™

πŸ‘ͺ All Contributors: 2 🀝 Code of Conduct: Kept πŸ§ͺ Coverage πŸ“ License: MIT πŸ“¦ npm version πŸ’ͺ TypeScript: Strict

Usage

npm i emojipedia

Data

The emojipedia package exports an emojipedia/data export of roughly all emojis on emojipedia. Data for each emoji can beΒ imported by its PascalCase name:

import { SparklingHeart } from "emojipedia/data";

console.log(SparklingHeart);
/*
{
	"code": "πŸ’–",
	"slug": "sparkling-heart",
	"title": "Sparkling Heart",
	// ...
}
*/

Alternately, you can import emoji data from the individual .json files by their kebab-case slug name using JSON import attributes:

import sparklingHeart from "emojipedia/data/sparkling-heart.json" with { type: "json" };

console.log(sparklingHeart);
/*
{
	"code": "πŸ’–",
	"slug": "sparkling-heart",
	"title": "Sparkling Heart",
	// ...
}
*/

Node.js APIs

The functions used to generate Emojipedia data are exported as well. In order from low-level to high-level:

  1. getEmoji
  2. getEmojis
  3. rebuildDirectory

getEmoji

Retrieves data for an emoji by its slug. This sends a single network request to the Emojipedia GraphQL API.

import { getEmoji } from "emojipedia";

const emoji = await getEmoji("sparkling-heart");
console.log(emoji);
/*
{
	"code": "πŸ’–",
	"slug": "sparkling-heart",
	"title": "Sparkling Heart",
	// ...
}
*/

See the TypeScript types for a complete description of emoji properties.

getEmojis

Retrieves data for an array of emoji slugs by calling getEmoji for each slug.

import { getEmojis } from "emojipedia";

const emojis = await getEmojis(["heart-on-fire", "sparkling-heart"]);
console.log(emojis);
/*
[
	{
		"code": "❀️‍πŸ”₯",
		"slug": "heart-on-fire",
		"title": "Heart on Fire",
		// ...
	},
	{
		"code": "πŸ’–",
		"slug": "sparkling-heart",
		"title": "Sparkling Heart",
		// ...
	}
]
*/

Note that network requests are p-throttle throttled to a maximum of 10 calls at each 100ms interval.

rebuildDirectory

Clears and recreates a directory to contain an index.mjs, an index.d.ts, and a *.json file for each emoji slug.

import { rebuildDirectory } from "emojipedia";

await rebuildDirectory({
	directory: "lib/data",
});

rebuildDirectory will call getEmojis with each of the emoji slugs as defined by unicode-emoji-json.

Contributors

Josh Goldberg ✨
Josh Goldberg ✨

πŸ’» πŸ–‹ πŸ“– πŸ€” πŸš‡ 🚧 πŸ“† πŸ”§ πŸ›
Megan Middleton
Megan Middleton

⚠️

πŸ’™ This package was templated with create-typescript-app.

About

Unofficial static export of emoji technical information from Emojipedia. πŸ“™

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks