Discord Labs Python SDK
A user-friendly Python client for the Discord Labs API. This package makes it simple to fetch public data (bots, users, website stats) and post authenticated bot statistics.
Links
- Conscherry
- Discord Labs
- Labs API Documentation
- Labs API Source
- JavaScript SDK on npm
- Python SDK on PyPI
Installation
python -m pip install labs-api-python
Quick start
Synchronous Client
from labs import LabsApiClient
with LabsApiClient() as client:
bots = client.list_bots(limit=5)
print(bots)
Asynchronous Client
import asyncio
from labs import AsyncLabsApiClient
async def main():
async with AsyncLabsApiClient() as client:
bots = await client.list_bots(limit=5)
print(bots)
asyncio.run(main())
Client options
| Option | Type | Default |
|---|---|---|
api_key |
str |
LABS_API_KEY environment variable |
base_url |
str (HTTPS only) |
https://labs.conscherry.com/api/v1 |
timeout |
float (seconds) |
15.0 |
telemetry |
bool |
True |
Both LabsApiClient and AsyncLabsApiClient accept the same options and expose the same methods. Close clients with a with / async with block or call close().
Authentication
Public endpoints do not require an API key.
For authenticated requests, configure LABS_API_KEY in your environment:
PowerShell
$env:LABS_API_KEY = "YOUR_API_KEY"
Linux/macOS
export LABS_API_KEY="YOUR_API_KEY"
Or provide the key directly:
from labs import LabsApiClient
client = LabsApiClient(api_key="YOUR_API_KEY")
Never expose your API key in client-side applications or public repositories.
API examples
List bots
with LabsApiClient() as client:
result = client.list_bots(limit=10)
print(result)
Get a bot
with LabsApiClient() as client:
result = client.get_bot_by_id("YOUR_BOT_ID")
print(result)
List users
with LabsApiClient() as client:
result = client.list_users(limit=10)
print(result)
Website statistics
with LabsApiClient() as client:
result = client.get_website_stats()
print(result)
Post bot stats
with LabsApiClient() as client:
# Supports guild_count, server_count, and serverCount aliases
result = client.post_stats(
bot_id="YOUR_BOT_ID",
server_count=100,
user_count=5000,
)
print(result)
Stats submission requires appropriate API permissions.
Generic requests
with LabsApiClient() as client:
result = client.get("/custom", params={"q": "search"})
print(result)
Authenticated request:
with LabsApiClient() as client:
result = client.post(
"/admin",
body={"action": "rebuild"},
authenticated=True,
)
Paths must start with a single / and must not contain a query string; pass query values through params. The async client exposes the same helpers as coroutines. Only use endpoints and request bodies supported by your API credentials and documentation.
Error handling
LabsAPIError is the base class. LabsAPIAuthError covers 401 or a missing key, LabsAPIPermissionError covers 403, LabsAPIRateLimitError covers 429, LabsAPIRequestError covers other HTTP errors and LabsAPIConnectionError covers timeouts and network failures. Every error exposes status_code, code, retry_after and response.
from labs import (
LabsApiClient,
LabsAPIError,
LabsAPIRateLimitError,
)
try:
with LabsApiClient() as client:
result = client.list_bots()
print(result)
except LabsAPIRateLimitError as exc:
print("Rate limited:", exc.retry_after)
except LabsAPIError as exc:
print("Labs API error:", exc)
Telemetry
This client sends a small set of telemetry headers by default to identify the SDK and runtime to your API: X-SDK-Name, X-SDK-Version, X-SDK-Lang and X-SDK-Instance-Id (a random UUID generated once per client).
To disable telemetry, pass telemetry=False when creating the client:
client = LabsApiClient(telemetry=False)
Development
python -m pip install -e .
python -m pip install pytest
python -m pytest -q
License
MIT
Metadata
Release files for labs-api-python 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| labs_api_python-1.0.0.tar.gz | 10.1 kB | With provenance | Details for labs_api_python-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| labs_api_python-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for labs_api_python-1.0.0-py3-none-any.whl |
Total release size: 18.2 kB
Release files / labs_api_python-1.0.0.tar.gz
| Download URL | labs_api_python-1.0.0.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
70db2be978ee759358a99e3276b8e371e20dab70f71ec31c833572169eefc22a
|
|
BLAKE2b-256 checksum How to use checksums |
e733bd7092e509962b4eb20a86aaa8edb135b7ecb439fb04155697170ee54418
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.
Transparency logRelease files / labs_api_python-1.0.0-py3-none-any.whl
| Download URL | labs_api_python-1.0.0-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
669df8b7bf4fee15cacc56431e26d26347190529059eba211baccc0cdc531a99
|
|
BLAKE2b-256 checksum How to use checksums |
def7d433007891dd8a3d6b96f7367f6ed1daee8bcd25f55185d3d614611bb4cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.
Transparency logSecurity for labs-api-python 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for labs_api_python-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.