Skip to main content

Linkbreakers API

Project description

linkbreakers

Official Python SDK for the Linkbreakers API.

PyPI version License: MIT

Installation

pip install linkbreakers

Usage

from linkbreakers import Configuration, ApiClient, LinksApi

# Configure API client
configuration = Configuration(
    api_key={'ApiKeyAuth': 'your_api_key_here'},
    host='https://api.linkbreakers.com'
)

# Create API client
with ApiClient(configuration) as api_client:
    links_api = LinksApi(api_client)

    # Create a shortened link
    link = links_api.create_link({
        'destination': 'https://example.com',
        'name': 'My Link'
    })

    print(f'Short link: {link.shortlink}')

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_key_here',
    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:

from linkbreakers import Configuration, ApiClient, LinksApi

configuration = Configuration(
    api_key={'ApiKeyAuth': 'your_api_key_here'},
    host='https://api.linkbreakers.com'
)

with ApiClient(configuration) as api_client:
    links_api = LinksApi(api_client)

    # Get a link by ID
    link = links_api.get_link(id='link-id')

    # Update a link
    updated = links_api.update_link(
        id='link-id',
        update_link_request={
            'name': 'Updated Name'
        }
    )

    # Delete a link
    links_api.delete_link(id='link-id')

    # List links with filtering
    links = links_api.list_links(
        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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

linkbreakers-1.35.1.tar.gz (130.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

linkbreakers-1.35.1-py3-none-any.whl (435.3 kB view details)

Uploaded Python 3

File details

Details for the file linkbreakers-1.35.1.tar.gz.

File metadata

  • Download URL: linkbreakers-1.35.1.tar.gz
  • Upload date:
  • Size: 130.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for linkbreakers-1.35.1.tar.gz
Algorithm Hash digest
SHA256 b1c348bc261356cb1fb9153d76350f163a22ab739f4fd4aa2baf9423b5621ce7
MD5 c5df8b7811ed3670ba3ab19af599286e
BLAKE2b-256 2e82e133280f46184ce6e8745602dd344bc648f050525b699492831b07e56e11

See more details on using hashes here.

File details

Details for the file linkbreakers-1.35.1-py3-none-any.whl.

File metadata

  • Download URL: linkbreakers-1.35.1-py3-none-any.whl
  • Upload date:
  • Size: 435.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for linkbreakers-1.35.1-py3-none-any.whl
Algorithm Hash digest
SHA256 635c51ae8d3d79029350cd5e4e85a5c2347bde2564b8bb7d0bbaeede5e9895fe
MD5 c915ed8ce186d5e10665ee235fa059f2
BLAKE2b-256 602aca37f8a31ae4fb1060d5cd12945767e6104ecc6fe97ae186e6a736536053

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page