Retrieve the World Economic Forum's Agenda articles.
You can install the package with remotes
from Github, see changes.
# install.packages("remotes")
remotes::install_github("news-r/weforum") # github
library(weforum)
#> ℹ No API key is required.
# list endpoints
(endpoints <- wef_endpoints())
#> # A tibble: 15 x 2
#> name endpoints
#> <chr> <chr>
#> 1 articles_list https://api.weforum.org/v1/articles
#> 2 articles_channels https://api.weforum.org/v1/articles/channels
#> 3 articles_content_types https://api.weforum.org/v1/articles/content-types
#> 4 articles_origins https://api.weforum.org/v1/articles/origins
#> 5 collections_list https://api.weforum.org/v1/collections
#> 6 communities_list https://api.weforum.org/v1/communities
#> 7 events_list https://api.weforum.org/v1/events
#> 8 event_sessions_list https://api.weforum.org/v1/event_sessions
#> 9 pages_list https://api.weforum.org/v1/pages
#> 10 projects_list https://api.weforum.org/v1/projects
#> 11 reports_list https://api.weforum.org/v1/reports
#> 12 sf_accounts_list https://api.weforum.org/v1/sf_accounts
#> 13 topics_list https://api.weforum.org/v1/topics
#> 14 streams_list https://api.weforum.org/v1/streams
#> 15 updates_list https://api.weforum.org/v1/updates
The above returns basic endpoints, responses from the calls above will include other endpoints, weforum
lets you dynamically call those. Let’s demonstrate with an example.
# get some articles
articles <- wef_articles_list()
nrow(articles[[1]])
#> [1] 25
This returns a nested list, of 25 articles by default. As explained above it includes more endpoints.
attr <- articles[[1]]$attributes
names(attr)[grepl("endpoint", names(attr))]
#> [1] "api_endpoint" "api_toplink_endpoint" "website_endpoint"
You can call those endpoints with wef_call
.