Ruby client library

Use the unofficial Ruby client library to integrate News API into your Ruby application without worrying about what's going on under the hood.

Source: olegmikhnovich/News-API-ruby


$ gem install news-api


require 'news-api'

# Init
newsapi ="API_KEY")             

# /v2/top-headlines
top_headlines = newsapi.get_top_headlines(q: 'bitcoin',
                                          sources: 'bbc-news,the-verge',
                                          category: 'business',
                                          language: 'en',
                                          country: 'us')

# /v2/everything
all_articles = newsapi.get_everything(q: 'bitcoin',
                                      sources: 'bbc-news,the-verge',
                                      domains: ',',
                                      from: '2017-12-01',
                                      to: '2017-12-12',
                                      language: 'en',
                                      sortBy: 'relevancy',
                                      page: 2))

# /v2/sources
sources = newsapi.get_sources(country: 'us', language: 'en')