Registry / http-networking / dub
library0.35.7pypypi✓ verified 86d ago

Python client SDK for the Dub API (link management, analytics, etc.), generated by Speakeasy. Current version 0.35.7, requires Python >=3.10. Released frequently.

pip install dub
INSTALL
IMPORT
SIG · DUB
D
dub
http-networkingpythonv0.35.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Dub
from dub import Dub
from dub.client import Dub
Old import path was dub.client; current SDK exposes client at top level.

Initialize with an API token and create a short link.

from dub import Dub client = Dub( token=os.environ.get('DUB_API_KEY', ''), ) # Create a short link link = client.links.create( url='https://example.com', external_id='my-link', tag_ids=[], ) print(link.id)
Debug
Known issues
breakingImport path changed from 'from dub.client import Dub' to 'from dub import Dub' in v0.30+.
fix
Use the top-level import: from dub import Dub
affects: >=0.30.0
deprecatedThe 'workspace_id' parameter is deprecated; use 'project_slug' instead.
fix
Replace 'workspace_id' with 'project_slug' in SDK initialization.
affects: <0.36.0 (likely deprecated in 0.35.x)
gotchaAll SDK methods are async; run in async context or use asyncio.run().
fix
Wrap synchronous calls in asyncio.run(): asyncio.run(client.links.create(...))
affects: All versions
Errors
Common errors & fixes
AttributeError: module 'dub' has no attribute 'Dub'
Outdated SDK version (<0.30.0) missing the top-level Dub class, or incorrect import.
fix
Upgrade to the latest version: pip install --upgrade dub
dub.core.ApiError: 401 Unauthorized
Invalid or missing API key (DUB_API_KEY environment variable not set or incorrect).
fix
Set DUB_API_KEY with a valid API token from the Dub dashboard.
Upgrade
Version history
0.35.7latest on PyPI · released Apr 24, 2026
Audit
Dependencies
httpxrequiredHTTP client used internally
pydanticrequiredData validation and serialization
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
dub — pip install dub · libregistry