get_headlines_all: Returns all headlines from newsapi.org

Description Usage Arguments Value Examples

View source: R/get_headlines_all.R

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
3
4
5
6
7
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)

CorrelAid/newsanchor documentation built on Sept. 6, 2020, 10:44 a.m.