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.

Metadata

Release files for pylightningfx 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pylightningfx 0.2.0
File Size Uploaded Provenance Actions
pylightningfx-0.2.0.tar.gz 32.3 kB With provenance Details for pylightningfx-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pylightningfx 0.2.0
File Interpreter ABI Platform Actions
pylightningfx-0.2.0-py3-none-any.whl Python 3 none any Details for pylightningfx-0.2.0-py3-none-any.whl

Total release size: 74.4 kB

Release files / pylightningfx-0.2.0.tar.gz

Download URL pylightningfx-0.2.0.tar.gz
Size 32.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e983a5107d5448ff457492dee50a7bdfe61e2f6dd9dd8816b243ff7b308cd50e
BLAKE2b-256 checksum
How to use checksums
038acabe5e2a0b0b1185450adee05e45c2d9f0da462524027908a33004930b62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Jul 31, 2026.

Transparency log

Release files / pylightningfx-0.2.0-py3-none-any.whl

Download URL pylightningfx-0.2.0-py3-none-any.whl
Size 42.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65208fca7fe49277d49bc06cfa3989c8d350c2bbbfdc082482274a1631fe4ded
BLAKE2b-256 checksum
How to use checksums
6f5cbbf833241aa4ba43f447a68b9e6db6faa9108557bad0d7efae62784f8ae3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Jul 31, 2026.

Transparency log

Security for pylightningfx 0.2.0

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pylightningfx-0.2.0.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 Jul 31, 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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

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