A simple asynchronous wrapper for the donatello API written in Python.
Project description
💸 Donatello-py
Simple python wrapper for the Donatello API.
Features
- Full type hints
- Client info
- Get donates
- Get clients
- Long polling
- Add Async support
Installation
pip install donatello-py
For speedup install ujson
pip install ujson
Basic Usage
Get and activate your API key here.
Sync
from donatello import Donatello
client = Donatello("YOUR_API_KEY")
# Get client info
print(client.get_me())
# Get donates
print(client.get_donates(page=1, per_page=10))
# Get clients
print(client.get_clients())
Async
from donatello import AsyncDonatello
client = AsyncDonatello("YOUR_API_KEY")
async def main():
print(await client.get_me())
print(await client.get_donates(page=1, per_page=10))
print(await client.get_clients())
asyncio.run(main())
Long polling
For use long polling you need to create widget here and get widget id from url.
Example url:
https://donatello.to/widget/<WIDGET_ID>/token/<YOUR_API_KEY>
Code example
Sync
from donatello import Donatello
from donatello.models import Donate, User
client = Donatello("YOUR_API_KEY", "WIDGET_ID")
@client.on_ready
def start(user: User):
print(f"Started with user {user.nickname}")
print(f"Donates Amount: {user.donates.total_amount}")
print(f"Donates count: {user.donates.total_count}")
@client.on_donate
def donate(donate: Donate):
print(donate)
client.start()
Async
from donatello import AsyncDonatello
from donatello.models import Donate, User
client = AsyncDonatello("YOUR_API_KEY", "WIDGET_ID")
@client.on_donate
async def donate(donate):
print(f"Donator: {donate.nickname}")
print(f"Amount: {donate.amount} {donate.currency} / {donate.goal_amount} {donate.goal_currency}")
print(f"Message: {donate.message}")
@client.on_ready
async def ready(user):
print(user)
client.start()
Examples
You can find more examples here.
License
TODO
- Add more examples
- Add docs
- Add tests
- Goal, Top, interactive widgets?
Contributing
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
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
donatello-py-1.0.0.tar.gz
(8.6 kB
view details)
Built Distribution
File details
Details for the file donatello-py-1.0.0.tar.gz
.
File metadata
- Download URL: donatello-py-1.0.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8272d4d512059d07d7fc702c0b4441b40b198486ffd48f15cedf93fa2104237d |
|
MD5 | 4ec9c844e678460c1bc510430aacef6d |
|
BLAKE2b-256 | 5a0c29dc969640ee77afd1dcaebbda6e921be2535d2b7e68f454303c5304ee43 |
File details
Details for the file donatello_py-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: donatello_py-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9903acf34221364d89f15ca64ce57b5678f0538f7db592931979003bd226063e |
|
MD5 | f2b25cc462755a993cb7105c2dd10e05 |
|
BLAKE2b-256 | 13eae23464fd25b29e3696f7492fb2693c4ea8933a959f24b6bc7c56762391e2 |