Skip to main content

Typed Lighter

A fully typed, validated async client for the Lighter API.

PyPI version Python versions Docs License



from typed_lighter import Lighter

async with Lighter.new(public=True) as client:
  books = await client.api.markets.order_books(filter='perp')
  for book in books['order_books'][:5]:
    print(book['market_id'], book['symbol'], book['supported_price_decimals'])

Lighter is a perpetuals and spot order book running on its own ZK rollup. Every state change (orders, transfers, leverage, API keys) is a signed L2 transaction; everything else is a REST read, a WebSocket stream, or an auth-token-gated account write. The client mirrors that split:

Surface What it covers Credentials
client.api REST: markets, candles, accounts, orders and trades, transfers, blocks, pools, referrals, RFQ public, or an auth token for private reads
client.tx Signed transactions: orders, cancels, leverage, margin, transfers, sub-accounts, API keys, pools, staking API key
client.streams WebSocket channels: order books, trades, candles, market stats, account orders, positions, notifications public, or an auth token for private channels
client.signer Local signing with no network: every transaction type, auth tokens, key generation API key
client.explorer The public block explorer (mainnet and testnet): blocks, batches, logs, account history none
client.deposit_bridge Universal deposit addresses from other chains bridge API key

Signing happens in pure Python, inside the package: no compiled library, no external process. Transactions go over HTTP or over the shared WebSocket connection, chosen per call.

Authenticated Quick Start

from typed_lighter import Lighter

async with Lighter.new() as client:  # reads LIGHTER_ACCOUNT_INDEX, LIGHTER_API_KEY_INDEX, LIGHTER_API_PRIVATE_KEY
  account = client.signer.account_index
  orders = await client.api.account.orders.active(account_index=account)
  for order in orders['orders']:
    print(order['market_index'], order['order_index'], order['price'], order['status'])

Create the API key on Lighter's API keys page: connect your wallet, click Generate API Key, pick an index from 4 to 254, and copy the private key (it is shown once). The same page shows your account index. See Authenticated Setup for the full walkthrough, read-only tokens and registering keys from code.

Why Typed Lighter?

  • 🎯 Precise Types: Typed requests and responses on every surface, down to order-type unions and Literal statuses, not dict/Any.
  • ✅ Runtime Validation: REST replies, WebSocket frames and transaction receipts validated by default, not just typed on paper.
  • ⚡ Async First: Async HTTP and one multiplexed WebSocket connection for streams and transactions, built for concurrent workflows.
  • 📚 Full Surface: Every REST endpoint and stream channel, all 20 user transaction types, the explorer and the deposit bridge, not just the popular ones.

Installation

pip install typed-lighter

How To

Reference

Design Philosophy

Typed Lighter follows the principles outlined in this blog post.

Details matter. Developer experience matters.

License

MIT — see LICENSE.

Metadata

Release files for typed-lighter 0.3.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 typed-lighter 0.3.1
File Size Uploaded Provenance Actions
typed_lighter-0.3.1.tar.gz 164.6 kB With provenance Details for typed_lighter-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for typed-lighter 0.3.1
File Interpreter ABI Platform Actions
typed_lighter-0.3.1-py3-none-any.whl Python 3 none any Details for typed_lighter-0.3.1-py3-none-any.whl

Total release size: 456.1 kB

Release files / typed_lighter-0.3.1.tar.gz

Download URL typed_lighter-0.3.1.tar.gz
Size 164.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d1e7a12ccbfd0559c2b64d06ad776bc5a762348ade956f43c66699dfdaf5f888
BLAKE2b-256 checksum
How to use checksums
d6484044e965e9b25965b92b548a4b9bd9cec1ec0520cfbb8b116388a701517a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Release files / typed_lighter-0.3.1-py3-none-any.whl

Download URL typed_lighter-0.3.1-py3-none-any.whl
Size 291.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c54c92a47671f33f9f47af3b678994577e1188f02e2728fc9d78c865ec744ba2
BLAKE2b-256 checksum
How to use checksums
bf919482842a92faf81eddbba0f7e058b86e6dceaf6524716b8ee6e13da29c7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Security for typed-lighter 0.3.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for typed_lighter-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

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.

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