https://github.com/joshuakgoldberg/emojipedia
Unofficial static export of technical information from Emojipedia. π
https://github.com/joshuakgoldberg/emojipedia
emojipedia emojis unicode
Last synced: 6 months ago
JSON representation
Unofficial static export of technical information from Emojipedia. π
- Host: GitHub
- URL: https://github.com/joshuakgoldberg/emojipedia
- Owner: JoshuaKGoldberg
- License: mit
- Created: 2024-03-14T18:14:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-14T00:42:22.000Z (6 months ago)
- Last Synced: 2025-04-14T01:31:13.892Z (6 months ago)
- Topics: emojipedia, emojis, unicode
- Language: TypeScript
- Homepage:
- Size: 285 KB
- Stars: 17
- Watchers: 2
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
The Emojipedia Technical Information Library
Unofficial static export of emoji technical information from Emojipedia. π
## Usage
```shell
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:
```ts
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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import/with#description):
```ts
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`](#getemoji)
1. [`getEmojis`](#getemojis)
1. [`rebuildDirectory`](#rebuilddirectory)
#### `getEmoji`
Retrieves data for an emoji by its slug.
This sends a single network request to the Emojipedia GraphQL API.
```ts
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`](#getemoji) for each slug.
```ts
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](https://github.com/sindresorhus/p-throttle) 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.
```ts
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`](https://github.com/muan/unicode-emoji-json).
## Contributors

Josh Goldberg β¨
π» π π π€ π π§ π π§ π

Megan Middleton
β οΈ
> π This package was templated with [`create-typescript-app`](https://github.com/JoshuaKGoldberg/create-typescript-app).