Skip to main content

newsapi_rust/
lib.rs

1//! # newsapi-rust
2//!
3//! A robust, async Rust client for the [NewsAPI.org](https://newsapi.org/) news aggregator API.
4//!
5//! This library provides a type-safe, async interface to all NewsAPI v2 endpoints:
6//! - `/top-headlines` - get breaking news headlines
7//! - `/everything` - search millions of articles
8//! - `/sources` - discover available news sources
9//!
10//! ## Quick Start
11//!
12//! Add to your `Cargo.toml`
13//! ```toml
14//! [dependencies]
15//! newsapi-rust = "0.1"
16//! tokio = { version = "1.0", features = ["full"] }
17//! ```
18//!
19//! Then:
20//! ```no_run
21//! use newsapi_rust::{NewsApiClient, ApiVersion};
22//!
23//! #[tokio::main]
24//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
25//!     let client =  NewsApiClient::new("YOUR_API_KEY", ApiVersion::V2);
26//!     let params = TopHeadlinesParams::new()
27//!         .country("us")
28//!        .category("technology");
29//!     let response = client.top_headlines(&params).await?;
30//!     for article in response.articles {
31//!        println!("{} - {}", article.title, article.url);
32//!     }
33//!     Ok(())
34//! }
35//! ```
36
37// Ensure all public items are documented
38#![deny(missing_docs)]
39#![doc(html_root_url = "https://docs.rs/newsapi-rust/0.1.0")]
40
41mod client;
42mod error;
43mod models;
44mod params;
45mod version;
46
47pub use client::NewsApiClient;
48pub use error::{NewsApiError, Result};
49pub use models::{Article, Source, SuccessResponse};
50pub use params::{EverythingParams, SourceParams, TopHeadlinesParams};
51pub use version::ApiVersion;