Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Fugle MarketData

Fugle MarketData API client library for Python

Installation

$ pip install fugle-marketdata

Importing

from fugle_marketdata import WebSocketClient, RestClient

Usage

The library is an isomorphic Python client that supports REST API and WebSocket.

REST API

client = RestClient(api_key = 'YOUR_API_KEY')
stock = client.stock  # Stock REST API client
print(stock.intraday.quote(symbol="2330"))

WebSocket API

from fugle_marketdata import WebSocketClient, RestClient


def handle_message(message):
    print(f'message: {message}')


def handle_connect():
    print('connected')


def handle_disconnect(code, message):
    print(f'disconnect: {code}, {message}')


def handle_error(error):
    print(f'error: {error}')


def main():
    client = WebSocketClient(api_key='YOUR_API_KEY')
    stock = client.stock
    stock.on("connect", handle_connect)
    stock.on("message", handle_message)
    stock.on("disconnect", handle_disconnect)
    stock.on("error", handle_error)
    stock.connect()
    stock.subscribe({
        "channel": 'trades',
        "symbol": '2330'
    })


if __name__ == "__main__":
    main()

Error Handling

The library provides a custom FugleAPIError exception for API-related errors, which includes detailed debugging information.

Catching API Errors

from fugle_marketdata import RestClient, FugleAPIError

client = RestClient(api_key='YOUR_API_KEY')

try:
    data = client.stock.intraday.quote(symbol="2330")
except FugleAPIError as e:
    # Access error details for debugging
    print(f"Error: {e.message}")
    print(f"URL: {e.url}")
    print(f"Status Code: {e.status_code}")
    print(f"Request Params: {e.params}")
    print(f"Response: {e.response_text}")

Error Attributes

The FugleAPIError exception provides the following attributes:

  • message: Error description
  • url: The API endpoint that was called
  • status_code: HTTP status code (if available)
  • params: Request parameters that were sent
  • response_text: Raw response text from the API (truncated to 200 chars)

Common Error Scenarios

HTTP Errors (4xx, 5xx):

try:
    data = client.stock.intraday.quote(symbol="INVALID_SYMBOL")
except FugleAPIError as e:
    if e.status_code == 404:
        print("Symbol not found")
    elif e.status_code >= 500:
        print("Server error, please try again later")

Network Errors:

try:
    data = client.stock.intraday.quote(symbol="2330")
except FugleAPIError as e:
    if e.status_code is None:
        print("Network error occurred")

License

MIT

Download files

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

Source Distribution

fugle_marketdata-2.5.0rc5.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.

fugle_marketdata-2.5.0rc5-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file fugle_marketdata-2.5.0rc5.tar.gz.

File metadata

  • Download URL: fugle_marketdata-2.5.0rc5.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.14.6 Linux/6.17.0-1020-azure

File hashes

Hashes for fugle_marketdata-2.5.0rc5.tar.gz
Algorithm Hash digest
SHA256 1924d560bae38cea4a145ea5d68b9426f2a03a1a5d97ccb2716ae1bdc0c536c0
MD5 6991e7a18da1c294f88b41a97290de57
BLAKE2b-256 c007306ad3b54232a9b11af5f2609592e119b959c4df3578cadd7442793df4f4

See more details on using hashes here.

File details

Details for the file fugle_marketdata-2.5.0rc5-py3-none-any.whl.

File metadata

  • Download URL: fugle_marketdata-2.5.0rc5-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.14.6 Linux/6.17.0-1020-azure

File hashes

Hashes for fugle_marketdata-2.5.0rc5-py3-none-any.whl
Algorithm Hash digest
SHA256 0ee030b08b7c5d60762115821c482ecc4108a6574d0ec4ec0f66d5403469fe84
MD5 3d7c0159b2c0135f4b45cd3003e40cac
BLAKE2b-256 91bfa37da0db38903cdaf0a6f8b57a47eaf367a75a98b498dc671167ddf73170

See more details on using hashes here.

Release history Release notifications | RSS feed

2.6.0

2 files

2.5.0

2 files

This release

2.5.0rc5 This release

2 files

2.4.1

2 files

2.4.0

2 files

2.3.1

2 files

2.3.0

2 files

2.2.0

2 files

2.1.1

2 files

2.1.0

2 files

2.0.0

2 files

1.1.0

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page