Examples

Choose the example that matches the application you want to build. Set your token as described in Installation before running any example.

Standalone applications

Discord bots

Configuration and delivery

Use several resources together

Save this as launcher.py and run python launcher.py:

launcher.py
import asyncio
import os

from dankmemer import DankMemer


async def main() -> None:
    async with DankMemer(os.environ["DANK_MEMER_API_TOKEN"]) as dank:
        item = await dank.items.get("Life Saver")
        if item is not None:
            print(f"{item.name}: market value {item.market_value:,}")
            for sale in await dank.store_sales.for_item(item):
                print(f"On sale for {sale.price:g}: {sale.url}")

        for gift in await dank.store_daily_gifts.today():
            print(f"{gift.category}: {gift.metadata.render}")
            reward_item = await dank.store_daily_gifts.reward_item(gift)
            if reward_item is not None:
                print(f"Item reward: {reward_item.name}")

        result = await dank.lottery.latest()
        if result is not None:
            print(f"Latest lottery: {result.drawn_at}, winnings {result.winnings:,}")

        print(f"Trending game: {await dank.stream.trending_game()}")


if __name__ == "__main__":
    asyncio.run(main())

The item lookup and gift reward helper share the item catalog cache. Live resources are requested when you call their methods. The client closes after the program finishes.

Watch drops without a Discord bot

The Events and polling guide includes a complete drop notifier, its polling schedule, and how to include drops already available at startup. Every callback is documented in Event reference.