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.
- Article
Response - Paginated result of
ArticleService::fetch_articles. - Article
Service - Fetches financial news articles.
- Article
Stream - 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_keyis required; the remaining fields default to the documented values shared by all sibling clients. - GetArticle
ByLink Params - Parameters for
ArticleService::fetch_article_by_link. - GetArticles
Params - Search parameters for
ArticleService::fetch_articles.Nonefields are omitted from the request; the server applies its documented defaults. - GetArticles
WebSocket Params - Filters for the enhanced WebSocket stream.
- GetRaw
Articles WebSocket Params - 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).
- RawWeb
Socket Client - Streams unenriched articles in real time (no sentiment, entities, or content — lower latency). No duplicate suppression.
- Source
- A news source available through the API.
- Source
Service - Lists the news sources available through the API.
- WebSocket
Client - Streams enriched articles in real time. Duplicate articles (same link within the last 10 deliveries) are suppressed.
- WebSocket
Options - Tunes the streaming clients. The defaults match the sibling clients.
- Webhook
Verification Error - Returned by
construct_webhook_eventwhen 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.
- Sort
Order - Sort direction for article queries.
Functions§
- construct_
webhook_ event - Verifies a finlight webhook and returns the contained article.