Python SDK

Overview

Official Python SDK for the Infoway real-time financial data API, providing REST API and WebSocket streaming interfaces across stocks, crypto, forex, and more.

Item
Details

Python

3.9+

License

MIT

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")

# Crypto daily K-lines
klines = client.crypto.get_kline("BTCUSDT", kline_type=KlineType.DAY, count=30)

# Market temperature
temp = client.market.get_temperature(market="HK,US")

# Industry sector ranking
plates = client.plate.get_industry("HK", limit=10)

Configuration

Pass api_key directly or set it via environment variable:

Client Options

REST API Modules

Module
Accessor
Description

Stock

client.stock

HK, US, CN equities — trade, depth, K-line

Crypto

client.crypto

Cryptocurrency — trade, depth, K-line

Japan

client.japan

Japan market — trade, depth, K-line

India

client.india

India market — trade, depth, K-line

Common

client.common

Cross-market — trade, depth, K-line

Basic

client.basic

Symbol lists, trading days, hours, adjustment factors

Market

client.market

Temperature, breadth, indexes, leaders, rank config

Plate

client.plate

Industry/concept sectors, members, heatmap

Stock Info

client.stock_info

Fundamentals — valuation, ratings, company, panorama

Market Data Methods (stock / crypto / japan / india / common)

Method
Description

get_trade(codes)

Get real-time trade data

get_depth(codes)

Get order book depth

get_kline(codes, kline_type, count)

Get K-line (OHLCV) data

Basic Info Methods

Market Overview Methods

Plate / Sector Methods

Stock Fundamental Methods

WebSocket Streaming

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

WebSocket Message Codes

Client → server (subscribe / heartbeat):

Code
Name
Description

10000

SUB_TRADE

Subscribe to trade data

10003

SUB_DEPTH

Subscribe to depth data

10006

SUB_KLINE

Subscribe to K-line data (payload data.arr=[{codes, type}], where type is the K-line interval — see below)

10010

HEARTBEAT

Heartbeat keepalive

11000

UNSUB_TRADE

Unsubscribe trade data

11001

UNSUB_DEPTH

Unsubscribe depth data

11002

UNSUB_KLINE

Unsubscribe K-line data

Server → client (acks / pushes):

Code
Name
Description

10001

SUB_TRADE_ACK

Trade subscribe acknowledgement

10002

PUSH_TRADE

Real-time trade push

10004

SUB_DEPTH_ACK

Depth subscribe acknowledgement

10005

PUSH_DEPTH

Real-time depth push

10007

SUB_KLINE_ACK

K-line subscribe acknowledgement

10008

PUSH_KLINE

Real-time K-line push

11010

UNSUB_ACK

Unsubscribe acknowledgement

K-line Types

Enum
Interval

KlineType.MIN_1 (1)

1 minute

KlineType.MIN_5 (2)

5 minutes

KlineType.MIN_15 (3)

15 minutes

KlineType.MIN_30 (4)

30 minutes

KlineType.HOUR_1 (5)

1 hour

KlineType.HOUR_2 (6)

2 hours

KlineType.HOUR_4 (7)

4 hours

KlineType.DAY (8)

1 day

KlineType.WEEK (9)

1 week

KlineType.MONTH (10)

1 month

KlineType.QUARTER (11)

1 quarter

KlineType.YEAR (12)

1 year

Error Handling


Last updated