Crates.io | thenewsapi |
lib.rs | thenewsapi |
version | 0.1.2 |
source | src |
created_at | 2024-07-19 23:41:08.175283 |
updated_at | 2024-07-19 23:47:12.088865 |
description | A client library for interacting with The News API, a free service providing access to global news from thousands of sources. |
homepage | https://github.com/rishabh-bector/thenewsapi |
repository | https://github.com/rishabh-bector/thenewsapi |
max_upload_size | |
id | 1309154 |
size | 19,154 |
A Rust client library for interacting with The News API (https://www.thenewsapi.com/), providing access to global news from thousands of sources with exceptional response times.
Add this to your Cargo.toml
:
[dependencies]
thenewsapi = "0.1.0"
Ensure you also have the required dependencies:
[dependencies]
reqwest = { version = "0.11", features = ["json"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = { version = "1.0", features = ["full"] }
anyhow = "1.0"
use thenewsapi::Client;
#[tokio::main]
async fn main() {
let api_token = "your_api_token";
let client = Client::new(api_token);
// Example: Fetch latest headlines
let params = HeadlinesParams::default();
match client.get_headlines(params).await {
Ok(headlines) => println!("{:?}", headlines),
Err(e) => eprintln!("Error fetching headlines: {:?}", e),
}
}
See the docs for all supported methods and parameters.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome. Please open an issue or submit a pull request on GitHub.