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§
- AllNews
Params - Parameters for the
get_all_news
API call. - AllNews
Response - Represents the response for all news articles in the News API.
- Article
- Represents an article in the News API.
- Article
ByUuid Response - Represents the response for a specific article by UUID in the News API.
- Client
- A client for the News API.
- Headlines
Params - Parameters for the
get_headlines
API call. - Headlines
Response - Represents the response for headlines in the News API.
- Meta
- Represents metadata in the News API responses.
- Similar
Article - Represents a similar article in the News API.
- Similar
News Params - Parameters for the
get_similar_news
API call. - Similar
News Response - Represents the response for similar news articles in the News API.
- Source
- Represents a source in the News API.
- Sources
Params - Parameters for the
get_sources
API call. - Sources
Response - Represents the response for sources in the News API.
- TopStories
Params - Parameters for the
get_top_stories
API call. - TopStories
Response - Represents the response for top stories in the News API.