Simple python wrapper for emojidb.com
Project description
📦 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/.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afbd740e71342f3f2c6d23a9ce972c643a891cfa20298d991b56031153c3925a
|
|
| MD5 |
bfe5a68357229beec36160963baa4022
|
|
| BLAKE2b-256 |
e7f6632ec3599a1f08a1f051859d41f7140ee81112252d1ccdb8423c45d154ce
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
emojidb_client-1.1.0.tar.gz -
Subject digest:
afbd740e71342f3f2c6d23a9ce972c643a891cfa20298d991b56031153c3925a - Sigstore transparency entry: 487740487
- Sigstore integration time:
-
Permalink:
hazel-noack/emojidb-python@a618676783a18594aa338329a1a9e9be402bb1bb -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/hazel-noack
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@a618676783a18594aa338329a1a9e9be402bb1bb -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
904cb97f27149394f12119cf86f185fb3f0af8d043899a71da0d1aefe33177af
|
|
| MD5 |
77c15018fcd45013d9a0a05ff3d20c5b
|
|
| BLAKE2b-256 |
03f0efa82906efde16c2fa6a03e2559bfa002f27766ca094a549c386337a9b74
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
emojidb_client-1.1.0-py3-none-any.whl -
Subject digest:
904cb97f27149394f12119cf86f185fb3f0af8d043899a71da0d1aefe33177af - Sigstore transparency entry: 487740509
- Sigstore integration time:
-
Permalink:
hazel-noack/emojidb-python@a618676783a18594aa338329a1a9e9be402bb1bb -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/hazel-noack
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@a618676783a18594aa338329a1a9e9be402bb1bb -
Trigger Event:
push
-
Statement type: