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.1.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.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: finlight_client-0.5.1.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.1.tar.gz
Algorithm Hash digest
SHA256 d96c1ab3d0263fdd94c71821d197910a698c32708f3ea6e81cbb48f814a062fd
MD5 af4a4dcaa61f86192d9a9d8b6139c5ff
BLAKE2b-256 e98a28f52a38b90a3c0647652a911dbc6788074fe4657c01fda845d30099f24b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for finlight_client-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fa0fac867b1a4c9861eab186513002d46189b2fb18e2efd48022104a5e710f47
MD5 4351758f3ebf6de8e7c5df3ce85079af
BLAKE2b-256 daf11bc0cada09622fc7842fa8677b79540054e2c45203530285b740b6dd2c5b

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