linkbreakers
Official Python SDK for the Linkbreakers API.
Installation
pip install linkbreakers
Usage
from linkbreakers import Configuration, ApiClient, LinksApi, CreateLinkRequest
# Configure API client with Bearer token authentication
configuration = Configuration(
access_token='your-api-token',
host='https://api.linkbreakers.com'
)
# Create API client
with ApiClient(configuration) as api_client:
links_api = LinksApi(api_client)
# Create a shortened link
response = links_api.links_service_create(
create_link_request=CreateLinkRequest(
destination='https://example.com',
name='My Link'
)
)
print(f'Short link: {response.link.shortlink}')
Authentication
Important: The Linkbreakers API uses Bearer token authentication. The SDK's Configuration class is designed to only accept the access_token parameter:
# ✅ CORRECT - Uses Bearer token authentication
configuration = Configuration(
access_token='your-workspace-token',
host='https://api.linkbreakers.com'
)
# ❌ ERROR - Will raise ValueError
configuration = Configuration(
api_key={'ApiKeyAuth': 'your-token'} # This will raise an error!
)
The SDK prevents you from accidentally using the wrong authentication method and will raise a clear error message with a link to the help documentation.
Get your workspace API token from the Linkbreakers dashboard.
For more information, see: https://linkbreakers.com/help/article/api-authentication-accesstoken-vs-apikey
Identifying Visitors
Use the VisitorsApi to identify and update visitor profiles. The identify method finds or creates a visitor using their LBID (from tracking) and merges attributes:
from linkbreakers import (
Configuration,
ApiClient,
VisitorsApi,
IdentifyRequest,
VisitorInput
)
configuration = Configuration(
access_token='your-api-token',
host='https://api.linkbreakers.com'
)
with ApiClient(configuration) as api_client:
visitors_api = VisitorsApi(api_client)
# Identify a visitor using their LBID (from tracking cookie/parameter)
response = visitors_api.visitors_service_identify(
identify_request=IdentifyRequest(
lbid='visitor-lbid-from-tracking', # Base64 encoded event ID from click/scan
visitor=VisitorInput(
data={
# System fields (prefixed with "$")
'$email': 'user@example.com',
'$phone': '+1234567890',
'$firstName': 'John',
'$lastName': 'Doe',
# Custom attributes (no "$" prefix)
'company': 'Acme Corp',
'plan': 'premium',
'signupDate': '2024-01-01'
}
),
set_once=False # If True, only sets empty fields (won't overwrite existing)
)
)
print(f'Created new profile: {response.created}')
print(f'Visitor: {response.visitor}')
Update an existing visitor by UUID:
from linkbreakers import VisitorsServiceUpdateBody, VisitorInput
with ApiClient(configuration) as api_client:
visitors_api = VisitorsApi(api_client)
# When you have the visitor's UUID (from your database)
visitor = visitors_api.visitors_service_update(
id='visitor-uuid',
visitors_service_update_body=VisitorsServiceUpdateBody(
visitor=VisitorInput(
data={
'$email': 'updated@example.com',
'plan': 'enterprise'
}
)
)
)
Get visitor details:
with ApiClient(configuration) as api_client:
visitors_api = VisitorsApi(api_client)
visitor = visitors_api.visitors_service_get(
id='visitor-uuid',
include=['devices', 'events', 'links'] # Optional: include related data
)
List visitors:
with ApiClient(configuration) as api_client:
visitors_api = VisitorsApi(api_client)
visitors = visitors_api.visitors_service_list(
page_size=50,
email='user@example.com', # Optional filters
link_id='link-uuid',
search='Acme Corp'
)
Full API Support
The SDK provides type-safe methods for all API operations. Method names follow the API's operation IDs (links_service_create, links_service_list, visitors_service_identify, ...), and request bodies are passed as the keyword named after their model (create_link_request, links_service_update_body, ...):
from linkbreakers import Configuration, ApiClient, LinksApi, LinksServiceUpdateBody
configuration = Configuration(
access_token='your-api-token',
host='https://api.linkbreakers.com'
)
with ApiClient(configuration) as api_client:
links_api = LinksApi(api_client)
# Get a link by ID
link = links_api.links_service_get(id='link-id').link
# Update a link
updated = links_api.links_service_update(
id='link-id',
links_service_update_body=LinksServiceUpdateBody(
name='Updated Name'
)
)
# Delete a link
links_api.links_service_delete(id='link-id')
# List links with filtering
links = links_api.links_service_list(
page_size=50,
search='my-search',
tags=['tag1', 'tag2']
)
Features
- ✅ Full type hints and autocompletion support
- ✅ Python 3.7+ support
- ✅ Auto-generated from OpenAPI specification
- ✅ Automatically updated when API changes
Examples
For complete, runnable code examples, see the examples/ directory:
- identify_visitor.py - Identify visitors using LBID (most important!)
- update_visitor.py - Update visitors by UUID
- create_link.py - Create shortened links with various options
- list_visitors.py - Query and filter visitors
Each example is complete, well-documented, and ready to run. See examples/README.md for details.
Documentation
For complete API documentation, visit https://docs.linkbreakers.com
Auto-Generated SDK
This SDK is automatically generated from the Linkbreakers OpenAPI specification. When the API is updated, this SDK is automatically regenerated and published.
Current API Version: See OPENAPI_VERSION
Support
- Issues: GitHub Issues
- Documentation: https://docs.linkbreakers.com
License
MIT License - see LICENSE for details.
Metadata
Release files for linkbreakers 1.177.2
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 | |
|---|---|---|---|---|
| linkbreakers-1.177.2.tar.gz | 334.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| linkbreakers-1.177.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.0 MB
Release files / linkbreakers-1.177.2.tar.gz
| Download URL | linkbreakers-1.177.2.tar.gz |
|---|---|
| Size | 334.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d6a428dd8f7395c408d9d87aa14a901b6c453c817ff98528b94d2e45dcd38f5
|
|
BLAKE2b-256 checksum How to use checksums |
3ff88967bf5afdf343b2ef938e8c63d4b740cbeca2d38d484ffad3f38469e13a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.17
|
Release files / linkbreakers-1.177.2-py3-none-any.whl
| Download URL | linkbreakers-1.177.2-py3-none-any.whl |
|---|---|
| Size | 1.6 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e1b29d5b0d6bfebf09acc938f2d1289905d7c9019e329ba3a98b289baadd0be6
|
|
BLAKE2b-256 checksum How to use checksums |
54792091ddf73a4304cdcd01ef02add5b2797a152990700937a2ab87a8bd54e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.17
|
Security for linkbreakers 1.177.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.