Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hampta/donatello-py
Simple python wrapper for the Donatello API.
https://github.com/hampta/donatello-py
api asynchronous asyncio asyncio-api-wrapper donatello python python3 ukraine wrapper-api
Last synced: about 1 month ago
JSON representation
Simple python wrapper for the Donatello API.
- Host: GitHub
- URL: https://github.com/hampta/donatello-py
- Owner: hampta
- License: mit
- Created: 2023-10-05T18:30:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-11T02:50:06.000Z (over 1 year ago)
- Last Synced: 2024-10-18T13:16:35.075Z (3 months ago)
- Topics: api, asynchronous, asyncio, asyncio-api-wrapper, donatello, python, python3, ukraine, wrapper-api
- Language: Python
- Homepage: https://donatello-py.hampta.pp.ua
- Size: 813 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## ✨ Features
- Full type hints
- Client info
- Get donates
- Get clients
- Long polling
- Async support## 🔗 Installation
```bash
pip install donatello-py
```For speedup:
```bash
pip install donatello-py[speed]
```## 🧑🏭 Basic Usage
Get and activate your API key [here](https://donatello.to/panel/doc-api).
#### ⛓️ Sync
```python
from donatello import Donatelloclient = Donatello("YOUR_API_KEY")
# Get client info
print(client.get_me())# Get donates
print(client.get_donates(page=0, per_page=00))# Get clients
print(client.get_clients())
```#### ⛓️ Async
```python
from donatello import AsyncDonatelloclient = AsyncDonatello("YOUR_API_KEY")
async def main():
print(await client.get_me())
print(await client.get_donates(page=0, per_page=00))
print(await client.get_clients())asyncio.run(main())
```## 🥏 Long polling
For use long polling you need to create widget [here](https://donatello.to/panel/alert-widget) and get widget id from url.
### Example url:
```
https://donatello.to/widget//token/
```### Code example
#### ⛓️ Sync
```python
from donatello import Donatello
from donatello.models import Donate, Userclient = 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
```python
from donatello import AsyncDonatello
from donatello.models import Donate, Userclient = 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()
```
## 📚 DocsYou can find docs [here](https://donatello-py.readthedocs.io/en/latest/).
## 📝 Examples
You can find more examples [here](https://github.com/hampta/donatello-py/tree/main/examples).
## 📄 License
[MIT](https://choosealicense.com/licenses/mit/)## 📋 TODO
- [x] Add more examples
- [x] Add docs
- [ ] Add tests
- [ ] Websocket based long polling- [ ] ~~Goal, Top, interactive widgets?~~ Never
## 🤝 Contributing
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.