Skip to main content

📦 EmojiDB

Simple python wrapper for emojidb.com.

⭐️ Usage

pip install emojidb-python

The library can be asynchronously and synchronously.

from asyncio import run
from emojidb import EmojiDBClient


async def main():
    async with EmojiDBClient() as client:
        emojis = await client.search("love")
        print(*emojis, sep=", ")

        client.like(emojis[0], query)

run(main())
from emojidb import EmojiDBClient

client = EmojiDBClient()
emojis = client.search("love")
print(*emojis, sep=", ")

You can also do more than just fetch emojis. All of those functions work both async and synchronously. Here are all functionalities.

from emojidb import EmojiDBClient

client = EmojiDBClient()

# fetch emojis
emojis = client.search("love")
print(*emojis, sep=", ")
# if you want to fetch similar emojis,
# you can just use the search function an pass in the emoji
emojis = client.search("🥺")
print(*emojis, sep=", ")

# like an emoji
client.like("🥺", "pleading face")

# dislike an emoji
client.dislike("🥺", "pleading face")

# suggest a new emoji
client.add_emoji("🥺", "pleading face")

If you want to change the caching behavior you can easily do so by just passing a custom cache class in the client.

from emojidb import EmojiDBClient, EmojiCache, DisableEmojiCache, EmojiCacheSqlite

# use sqlite as cache (DEFAULT with expires in 30 days)
client = EmojiDBClient(EmojiCacheSqlite(expire_after_days=1))

# disable the cache
client = EmojiDBClient(DisableEmojiCache())

# custom cache
class MemoryCache(EmojiCache):
    """
    This cache only caches everything in memory.
    When initializing a new client the cache wouldn't persist
    """
    def __init__(self):
        self.data = {}

    def has_cache(self, query: str) -> bool:
        return query in self.data

    def get_cache(self, query: str) -> List[str]:
        return self.data.get(query, [])

    def write_cache(self, query: str, emojis: List[str]):
        return self.data[query] = emojis

    def clear_cache(self):
        self.data = {}

client = EmojiDBClient(MemoryCache())

The functions EmojiCache.clean_cache() and EmojiCache.clear_cache() are never called by the client, but it is recommended to still implement them.

Programms that use this library can use these functions by doing this:

from emojidb import EmojiDBClient

client = EmojiDBClient(DisableEmojiCache())
client.cache.clean_cache()
client.cache.clear_cache()

Features

  • use an asynchronous client or a synchronous one
  • cache the results using sqlite
  • search for emojis
  • like and dislike emojis (please do not abuse that)

🪪 License

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.

Download files

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

Source Distribution

emojidb_client-1.1.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

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

emojidb_client-1.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file emojidb_client-1.1.0.tar.gz.

File metadata

  • Download URL: emojidb_client-1.1.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for emojidb_client-1.1.0.tar.gz
Algorithm Hash digest
SHA256 afbd740e71342f3f2c6d23a9ce972c643a891cfa20298d991b56031153c3925a
MD5 bfe5a68357229beec36160963baa4022
BLAKE2b-256 e7f6632ec3599a1f08a1f051859d41f7140ee81112252d1ccdb8423c45d154ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for emojidb_client-1.1.0.tar.gz:

Publisher: publish-to-pypi.yml on hazel-noack/emojidb-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file emojidb_client-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: emojidb_client-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for emojidb_client-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 904cb97f27149394f12119cf86f185fb3f0af8d043899a71da0d1aefe33177af
MD5 77c15018fcd45013d9a0a05ff3d20c5b
BLAKE2b-256 03f0efa82906efde16c2fa6a03e2559bfa002f27766ca094a549c386337a9b74

See more details on using hashes here.

Provenance

The following attestation bundles were made for emojidb_client-1.1.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on hazel-noack/emojidb-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 files

Supported by

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