pylightningfx
Python client for the bitFlyer Lightning API.
- Every HTTP endpoint, Public and Private, with Pydantic response models
asynciosupport 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_orderis ambiguous — the order may already be live — so only safe methods are retried by default. Opt in withRetryPolicy(retry_unsafe_methods=True)if you reconcile orders afterwards. HTTP 429 is always retried, since a rate-limited request never reached the matching engine. withdrawis 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 passRateLimits.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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e983a5107d5448ff457492dee50a7bdfe61e2f6dd9dd8816b243ff7b308cd50e
|
|
| MD5 |
f70ec4ca4e0da54066d4d2629a41e374
|
|
| BLAKE2b-256 |
038acabe5e2a0b0b1185450adee05e45c2d9f0da462524027908a33004930b62
|
Provenance
The following attestation bundles were made for pylightningfx-0.2.0.tar.gz:
Publisher:
release.yml on ykus4/pylightningfx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pylightningfx-0.2.0.tar.gz -
Subject digest:
e983a5107d5448ff457492dee50a7bdfe61e2f6dd9dd8816b243ff7b308cd50e - Sigstore transparency entry: 2303561229
- Sigstore integration time:
-
Permalink:
ykus4/pylightningfx@1244039431a50baa7889ff17fed8f8c8ff7d1abe -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ykus4
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1244039431a50baa7889ff17fed8f8c8ff7d1abe -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65208fca7fe49277d49bc06cfa3989c8d350c2bbbfdc082482274a1631fe4ded
|
|
| MD5 |
3fdfa807614a2fe4d861bfb4136bc5fc
|
|
| BLAKE2b-256 |
6f5cbbf833241aa4ba43f447a68b9e6db6faa9108557bad0d7efae62784f8ae3
|
Provenance
The following attestation bundles were made for pylightningfx-0.2.0-py3-none-any.whl:
Publisher:
release.yml on ykus4/pylightningfx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pylightningfx-0.2.0-py3-none-any.whl -
Subject digest:
65208fca7fe49277d49bc06cfa3989c8d350c2bbbfdc082482274a1631fe4ded - Sigstore transparency entry: 2303561260
- Sigstore integration time:
-
Permalink:
ykus4/pylightningfx@1244039431a50baa7889ff17fed8f8c8ff7d1abe -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ykus4
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1244039431a50baa7889ff17fed8f8c8ff7d1abe -
Trigger Event:
push
-
Statement type: