Skip to main content

CLASP client for Python - Creative Low-Latency Application Streaming Protocol

Project description

CLASP Python Client

A Python client for the CLASP protocol - Creative Low-Latency Application Streaming Protocol for creative tools communication.

Installation

pip install clasp-to

Quick Start

import asyncio
from clasp import Clasp

async def main():
    # Connect to a CLASP server
    sf = Clasp('ws://localhost:7330')
    await sf.connect()

    # Subscribe to parameter changes
    @sf.on('/lumen/layer/*/opacity')
    def on_opacity(value, address):
        print(f'{address} = {value}')

    # Set a parameter
    await sf.set('/lumen/layer/0/opacity', 0.75)

    # Get a parameter
    opacity = await sf.get('/lumen/layer/0/opacity')
    print(f'Current opacity: {opacity}')

    # Emit an event
    await sf.emit('/lumen/cue/fire', {'cue': 1})

    # Keep running
    sf.run()

asyncio.run(main())

Builder Pattern

from clasp import ClaspBuilder

async def main():
    client = await (
        ClaspBuilder('ws://localhost:7330')
        .with_name('My Python App')
        .with_features(['param', 'event'])
        .with_reconnect(True, interval=5.0)
        .connect()
    )

    # Use client...
    await client.close()

API Reference

Clasp

  • connect() - Connect to server
  • close() - Close connection
  • subscribe(pattern, callback) - Subscribe to address pattern
  • on(pattern) - Decorator for subscriptions
  • set(address, value, ttl=None) - Set parameter value (optional TTL in microseconds)
  • get(address) - Get parameter value
  • emit(address, payload) - Emit event
  • stream(address, value) - Send stream sample
  • bundle(messages, at) - Send atomic bundle
  • cached(address) - Get cached value
  • time() - Get server time (microseconds)

Properties

  • connected - Check if connected
  • session_id - Get session ID

Callbacks

  • on_connect(callback) - Register connect callback
  • on_disconnect(callback) - Register disconnect callback
  • on_error(callback) - Register error callback

Address Patterns

CLASP supports wildcard patterns:

  • * - Match single path segment
  • ** - Match multiple path segments

Examples:

  • /lumen/layer/*/opacity - All layer opacities
  • /lumen/**/enabled - All enabled properties

Documentation

Visit clasp.to for full documentation.

License

MIT


Maintained by LumenCanvas | 2026

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

clasp_to-4.2.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

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

clasp_to-4.2.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file clasp_to-4.2.0.tar.gz.

File metadata

  • Download URL: clasp_to-4.2.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for clasp_to-4.2.0.tar.gz
Algorithm Hash digest
SHA256 3c121f6d510014e9715dee0dc441e5e54ee5e371ac70cb8907dfa39b846cacbf
MD5 c1b0845d6fe7f0a13e484505cc335ce6
BLAKE2b-256 6e0d45691b61256a8284d9755fb4b06410007979b91656c10625b025db52f1fc

See more details on using hashes here.

File details

Details for the file clasp_to-4.2.0-py3-none-any.whl.

File metadata

  • Download URL: clasp_to-4.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for clasp_to-4.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02c9c7d7cb0f3d678c13b2e330fe94f2f173bb3a4b71949bd71613e245d0514d
MD5 704740fb113c4ededfd40799034da4e7
BLAKE2b-256 7fe89528db36b62de6e7a1dc3b2639328a3459a0c1a13d95ecde30144533cb57

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