No project description provided
Project description
Duckity Python SDK
Welcome to the Duckity Python SDK! This SDK handles fetching, solving, and validating Duckity challenges. The solving backend is built in Rust, so you can solve challenges from Python at native speed.
Installation
To install this SDK, run the following command in your terminal:
pip install duckity
Otherwise, if you're using another package manager, use that PM's command. For example, with uv,
run:
uv add duckity
Usage
There's a single interface through which you'll interact with the duckling API.
from duckity import DuckityClient
client = DuckityClient()
That will create a new DuckityClient instance pointing at quack.duckity.dev. If you self-host a
duckling, create a DuckityClient with a custom domain name instead:
from duckity import DuckityClient
client = DuckityClient("quack.example.com")
Every method of DuckityClient has an alternative asynchronous method prefixed with a. For
example, fetch() and afetch(), or solve() and asolve().
Solving Challenges
To solve a challenge, you need to fetch it first.
from duckity import Challenge
challenge: Challenge = client.fetch("app-id", "profile-code")
Once you have a challenge, solve it by calling solve() on it.
solution: str = challenge.solve()
The solution will be an already-encoded token ready to send to the server.
As stated before, every method has an asynchronous alternative. In asynchronous environments, do
not use the synchronous methods as they will block your async runtime. Challenge.solve() is
notable here, since it is CPU-intensive. Challenge.asolve() wraps Challenge.solve() in
asyncio.to_thread() to prevent it from blocking the event loop.
Validating Challenges
To validate challenges, use DuckityClient.validate() (or its asynchronous alternative
DuckityClient.avalidate()).
is_valid: bool = client.validate(
"app-id",
"app-secret",
"profile-code",
"client-ip",
"solution-token"
)
if not is_valid:
print("The challenge was not valid!")
return
# Do your stuff here
Examples
There's an example of solving a challenge implemented at python/examples/challenge.py in the SDKs
repository. To run it, clone the repository with git clone https://github.com/duckity-dev/sdks
and CD into the python/ directory. You can run it with the following command:
# The example works as a singletone file if you install the dependencies in pyproject.toml
# manually.
uv sync
uv run examples/challenge.py
You'll be guided on how to set it up. It's easy, so good luck!
Contributing
Contributions of any kind are welcome! Suggestions, issues, PRs, and everything else goes into our SDKs repository in GitHub. We reward good contributions with Duckity credits 😉
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 duckity-0.1.3.tar.gz.
File metadata
- Download URL: duckity-0.1.3.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adfdb30d8bca780ff34f7542359aedb1623d865e5a0960bf9992813d8f41ec15
|
|
| MD5 |
9f1505146cb5480a6301b6851e4f9507
|
|
| BLAKE2b-256 |
072553a62352cc577957991f0a8261574ac40a8149b343b15c25f3aa970043ca
|
File details
Details for the file duckity-0.1.3-cp313-cp313-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: duckity-0.1.3-cp313-cp313-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 310.9 kB
- Tags: CPython 3.13, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92f3c5c60d02c1075d1a1c53ba073ad170537d3ac9122c7bac33cc74590b34b0
|
|
| MD5 |
629018871ab6423f34cf80b2758514f1
|
|
| BLAKE2b-256 |
6f11c95906b4ea1e5eba9439a8e63d1eca7f65b64a0fab06708bce787877158c
|