Emoji list API and npm

August 2022
development
Python, npm

I developed a simple RESTful API and a Node package for querying emoji, since I needed one for developing EmojiPoll. For the first I used Python and FastAPI, and now is hosted on Deta.


import requests
import json

data=requests.get('https://emoji.deta.dev/random?n=10&skintones=False&nogroup=Symbols,Flags')
print(json.loads(data.text))
 
# ["☔","🤵‍♀️","🤍","🗿","🎥","👴","🏃","🥄","🧃","✌️"]

For both the tool there are several parameters, you can see them on the GitHub repository. One of them is the random option.

The data is parsed from the unicode website into a JSON list of dictionaries from which the emoji are retrieved (JSON file). Each dictionary presents several information reguarding an emoji, and can be retrieved using the verbose parameter. An example is reported.

{
        "emoji": "🌵",
        "description": "cactus",
        "group": "Animals & Nature",
        "subgroup": "plant-other",
        "code": "1F335",
        "status": "fully-qualified",
        "version": "E0.6"
    }

For what concerns the npm package, here is an example.

npm i emoji-random-list
var emoji = require("emoji-random-list")
console.log(emoji.random({n: 5, group: 'objects'}))
//[ '🪒', '📕', '🔋', '🔩', '💷' ]