Crate thenewsapi

Source
Expand description

§News API Client

This crate provides a client library for interacting with the News API.

The News API provides global news from thousands of sources with exceptional response times. This client allows you to access headlines, top stories, all news articles, similar news articles, and sources.

§Usage

Add this to your Cargo.toml:

[dependencies]
news_api_client = "0.1.0"
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"

§Examples

use news_api_client::{Client, HeadlinesParams};

#[tokio::main]
async fn main() {
    let api_token = "your_api_token";
    let client = Client::new(api_token);

    let params = HeadlinesParams::default();
    let headlines = client.get_headlines(params).await.unwrap();
    println!("{:?}", headlines);
}

Structs§

AllNewsParams
Parameters for the get_all_news API call.
AllNewsResponse
Represents the response for all news articles in the News API.
Article
Represents an article in the News API.
ArticleByUuidResponse
Represents the response for a specific article by UUID in the News API.
Client
A client for the News API.
HeadlinesParams
Parameters for the get_headlines API call.
HeadlinesResponse
Represents the response for headlines in the News API.
Meta
Represents metadata in the News API responses.
SimilarArticle
Represents a similar article in the News API.
SimilarNewsParams
Parameters for the get_similar_news API call.
SimilarNewsResponse
Represents the response for similar news articles in the News API.
Source
Represents a source in the News API.
SourcesParams
Parameters for the get_sources API call.
SourcesResponse
Represents the response for sources in the News API.
TopStoriesParams
Parameters for the get_top_stories API call.
TopStoriesResponse
Represents the response for top stories in the News API.