@diqi/emoji-search v0.7.0
Emoji Search TS
A simple TypeScript library for searching emojis based on names, keywords, emoticons, tags, and country codes. It uses an enriched emoji dataset generated by the DeepSeek API.
npm install @diqi/emoji-searchFeatures
- Search emojis by
- Name (e.g., "cat face", "heart")
- Semantic keywords (e.g., "love", "sad", "party")
- Common emoticons (e.g.,
:), :P, <3, :x) - Tags (e.g., "animal", "food", "flag")
- Country code (e.g., "US", "GB", "DE")
- Uses a pre-generated JSON file for fast, local searching (no external API calls at runtime).
- Includes a script to generate the enriched JSON data using the DeepSeek API.
Prerequisites
- Node.js and npm: Required for running the TypeScript package and build/test scripts. (Download Node.js)
- Python 3: Required for the metadata generation script. (Download Python)
- DeepSeek API Key: You need an API key from DeepSeek. (Sign up/Login at DeepSeek)
Setup
git clone https://github.com/dqii/emoji-search
cd emoji-search
npm install
pip install requests python-dotenvAdd your DeepSeek API key to .env:
DEEPSEEK_API_KEY=YOUR_DEEPSEEK_API_KEY_HEREData Generation (One-time Step)
The search functionality relies on an enriched data file (emojis-expanded.json) which needs to be generated using the provided Python script and your DeepSeek API key.
Ensure
.envfile is set up with yourDEEPSEEK_API_KEY.Run the generation script: From the project root directory (
emoji-search), run:python scripts/generate_metadata.pyThis script will:
- Read your API key from the
.envfile. - Read the base
emojis.jsonfile. - Query the DeepSeek API for each emoji to generate keywords, emoticons, descriptions, tags, and country codes.
- Write the results to
emojis-expanded.jsonin the project root.
This process can take several minutes depending on your system, the number of emojis, and DeepSeek API limits/latency.
(Note: If you modify
emojis.jsonlater, you'll need to re-run this script.)- Read your API key from the
Usage
npm install @diqi/emoji-searchimport { searchEmojis } from '@diqi/emoji-search';
// --- Examples ---
// Search by keyword
const happyEmojis = searchEmojis('happy');
console.log('Happy:', happyEmojis.map(e => e.emoji));
// Example Output: Happy: [ 'ð', 'ð', 'ð', 'ð', 'ð', 'ð
', 'ðĪĢ', 'ð', 'ð', 'ð', 'ðĨ°', 'ðĨģ' ] (Results may vary based on generated data)
// Search by emoticon
const tongueEmojis = searchEmojis(':p');
console.log('Tongue Out:', tongueEmojis.map(e => e.emoji));
// Example Output: Tongue Out: [ 'ð', 'ð', 'ðĪŠ', 'ð' ]
// Search by country code
const ukFlag = searchEmojis('gb');
console.log('UK Flag:', ukFlag.map(e => e.emoji));
// Example Output: UK Flag: [ 'ðŽð§' ]
// Search by name fragment
const catEmojis = searchEmojis('cat face');
console.log('Cat Faces:', catEmojis.map(e => e.emoji));
// Example Output: Cat Faces: [ 'ðš', 'ðļ', 'ðđ', 'ðŧ', 'ðž', 'ð―', 'ð', 'ðŋ', 'ðū' ]
// Limit results
const limitedFlags = searchEmojis('flag', 5);
console.log('Flags (max 5):', limitedFlags.map(e => e.emoji));Development
Commands
git clone https://github.com/dqii/emoji-search
cd emoji-search
npm install
pip install requestsBuild and test
npm run build
npm testPublishing to npm
Ensure you have an npm access token with publish permissions in your .npmrc file.
//registry.npmjs.org/:_authToken=NPM_ACCESS_TOKENBefore publishing, ensure you increment the version field in package.json.
npm login
npm run build
npm publish --access public