Skip to main content

Crate finlight_client

Crate finlight_client 

Source
Expand description

Official Rust client for the finlight.me API — financial news with sentiment analysis, entity recognition, and real-time streaming.

Full API documentation: https://docs.finlight.me

§Quick start

use finlight_client::{Client, Config, GetArticlesParams};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new(Config::new(std::env::var("FINLIGHT_API_KEY")?))?;

    let resp = client
        .articles
        .fetch_articles(&GetArticlesParams {
            query: Some("nvidia".into()),
            page_size: Some(10),
            ..Default::default()
        })
        .await?;
    for article in resp.articles {
        println!("[{}] {}", article.source, article.title);
    }
    Ok(())
}

§Streaming

use finlight_client::{Client, Config, GetArticlesWebSocketParams};
use futures_util::StreamExt;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new(Config::new(std::env::var("FINLIGHT_API_KEY")?))?;

    let mut stream = client.websocket.stream(GetArticlesWebSocketParams {
        query: Some("nvidia".into()),
        ..Default::default()
    });
    while let Some(article) = stream.next().await {
        let article = article?; // Err is terminal (e.g. blocked by server)
        println!("[{}] {}", article.source, article.title);
    }
    Ok(())
}

Structs§

Article
An enriched news article as returned by the REST API, the enhanced WebSocket stream, and webhooks.
ArticleResponse
Paginated result of ArticleService::fetch_articles.
ArticleService
Fetches financial news articles.
ArticleStream
A stream of articles delivered over the finlight WebSocket. Dropping the stream disconnects and stops the background task.
Client
Entry point to the finlight API.
Company
An entity recognized in an article.
Config
Configures the finlight client. Only api_key is required; the remaining fields default to the documented values shared by all sibling clients.
GetArticleByLinkParams
Parameters for ArticleService::fetch_article_by_link.
GetArticlesParams
Search parameters for ArticleService::fetch_articles. None fields are omitted from the request; the server applies its documented defaults.
GetArticlesWebSocketParams
Filters for the enhanced WebSocket stream.
GetRawArticlesWebSocketParams
Filters for the raw WebSocket stream.
Listing
One exchange listing of a company.
RawArticle
An unenriched article as delivered by the raw WebSocket stream (no sentiment, entities, or content — lower latency).
RawWebSocketClient
Streams unenriched articles in real time (no sentiment, entities, or content — lower latency). No duplicate suppression.
Source
A news source available through the API.
SourceService
Lists the news sources available through the API.
WebSocketClient
Streams enriched articles in real time. Duplicate articles (same link within the last 10 deliveries) are suppressed.
WebSocketOptions
Tunes the streaming clients. The defaults match the sibling clients.
WebhookVerificationError
Returned by construct_webhook_event when a webhook fails signature, timestamp, or payload validation.

Enums§

Category
An article category assigned by finlight’s classification.
Error
Errors returned by the finlight client.
OrderBy
Sort field for article queries.
SortOrder
Sort direction for article queries.

Functions§

construct_webhook_event
Verifies a finlight webhook and returns the contained article.