Skip to main content

Python SDK for the LaserSell API

Project description

lasersell-sdk (Python)

Python SDK for the LaserSell API.

Modules:

  • exit_api: build unsigned buy/sell transactions.
  • stream: websocket client, protocol types, and session helpers.
  • tx: sign/encode/send Solana transactions.
  • retry: shared retry helpers.

Install

pip install lasersell-sdk

From this repository:

cd lasersell-sdk/python
python -m pip install -e .

Package layout

  • lasersell_sdk.exit_api: build unsigned buy/sell transactions.
  • lasersell_sdk.stream.client: websocket transport and command sender.
  • lasersell_sdk.stream.session: higher-level stream session with position tracking.
  • lasersell_sdk.stream.proto: protocol types and JSON encode/decode helpers.
  • lasersell_sdk.tx: sign/encode/send Solana transactions.
  • lasersell_sdk.retry: retry/backoff and timeout helpers.

Build a sell transaction

import asyncio

from lasersell_sdk.exit_api import BuildSellTxRequest, ExitApiClient, SellOutput


async def main() -> None:
    client = ExitApiClient.with_api_key("REPLACE_WITH_API_KEY")

    request = BuildSellTxRequest(
        mint="REPLACE_WITH_MINT",
        user_pubkey="REPLACE_WITH_WALLET_PUBKEY",
        amount_tokens=1_000_000,
        slippage_bps=2_000,
        output=SellOutput.SOL,
    )

    response = await client.build_sell_tx(request)
    print(response.tx)


asyncio.run(main())

Notes:

  • amount_tokens is in token atomic units (smallest unit for the mint).
  • slippage_bps is basis points (100 = 1%, 2000 = 20%).
  • Use client.with_base_url("https://api-dev.example") to target a custom base URL.

Stream + auto-sell flow

import asyncio

from solders.keypair import Keypair

from lasersell_sdk.stream.client import (
    StreamClient,
    single_wallet_stream_configure_optional,
)
from lasersell_sdk.stream.session import StreamSession
from lasersell_sdk.tx import SendTargetHeliusSender, send_transaction, sign_unsigned_tx


async def main() -> None:
    signer = Keypair()
    client = StreamClient("REPLACE_WITH_API_KEY")
    session = await StreamSession.connect(
        client,
        single_wallet_stream_configure_optional(
            "REPLACE_WITH_WALLET_PUBKEY",
            deadline_timeout_sec=45,  # timeout-only strategy is valid
        ),
    )

    while True:
        event = await session.recv()
        if event is None:
            break

        if event.type == "exit_signal_with_tx" and event.message.get("type") == "exit_signal_with_tx":
            signed_tx = sign_unsigned_tx(event.message["unsigned_tx_b64"], signer)
            signature = await send_transaction(SendTargetHeliusSender(), signed_tx)
            print(signature)


asyncio.run(main())

deadline_timeout_sec is enforced client-side by StreamSession timers and is not sent as part of wire strategy. Use session.update_strategy(...) when changing strategy so local deadline timers stay in sync (pass deadline_timeout_sec= to change local deadline timing). Use single_wallet_stream_configure_optional(...) / strategy_config_from_optional(...) to omit TP/SL fields; at least one of take profit, stop loss, or timeout must be enabled.

Notes:

  • Use client.with_endpoint("wss://stream-dev.example/v1/ws") to target a custom stream endpoint.
  • unsigned_tx_b64 from stream events can be signed with lasersell_sdk.tx.sign_unsigned_tx.

RPC endpoint

The SDK ships with the Solana public mainnet-beta RPC as a default so you can get started immediately:

from lasersell_sdk.tx import SendTargetRpc

target = SendTargetRpc()  # uses mainnet-beta public RPC

A private RPC is highly recommended for production — the public endpoint is rate-limited and unreliable under load. Free private RPC tiers are available from Helius and Chainstack, among others:

target = SendTargetRpc(url="https://your-private-rpc.example.com")

Examples

See examples/README.md for setup and script-by-script instructions.

Quick run commands (from lasersell-sdk/python):

python examples/build_buy.py
python examples/build_sell.py
python examples/build_and_send_sell.py
python examples/auto_sell.py

Scripts:

  • build_buy.py
  • build_sell.py
  • build_and_send_sell.py
  • auto_sell.py

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

lasersell_sdk-0.1.3.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

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

lasersell_sdk-0.1.3-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file lasersell_sdk-0.1.3.tar.gz.

File metadata

  • Download URL: lasersell_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lasersell_sdk-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f6ac1b6c8c3b51627de0daddd8a2626def703f8b34606679d1ac001d6e61ceed
MD5 a11443f3c745a41f95f79bf14a66551b
BLAKE2b-256 9e0fa326a44737a676745aff47a71a6b1d0f45cf4293ce1cded8d661c0799f7e

See more details on using hashes here.

Provenance

The following attestation bundles were made for lasersell_sdk-0.1.3.tar.gz:

Publisher: publish.yml on lasersell/lasersell-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lasersell_sdk-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: lasersell_sdk-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lasersell_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 635ee390aaab886b0953a51c9af9bf8c77191ea8559f1be794bf0c12d4e4230a
MD5 ba09d62e6dae871728f0757ad656e39c
BLAKE2b-256 6698d385e683de9601131ee28631ed623ccaff83a4b831f8892075bef54fd6eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for lasersell_sdk-0.1.3-py3-none-any.whl:

Publisher: publish.yml on lasersell/lasersell-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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