Skip to main content

A lightweight utility for resolving emojis into file names, local asset paths, and URLs.

Project description

Twemoji API

PyPI Python License Downloads

A lightweight utility for resolving emojis into Unicode code points, local asset paths, and Twemoji URLs. Supports PNG and SVG assets and includes a similarity-based fallback system for emojis with modifiers (skin tones, ZWJ sequences, etc.).

Features

  • Convert emojis into Unicode code points
  • Resolve local Twemoji asset paths
  • Resolve URLs for PNG/SVG assets
  • Automatic fallback via similarity-based codepoint matching
  • Object-oriented access through Twemoji

Installation

pip install twemoji-api

Usage

Basic

from twemoji_api.api import get_emoji_path, get_emoji_url

print(get_emoji_path("🔥"))
print(get_emoji_url("🔥"))

Using Twemoji

from twemoji_api.api import Twemoji

emoji = Twemoji("👏🏻")

print(emoji.code_points)
print(emoji.path)
print(emoji.url)

Similarity Lookup

Useful for emojis with modifiers (skin tones) or multi-codepoint variants:

from twemoji_api.api import (
    get_emoji_code_points,
    get_emoji_code_points_by_similarity,
)

cp = get_emoji_code_points("👏🏻")
closest = get_emoji_code_points_by_similarity(cp)

print(closest)

API Reference

get_extension_folder(extension)

Returns the asset folder (72x72 or svg).

get_emoji_path(emoji, extension="png")

Returns the local file path for an emoji. Falls back to similar code points if an exact file is not found.

get_emoji_url(emoji, extension="png")

Returns the Twemoji GitHub URL for the asset.

get_emoji_code_points(emoji)

Extracts a list of Unicode code points from the emoji.

get_emojis_code_points_by_similarity(code_points)

Returns all file stems whose code points are a subset of the input.

get_emoji_code_points_by_similarity(code_points)

Returns the best matching file stem or None.

get_all_emojis(extension="png")

Returns a list of Twemoji objects for every emoji in the Twemoji database.

Twemoji

  • emoji
  • extension
  • path
  • code_points
  • url

License

MIT

Twemoji Attribution

This project includes graphics from Twemoji. Copyright 2019 Twitter, Inc and other contributors. Licensed under CC-BY 4.0: https://creativecommons.org/licenses/by/4.0/ No changes were made.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

twemoji_api-1.0.2.tar.gz (4.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

twemoji_api-1.0.2-py3-none-any.whl (8.5 MB view details)

Uploaded Python 3

File details

Details for the file twemoji_api-1.0.2.tar.gz.

File metadata

  • Download URL: twemoji_api-1.0.2.tar.gz
  • Upload date:
  • Size: 4.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for twemoji_api-1.0.2.tar.gz
Algorithm Hash digest
SHA256 83cfb495e2a04d00af72499291b1b68c2bf0d024c791343415324592f5af9eac
MD5 2d89306664d66f0c19a23a25481fff8c
BLAKE2b-256 432b8fc357ea08933a62509358432535586886ee565c94b3c1d1f478f7dba7f5

See more details on using hashes here.

File details

Details for the file twemoji_api-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: twemoji_api-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for twemoji_api-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 087c8a9eec8aa0711e2a434a4297319eccd57674ddc07b7fa1bb129436f4069f
MD5 836835d49ff7606512e47dded02fb0f9
BLAKE2b-256 023b2b1398f256f32636a715ce536a683e495148b32dccf41fe02190e5da5a0e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page