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.1.tar.gz (11.8 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.1-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: infoway_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 11.8 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.1.tar.gz
Algorithm Hash digest
SHA256 4b215c416baadaacaaddd0e6efe8fbdec292ddd956091852790e8d9a57ce1d36
MD5 cd05222acc1e29895abb7f8406c191f8
BLAKE2b-256 36fdec901290fdd442b91844e8ebf25a599f4e67612bbcbc58ce804bce4972ef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: infoway_sdk-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cc6459630d71534722d85a3ebb6883640db311c03e98c589b793dd082f7c192c
MD5 0ed711880b82b77125b48b1bd9167643
BLAKE2b-256 4056d4d120a85d9d5a7499741a0c75915b8a99a24630d2a98741e63373c0db40

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