The News API allows you to get breaking news headlines, and search for articles from over 30,000 news sources and blogs.
-
Version 0.5.x renames the
Clientstruct toNewsAPIClient. See examples for demonstrated usage. -
Version 0.4.x introduces async fetch. While synchronous functionality is retained, the relevant functions have been renamed. Please check examples for further details. The core change is
sendhas been replaced withsend_asyncandsend_syncfor the asynchronous and synchronous variants respectively.
All you need is an API key to
- Search live top headlines or search all articles
- New articles available with 15 minute delay
- And Search articles up to a month old
- Get short article snippet or descriptions
The following limits apply
- 1,000 requests per day
- No extra requests available
- No uptime SLA
- Basic support
- NewsAPI.org attribution required
See here for pricing
There are three endpoints
Top Headlines and Everything endpoints are wrapped by an Article struct and Sources by a Source struct. Both currently provide limited functionality.
As described in The Cargo Book the project has some simple examples in examples/. These can be run via cargo after you've exported your NEWSAPI_KEY
export NEWSAPI_KEY=5h79off128957edb3179y5da1nb36y9eTo list all examples:
cargo run --exampleto run a specific example
cargo run --example get_sources_asyncLicensed under MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
We have no affiliation with the News API team.