Skip to main content

linkbreakers

Official Python SDK for the Linkbreakers API.

PyPI version License: MIT

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:

Each example is complete, well-documented, and ready to run. See examples/README.md for details.

Whole projects live in linkbreakers-com/examples, each a small repo you can run as is. Start with bulk dynamic QR codes from a CSV: a CSV of destinations in, one dynamic QR code (SVG) and short link per row out, then the scan counts written back to the CSV.

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

License

MIT License - see LICENSE for details.

Metadata

Release files for linkbreakers 1.184.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for linkbreakers 1.184.0
File Size Uploaded Provenance Actions
linkbreakers-1.184.0.tar.gz 348.7 kB Without provenance Details for linkbreakers-1.184.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for linkbreakers 1.184.0
File Interpreter ABI Platform Actions
linkbreakers-1.184.0-py3-none-any.whl Python 3 none any Details for linkbreakers-1.184.0-py3-none-any.whl

Total release size: 2.0 MB

Release files / linkbreakers-1.184.0.tar.gz

Download URL linkbreakers-1.184.0.tar.gz
Size 348.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5dc89fd70fbc02457d28dfe6ec3cb54b0e1f20261e7ce59ebac9eddddca4aaa3
BLAKE2b-256 checksum
How to use checksums
e1b8fc598f888bc06769cf2b1e29dec817b7d278b03a6bc2cc05096d49faf544
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.184.0-py3-none-any.whl

Download URL linkbreakers-1.184.0-py3-none-any.whl
Size 1.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
938ed47cf1765627b5ed70799cdc1ff83c67b46c7cca0edbde634a1ed802e2bd
BLAKE2b-256 checksum
How to use checksums
ad6fdffdc11ad308d40c849b0fb833293ff1ba5cacbe6c8763437d5accbae3e2
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.184.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.

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.

Release history Release notifications | RSS feed

This release

1.184.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page