Official Python SDK for Infoway real-time financial data API
Project description
Infoway SDK
English | 中文
Official Python SDK for Infoway real-time financial data API. Full documentation at docs.infoway.io.
Installation
pip install infoway-sdk
Quick Start
from infoway import InfowayClient, KlineType
client = InfowayClient(api_key="YOUR_API_KEY")
# Real-time trades
trades = client.stock.get_trade("AAPL.US")
# Daily K-lines for crypto
klines = client.crypto.get_kline("BTCUSDT", kline_type=KlineType.DAY, count=30)
# Market temperature
temp = client.market.get_temperature(market="HK,US")
# Sector/plate rankings
plates = client.plate.get_industry("HK", limit=10)
WebSocket Streaming
import asyncio
from infoway.ws import InfowayWebSocket
async def main():
ws = InfowayWebSocket(api_key="YOUR_API_KEY", business="stock")
async def on_trade(msg):
print(f"Trade: {msg}")
ws.on_trade = on_trade
await ws.subscribe_trade("AAPL.US,TSLA.US")
await ws.connect()
asyncio.run(main())
WebSocket Features
- Auto-reconnect with exponential backoff (1s to 30s cap)
- Heartbeat keepalive at 30-second intervals
- Auto-resubscribe on reconnect -- no manual re-subscription needed
- Event callbacks:
on_trade,on_depth,on_kline,on_error,on_reconnect,on_disconnect
REST API Modules
| Module | Accessor | Description |
|---|---|---|
| Stock | client.stock |
HK, US, CN equities -- trade, depth, K-line |
| Crypto | client.crypto |
Cryptocurrency pairs -- trade, depth, K-line |
| Japan | client.japan |
Japan market data -- trade, depth, K-line |
| India | client.india |
India market data -- trade, depth, K-line |
| Common | client.common |
Cross-market data -- trade, depth, K-line |
| Basic | client.basic |
Symbol lists, trading days, trading hours, adjustment factors |
| Market | client.market |
Market temperature, breadth, indexes, leaders, rank config |
| Plate | client.plate |
Sector/industry/concept plates, members, charts |
| Stock Info | client.stock_info |
Fundamentals -- valuation, ratings, company, panorama, events |
Configuration
You can pass api_key directly or set it via environment variable:
export INFOWAY_API_KEY="YOUR_API_KEY"
# Reads INFOWAY_API_KEY from environment automatically
client = InfowayClient()
Client Options
client = InfowayClient(
api_key="YOUR_API_KEY",
base_url="https://data.infoway.io", # default
timeout=15.0, # request timeout in seconds
max_retries=3, # retry count for failed requests
)
Error Handling
from infoway import InfowayClient, InfowayAPIError, InfowayAuthError, InfowayTimeoutError
client = InfowayClient(api_key="YOUR_API_KEY")
try:
trades = client.stock.get_trade("AAPL.US")
except InfowayAuthError:
print("Invalid API key")
except InfowayTimeoutError:
print("Request timed out")
except InfowayAPIError as e:
print(f"API error [{e.ret}]: {e.msg}")
License
MIT
Get your free API key at infoway.io -- 7-day free trial, no credit card required.
Project details
Release history Release notifications | RSS feed
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 infoway_sdk-0.1.2.tar.gz.
File metadata
- Download URL: infoway_sdk-0.1.2.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0604572e5b81d565ad0538baec260f5f3d8e760c033f52de4f07bc052174d5f
|
|
| MD5 |
bbee8f6c57a090f11c1bf989ccdfee8a
|
|
| BLAKE2b-256 |
c7e4ebcb6d1fc85027e526de875cc0f785d46a4a1a0adce54079d27ae9c30de3
|
File details
Details for the file infoway_sdk-0.1.2-py3-none-any.whl.
File metadata
- Download URL: infoway_sdk-0.1.2-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
503e3463b265e3b5e4223dcdee697b8037e7723cbc2dfb36049f5be2c700af54
|
|
| MD5 |
9534aa08d3278a84d1cf1b53d5f9f0e7
|
|
| BLAKE2b-256 |
58db6d73c7fb54c066d37db9d36c02867c04f5b51bc74f05a3a9d0fe8d4fbad2
|