Skip to main content

Official Python SDK for Infoway real-time financial data API

Project description

Infoway SDK

PyPI version Python License: MIT

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


Download files

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

Source Distribution

infoway_sdk-0.1.0.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

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

infoway_sdk-0.1.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file infoway_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: infoway_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for infoway_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3b977766ca7965c1ac195d71faeb91f9271e56ca0c880f4888e6faed8c04f5a9
MD5 b5aea234ba8c30c21d15ebd9fb5cf6e0
BLAKE2b-256 f98d7f961c5ac63c70e9d4c36fae3c4f8baad94c7448fa5275b641639c8015f7

See more details on using hashes here.

File details

Details for the file infoway_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: infoway_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for infoway_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ae8820bed7541c47de6964e2055c83e636ba77dedde519da8db76f59ab77005
MD5 fd347659f556b4c189cb3f2b1f6b03ea
BLAKE2b-256 98b446a06ea4dd492fe86a4e3ad9131d2bb8cc615eb86dda70399fbdb0e7885c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page