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.

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.177.1

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.177.1
File Size Uploaded Provenance
linkbreakers-1.177.1.tar.gz 333.1 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 2.0 MB

Release files / linkbreakers-1.177.1.tar.gz

Download URL linkbreakers-1.177.1.tar.gz
Size 333.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b5e5174f0b384b8f2e966788faaed0c5343a05de85d65d66c165c234da832035
BLAKE2b-256 checksum
How to use checksums
61f20e0ad16184c85c97e2333ff4bb7a98a81d876609dbea50d9e116f07363f4
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.1-py3-none-any.whl

Download URL linkbreakers-1.177.1-py3-none-any.whl
Size 1.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
a9d231bec56b87b05edb4ef78a967f67d93529bc7f355660ddfc84b965f369f4
BLAKE2b-256 checksum
How to use checksums
faba0bb77b7ae42157256c597f4ac636c94e11fc9645a3b153f016f109f1e0ed
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.1

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.177.1 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