~ Web Development ~ Built using Python, npm

Emoji list API and npm

I developed a simple RESTful API and a Node package for querying emoji, since I needed one for developing EmojiPoll. The problem is that for emojis, unlike standard alphabet characters, it is not possible to get a random glyph from a set.

API

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 information regarding 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"
    }

npm

For what concerns the npm package, here is a very simple script that shows how it works.

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