thenewsapi

Crates.iothenewsapi
lib.rsthenewsapi
version0.1.2
sourcesrc
created_at2024-07-19 23:41:08.175283
updated_at2024-07-19 23:47:12.088865
descriptionA client library for interacting with The News API, a free service providing access to global news from thousands of sources.
homepagehttps://github.com/rishabh-bector/thenewsapi
repositoryhttps://github.com/rishabh-bector/thenewsapi
max_upload_size
id1309154
size19,154
Rishabh Bector (rishabh-bector)

documentation

https://docs.rs/thenewsapi

README

The News API

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.

Features

  • Fetch latest headlines by category
  • Retrieve top stories
  • Access all news articles with advanced filtering
  • Find similar news articles based on a specific article UUID
  • Retrieve specific articles by UUID
  • List available news sources

Installation

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"

Usage

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.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contribution

Contributions are welcome. Please open an issue or submit a pull request on GitHub.

Commit count: 0

cargo fmt