get_headlines_all: Returns all headlines from newsapi.org

Description Usage Arguments Value Examples

Description

get_headlines returns live top and breaking headlines for a country, specific category in a country, single source, or multiple sources. You can also search with keywords. Articles are sorted by the earliest date published first. To automatically download all results, use get_headlines_all.

Please check that the api_key is available. You can provide an explicit definition of the api_key or use set_api_key

Valid searchterms are provided in terms_category, terms_country or terms_sources

Usage

1
2
get_headlines_all(query = NULL, category = NULL, country = NULL,
  sources = NULL, api_key = Sys.getenv("NEWS_API_KEY"))

Arguments

query

Character string that contains the searchterm

category

Category you want headlines from

country

Country you want headlines for

sources

Character string with IDs (comma separated) of the news outlets you want to focus on (e.g., "usa-today, spiegel-online").

api_key

Character string with the API key you get from newsapi.org. Passing it is compulsory. Alternatively, function can be provided from the global environment (see set_api_key).

Value

List with two dataframes:
1) Data frame with results_df
2) Data frame with meta_data

Examples

1
2
3
4
5
## Not run: 
df <- get_headlines_all(query = "sports")
df <- get_headlines_all(category = "health")

## End(Not run)

newsanchor documentation built on June 29, 2019, 5:02 p.m.