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.0.4.tar.gz (7.6 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.0.4-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: duckdice_api-1.0.4.tar.gz
  • Upload date:
  • Size: 7.6 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.0.4.tar.gz
Algorithm Hash digest
SHA256 88d058ace370d19eaff727561efb0e2b03780b2639af91f2252a99abe93d617d
MD5 8f6a9c3ef8781294c4c5912a65f0cd7b
BLAKE2b-256 ec221b148dba5a9c1535b3eaa66b9e518038e498406d5610295619641f2d8a24

See more details on using hashes here.

File details

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

File metadata

  • Download URL: duckdice_api-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.8 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.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 83d8c7230ab1096c4f7f72b72e0fa593183de2d67d1de57d0a62e6c12bba5c77
MD5 6eb4bd393277fd93b3f9c163e362e26a
BLAKE2b-256 3f410bf8eff92101db0bf24517541106f563f0a1a0804a273a434b71d4b0d0e0

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