Skip to main content

Python client for the Finlight API

Project description

Finlight Client – Python Library

A Python client library for interacting with the Finlight News API.
Finlight delivers real-time and historical financial news articles, enriched with sentiment analysis and market insights. This library makes it easy to integrate Finlight into your Python applications.


✨ Features

  • Fetch basic and extended articles via REST API.
  • Stream real-time news using WebSocket.
  • Built-in retry and timeout handling.
  • Fully type-annotated models using pydantic.
  • Lightweight and developer-friendly.

📦 Installation

pip install finlight-client

🚀 Quick Start

Fetching Articles via REST API

from finlight_client import FinlightApi, ApiConfig
from finlight_client.models import GetArticlesParams

def main():
    client = FinlightApi(
        config=ApiConfig(
            api_key="your_api_key"
        )
    )

    params = GetArticlesParams(query="Nvidia", language="en")
    articles = client.articles.get_extended_articles(params=params)
    print(articles)

if __name__ == "__main__":
    main()

Streaming Real-Time Articles via WebSocket

import asyncio
from finlight_client import FinlightApi, ApiConfig
from finlight_client.models import GetArticlesWebSocketParams

def on_article(article):
    print("📨 Received article:", article.title)

async def main():
    client = FinlightApi(
        config=ApiConfig(
            api_key="your_api_key"
        )
    )

    payload = GetArticlesWebSocketParams(
        sources=["www.reuters.com"],
        language="en"
    )

    await client.websocket.connect(
        request_payload=payload,
        on_article=on_article
    )

if __name__ == "__main__":
    asyncio.run(main())

⚙️ Configuration

ApiConfig accepts the following parameters:

Parameter Type Description Default
api_key str Your API key. Required
base_url str Base URL for REST API. https://api.finlight.me
wss_url str WebSocket server URL. wss://wss.finlight.me
timeout int Timeout for requests (ms). 5000
retry_count int Max retries for failed requests. 3

📚 API Reference

client.articles.get_basic_articles(params)

  • Fetch short-form articles with titles, links, etc.

client.articles.get_extended_articles(params)

  • Fetch full articles with summaries and full text.

client.websocket.connect(request_payload, on_article)

  • Subscribe to a real-time feed of articles via WebSocket.
  • Payload: GetArticlesWebSocketParams
  • Callback: on_article(article: Article)

🧯 Error Handling

  • HTTP errors raise detailed Python exceptions.
  • WebSocket disconnections trigger auto-reconnect unless stopped.
  • Logs are printed via the finlight-websocket-client logger.

🤝 Contributing

Pull requests and issues are welcome! Please ensure any contributions are well tested and documented.


📄 License

This project is licensed under the MIT License. See the LICENSE file.


🔗 Resources


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

finlight_client-0.5.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

finlight_client-0.5.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file finlight_client-0.5.0.tar.gz.

File metadata

  • Download URL: finlight_client-0.5.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.4

File hashes

Hashes for finlight_client-0.5.0.tar.gz
Algorithm Hash digest
SHA256 0e2ca2795199c48348fcc52a5833286486b06efdab42473a30d93c84cd3f431a
MD5 4b0ff2c3627b49fdc2cb8e2baa7f3449
BLAKE2b-256 ee1561e0c2d0f7f99457b37249a36c3a90c76c8bf97619bbfccb3245600f5066

See more details on using hashes here.

File details

Details for the file finlight_client-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for finlight_client-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 853f87720a65f045d0b6f3440bad2ea98b91872c1d2903480bb4da8c6638e401
MD5 aa7e852f190a6b6109d384ff1d38f546
BLAKE2b-256 c5de7e8958a25a3a8e1920de874b8bdf973b19f4fc36c0d8c1e176ac5993f096

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