Python client for DuckDice Bot API - Place bets and retrieve statistics
Project description
DuckDice API Python Wrapper
A modern, type-safe Python client for the DuckDice Bot API. Place bets, manage balances, and retrieve user statistics programmatically.
Features
- Simple & Intuitive: Easy-to-use API client with clear method signatures
- Type Hints: Full type annotations for IDE support and better code safety
- Error Handling: Comprehensive exception handling with
DuckDiceAPIException - Well Tested: 13 unit tests covering all methods and edge cases
- Production Ready: Used by DuckDice bot operators worldwide
Installation
pip install duckdice-api
Quick Start
from duckdice_api import DuckDiceAPI, DuckDiceConfig
# Initialize client
cfg = DuckDiceConfig(api_key="YOUR_BOT_API_KEY")
client = DuckDiceAPI(cfg)
# Get user info
user = client.get_user_info()
print(f"Username: {user['username']}, Level: {user['level']}")
# Get currency stats
stats = client.get_currency_stats("XLM")
print(f"Bets: {stats['bets']}, Wins: {stats['wins']}")
# Place Original Dice bet
result = client.play_dice(
symbol="XLM",
amount="0.1",
chance="77.77",
is_high=True
)
print(f"Bet result: {result['bet']['result']}")
# Place Range Dice bet
result = client.play_range_dice(
symbol="XLM",
amount="0.1",
range_vals=[0, 5000],
is_in=True
)
API Methods
Read Methods
get_user_info()— Retrieve bot user profile, balances, wagering bonuses, and TLE infoget_currency_stats(symbol)— Get statistics for a specific currency (bets, wins, profit, volume)
Betting Methods
play_dice(symbol, amount, chance, is_high, ...)— Place Original Dice bet (high/low prediction)play_range_dice(symbol, amount, range_vals, is_in, ...)— Place Range Dice bet (range prediction)
All methods return parsed JSON responses from the DuckDice API.
Configuration
from duckdice_api import DuckDiceConfig
cfg = DuckDiceConfig(
api_key="your_api_key", # Required
base_url="https://duckdice.io/api", # Default
timeout=30 # Seconds
)
Error Handling
from duckdice_api import DuckDiceAPIException
try:
user = client.get_user_info()
except DuckDiceAPIException as e:
print(f"API Error: {e}")
Full Documentation
See docs/USAGE.md for more examples and https://duckdice.io/bot-api for official API documentation.
Requirements
- Python 3.8+
requests>=2.25.0
Testing
Run the test suite:
pytest tests/
License
MIT License — Copyright (c) 2025 duckdice.casino
Project details
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 duckdice_api-1.0.3.tar.gz.
File metadata
- Download URL: duckdice_api-1.0.3.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d3a374d8a90e1004b5433ad2908a9027fe7abb4b5558bb35c72c11c0ca6504b
|
|
| MD5 |
f36b7f2a55677a3287db8fbd11d6dd53
|
|
| BLAKE2b-256 |
e3931c9ee3a862908c45742f944a12ca5de2a9fc8d560969e84276fa9c5a79d5
|
File details
Details for the file duckdice_api-1.0.3-py3-none-any.whl.
File metadata
- Download URL: duckdice_api-1.0.3-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9f9a095eb27d14fc80e4a16bcccdb1b019628b42c30777d50a997c5ad717df2
|
|
| MD5 |
7acd7fe15e8fe97ffc6a4775f25f5cc3
|
|
| BLAKE2b-256 |
b7b67a7e584e1d06dfa826c8806cfe6a056c9b30025a60c590b43b252e7e3c29
|