Skip to main content

finlight/
lib.rs

1//! Official Rust client for the [finlight.me](https://finlight.me) API v3: financial news
2//! search, article, company and source lookups, real-time streams and webhook verification.
3//!
4//! This crate (0.2) speaks API v3 only. Stay on `finlight-client = "0.1"` for API v2.
5//! Full API documentation: <https://docs.finlight.me>
6//!
7//! ```no_run
8//! use finlight::{Client, Config, SearchParams};
9//!
10//! # async fn run() -> Result<(), finlight::Error> {
11//! let client = Client::new(Config::new(std::env::var("FINLIGHT_API_KEY").unwrap_or_default()))?;
12//! let page = client
13//!     .articles()
14//!     .search(&SearchParams::new().query("ticker:NVDA").limit(10))
15//!     .await?;
16//! for article in &page.articles {
17//!     println!("{}  {}", article.source.domain, article.title);
18//! }
19//! # Ok(())
20//! # }
21//! ```
22//!
23//! Logging goes through `tracing` with the target `finlight`; nothing is printed without a
24//! subscriber. The API key, webhook secrets, signatures and full bodies are never logged.
25
26#![warn(missing_docs)]
27#![forbid(unsafe_code)]
28
29mod articles;
30mod client;
31mod companies;
32mod config;
33mod error;
34mod field;
35mod frames;
36mod http;
37mod models;
38mod params;
39mod sources;
40mod stream;
41mod time;
42mod version;
43mod vocab;
44pub mod webhooks;
45mod ws;
46
47pub use articles::{Articles, SearchAllResult};
48pub use client::Client;
49pub use companies::Companies;
50pub use config::{Config, ConfigBuilder, RetryOnBurst};
51pub use error::{
52    ApiError, ApiErrorKind, DecodeError, Error, FieldIssue, NetworkError, PreemptedError, Result,
53    TimeoutError, ValidationError, WebhookVerificationError, WebhookVerificationReason,
54};
55pub use field::Field;
56pub use models::{
57    Article, ArticlePage, ArticleSource, CacheInfo, Company, CompanyList, CompanyRecord, EventTag,
58    Listing, Media, Pagination, Sentiment, SkippedEntry, Source, SourceList, StreamEvent,
59    StreamEventKind,
60};
61pub use params::{
62    CompanySearchParams, DateInput, GetArticleOptions, RawStreamParams, SearchAllOptions,
63    SearchParams, StreamParams,
64};
65pub use sources::Sources;
66pub use stream::{AdmittedInfo, FinlightStream, QuotaWaitInfo, ReconnectInfo, StreamOptions};
67pub use version::{PAYLOAD_VERSION, VERSION};
68pub use vocab::{
69    CompanyRole, ConnectionErrorCode, EventDirection, EventType, Importance, IncludeBlock, OrderBy,
70    PreemptReason, ProblemCode, RateLimitType, ReconnectReason, SentimentLabel, SortOrder,
71    SourceType, StreamEventName, WebhookEventName,
72};
73pub use webhooks::{WebhookEvent, WebhookPayload, WrongPayloadVersion};
74pub use ws::{WsConnectFuture, WsConnector, WsIo};
75
76#[cfg(doctest)]
77#[doc = include_str!("../README.md")]
78struct ReadmeDoctests;