A lightweight async wrapper for the DankAlert API.
Project description
dankmemer.py is a lightweight asynchronous Python wrapper for the DankAlert API. It provides typed response objects, built-in caching, route-level filtering, and optional client-side rate-limit protection.
Release Status
This package is currently prepared as 1.0.0rc2. The public API is usable across the supported DankAlert route groups, but small fixes may still land before a stable 1.0.0 release.
Installation
Python 3.11 or newer is required.
Both package aliases are available:
pip install dankmemer
pip install dankmemer.py
Supported Routes
The client currently exposes these route groups:
client.all
client.baits
client.buckets
client.creatures
client.decorations
client.events
client.items
client.locations
client.npcs
client.seasons
client.skills
client.skillsdata
client.stream
client.tanks
client.tools
Features
Async aiohttp client with context-manager and manual-close usage
Built-in caching with configurable TTL
Cache clearing and cache state introspection
Configurable retry handling for rate limits, temporary server errors, timeouts, and connection errors
Configurable logging modes with default coloured console logs, silent logging, inherited application logging, or a custom logger
Exact, fuzzy, membership, numeric range, above, and below filters
Immutable dataclass response objects for route data
Optional anti-rate-limit handling
Quick Start
import asyncio
from dankmemer import DankMemerClient, Fuzzy, IN, ItemsFilter, NPCsFilter
async def main():
async with DankMemerClient() as client:
items = await client.items.query()
print(items[0].name)
filtered_items = await client.items.query(
ItemsFilter(name=Fuzzy("trash", cutoff=80))
)
print([item.name for item in filtered_items])
npcs = await client.npcs.query(NPCsFilter(name=IN("chad")))
print([npc.name for npc in npcs])
asyncio.run(main())
Stream Example
import asyncio
from dankmemer import DankMemerClient
async def main():
async with DankMemerClient() as client:
stream = await client.stream.query()
print(stream.trending_game.name)
asyncio.run(main())
Manual Client Close
import asyncio
from dankmemer import DankMemerClient
async def main():
client = DankMemerClient()
try:
items = await client.items.query()
print(len(items))
finally:
await client.close()
asyncio.run(main())
Cache Control
Responses are cached by route for 24 hours by default. Set cache_ttl_hours=0 or cache_ttl_hours=None to disable caching.
async with DankMemerClient(cache_ttl_hours=0) as client:
first = await client.items.query()
second = await client.items.query()
async with DankMemerClient() as client:
await client.items.query()
client.items.clear_cache()
client.clear_route_cache("items")
client.clear_cache()
print(client.items.cache_info())
Retries, Logging, and Sessions
The client retries HTTP 429 responses and selected temporary server errors by default. Retry-After headers are respected when present.
client = DankMemerClient(
retry_attempts=2,
retry_backoff=0.5,
retry_on_rate_limit=True,
)
DankMemerClient configures logging when a client is created. The default is logging_mode="default", which installs the package’s coloured console handler on the dankmemer logger. The package does not attach this handler at import time and it is not duplicated when multiple clients are created.
Use logging_mode="null" for silent logging, or logging_mode="inherit" to leave output handling to your application or root logging configuration. Pass logger=... when your application wants direct control over client logs; a custom logger is used as-is.
import logging
default_client = DankMemerClient()
explicit_default = DankMemerClient(logging_mode="default")
silent_client = DankMemerClient(logging_mode="null")
inherited_client = DankMemerClient(logging_mode="inherit")
api_logger = logging.getLogger("myapp.dankmemer")
custom_client = DankMemerClient(logger=api_logger)
If you pass an existing aiohttp.ClientSession, the client will not close it. Sessions created by DankMemerClient are closed by close() and by the async context manager.
Documentation
Full documentation is under development and will be published at:
https://dankmemerpy.readthedocs.io
Issues and contributions are welcome on GitHub.
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 dankmemer-1.0.0rc2.tar.gz.
File metadata
- Download URL: dankmemer-1.0.0rc2.tar.gz
- Upload date:
- Size: 28.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bc9e40c220d263a5206408342ea6800aedcd595f8002a92114cbfb6b358c0e3
|
|
| MD5 |
6d0852b7ff2c5458f2dc63903372f040
|
|
| BLAKE2b-256 |
1b96921a6fc6007c45b1f2a07b479049d3f888ef08b75bdc2c016c517c022968
|
File details
Details for the file dankmemer-1.0.0rc2-py3-none-any.whl.
File metadata
- Download URL: dankmemer-1.0.0rc2-py3-none-any.whl
- Upload date:
- Size: 46.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27c8abf045abea602de01ca5da23a54a22d5736415531ee11f296de1999db352
|
|
| MD5 |
364976f6e53a3c298f37e43e4ef164d0
|
|
| BLAKE2b-256 |
77e93e113d989a669d0573679006fcd95ffaeaf43cbe00ebea89b3020d4d803b
|