Description Usage Arguments Value Examples
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 key or use set_api_key()
.
Valid searchterms are provided in the data sets terms_category
,
terms_country
or terms_sources
.
1 2 3 | get_headlines(query = NULL, category = NULL, country = NULL,
sources = NULL, page = 1, page_size = 100,
api_key = Sys.getenv("NEWS_API_KEY"))
|
query |
Character string that contains the searchterm. |
category |
Character string with the category you want headlines from. |
country |
Character string with the country you want headlines from. |
sources |
Character vector with with IDs of the news outlets you want to focus on (e.g., c("usa-today", "spiegel-online")). |
page |
Specifies the page number of your results that is returned. Must
be numeric. Default is first page. If you want to get all results
at once, use |
page_size |
The number of articles per page that are returned. Maximum is 100 (also default). |
api_key |
Character string with the API key you get from newsapi.org.
Passing it is compulsory. Alternatively, a function can be
provided from the global environment (see |
List with two dataframes:
1) Data frame with results_df
2) Data frame with meta_data
1 2 3 4 5 6 | ## Not run:
df <- get_headlines(sources = "bbc-news")
df <- get_headlines(query = "sports", page = 2)
df <- get_headlines(category = "business")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.