Skip to main content

pylightningfx

Python client for the bitFlyer Lightning API.

PyPI Python CI License

Documentation · 日本語

  • Every HTTP endpoint, Public and Private, with Pydantic response models
  • asyncio support with an identical API surface
  • The Realtime WebSocket API, with automatic reconnect and resubscribe
  • Request signing, client-side rate limiting, and retries that never replay an order
  • Fully typed, checked under mypy --strict

Installation

pip install pylightningfx

Requires Python 3.13 or newer.

Usage

Market data

from pylightningfx import Client, ProductCode

with Client() as client:
    ticker = client.get_ticker(ProductCode.FX_BTC_JPY)
    print(ticker.ltp, ticker.best_bid, ticker.best_ask)

Trading

from pylightningfx import ChildOrderType, Client, ProductCode, Side

with Client("YOUR_API_KEY", "YOUR_API_SECRET") as client:
    ack = client.send_child_order(
        ProductCode.BTC_JPY, ChildOrderType.LIMIT, Side.BUY, 0.001, price=5_000_000
    )
    print(ack.child_order_acceptance_id)

    for order in client.get_child_orders(ProductCode.BTC_JPY, child_order_state="ACTIVE"):
        print(order.child_order_id, order.outstanding_size)

Streaming

from pylightningfx import ProductCode, RealtimeClient, channels

with RealtimeClient() as rt:
    rt.subscribe(channels.executions(ProductCode.FX_BTC_JPY))
    for message in rt.listen():
        for trade in message.data:
            print(trade.exec_date, trade.side, trade.price, trade.size)

Subscribe to channels.CHILD_ORDER_EVENTS with credentials to stream your own order events. The connection reconnects and resubscribes on its own if it drops.

asyncio

import asyncio

from pylightningfx import AsyncClient, ProductCode


async def main() -> None:
    async with AsyncClient() as client:
        board, ticker = await asyncio.gather(
            client.get_board(ProductCode.FX_BTC_JPY),
            client.get_ticker(ProductCode.FX_BTC_JPY),
        )
        print(board.mid_price, ticker.ltp)


asyncio.run(main())

AsyncRealtimeClient is the streaming equivalent.

Notes on safety

Orders are real money, so a few defaults are deliberately conservative:

  • Retries never replay a write. A 5xx or a timeout on send_child_order is ambiguous — the order may already be live — so only safe methods are retried by default. Opt in with RetryPolicy(retry_unsafe_methods=True) if you reconcile orders afterwards. HTTP 429 is always retried, since a rate-limited request never reached the matching engine.
  • withdraw is never retried, whatever the policy says.
  • Rate limits are respected client-side. The client tracks bitFlyer's 500-per-5-minutes general budget and the tighter 300-per-5-minutes order budget, and spreads bursts rather than collecting 429s. Configure with RateLimits, or pass RateLimits.disabled() to opt out.

Errors arrive as APIError carrying bitFlyer's numeric status and error_message, not just an HTTP code.

See the documentation for the full API reference.

Download files

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

Source Distribution

pylightningfx-0.2.0.tar.gz (32.3 kB view details)

Uploaded Source

Built Distribution

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

pylightningfx-0.2.0-py3-none-any.whl (42.0 kB view details)

Uploaded Python 3

File details

Details for the file pylightningfx-0.2.0.tar.gz.

File metadata

  • Download URL: pylightningfx-0.2.0.tar.gz
  • Upload date:
  • Size: 32.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pylightningfx-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e983a5107d5448ff457492dee50a7bdfe61e2f6dd9dd8816b243ff7b308cd50e
MD5 f70ec4ca4e0da54066d4d2629a41e374
BLAKE2b-256 038acabe5e2a0b0b1185450adee05e45c2d9f0da462524027908a33004930b62

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylightningfx-0.2.0.tar.gz:

Publisher: release.yml on ykus4/pylightningfx

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

File details

Details for the file pylightningfx-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pylightningfx-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 42.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pylightningfx-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 65208fca7fe49277d49bc06cfa3989c8d350c2bbbfdc082482274a1631fe4ded
MD5 3fdfa807614a2fe4d861bfb4136bc5fc
BLAKE2b-256 6f5cbbf833241aa4ba43f447a68b9e6db6faa9108557bad0d7efae62784f8ae3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylightningfx-0.2.0-py3-none-any.whl:

Publisher: release.yml on ykus4/pylightningfx

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

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.0

2 files

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