#news #api-client #http-request #article #client #search #api-key

newsapi

Wrapper for the newsapi, uses reqwest to do the http work. A learn by doing project

6 releases (breaking)

0.6.0 Jul 1, 2022
0.4.0 Nov 12, 2020
0.3.1 Feb 21, 2020
0.3.0 Dec 28, 2019
0.1.0 Apr 25, 2019

#1985 in Web programming

MIT/Apache

29KB
658 lines

The News API Rust Library

Build Status

The News API allows you to get breaking news headlines, and search for articles from over 30,000 news sources and blogs.

Breaking changes**

  • Version 0.5.x renames the Client struct to NewsAPIClient. 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 send has been replaced with send_async and send_sync for the asynchronous and synchronous variants respectively.

Summary

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

Notes

There are three endpoints

  1. Top Headlines
  2. Everything
  3. Sources

Top Headlines and Everything endpoints are wrapped by an Article struct and Sources by a Source struct. Both currently provide limited functionality.

Examples

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=5h79off128957edb3179y5da1nb36y9e

To list all examples:

cargo run --example

to run a specific example

cargo run --example get_sources_async

License

Licensed under MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

Disclaimer

We have no affiliation with the News API team.

Dependencies

~8–20MB
~274K SLoC