Skip to main content

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 info
  • get_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

duckdice_api-1.1.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

duckdice_api-1.1.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file duckdice_api-1.1.0.tar.gz.

File metadata

  • Download URL: duckdice_api-1.1.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for duckdice_api-1.1.0.tar.gz
Algorithm Hash digest
SHA256 cf3812a5bf2bb9e937106a8ed339a5b60d64a40954e091a40e8db3197977f62f
MD5 bac133bc0877497b90d3970b28b33177
BLAKE2b-256 bd825bf65e157f71aef81241b162232533b7e89ff87e20b99b72c2a59e7e8217

See more details on using hashes here.

File details

Details for the file duckdice_api-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: duckdice_api-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for duckdice_api-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4b9913d90dc30442254fdc3da94f059948860e6b73dc414284ea84c2239cea6
MD5 73b57e75c82b46824b073464a00dfc0d
BLAKE2b-256 ab5c22c8458c9e7525b6aa5fea2f1e199bb67a5bbcd307fcef86c1bc843c91ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page