View source: R/wiki-action-request.R
wiki_action_request | R Documentation |
Wikipedia exposes a To build up a query, you first call
wiki_action_request()
to create the basic request object, then use the
helper functions query_page_properties()
, query_list_pages()
and
query_generate_pages()
to modify the request, before calling next_batch()
or retrieve_all()
to perform the query and download results from the
server.
wiki_action_request(..., action = "query", language = "en")
... |
< |
action |
The action to perform, typically 'query' |
language |
The language edition of Wikipedia to request, e.g. 'en' or 'fr' |
wikkitidy provides an ergonomic API for the Action API's Query modules. These modules are most
useful for researchers, because they allow you to explore the structure of
Wikipedia and its back pages. You can obtain a list of available modules in
your R console using list_all_property_modules()
, list_all_list_modules()
and list_all_generators()
,
An action_api
object, an S3 list that subclasses httr2::request.
The dependencies between different aspects of the Action API are complex.
At the time of writing, there are five major subclasses of
action_api/httr2_request
:
generator/action_api/httr2_request
, returned (sometimes) by query_generate_pages
list/action_api/httr2_request
, returned by query_list_pages
titles
, pageids
and revids/action_api/httr2_request
, returned by the various query_by_ functions
You can use query_page_properties to modify any kind of query except
for list
queries: indeed, the central limitation of the list
queries is
that you cannot choose what properties to return for the pages the meet the
given criterion. The concept of a generator
is complex. If the
generator
is based on a
property module, then it
must be combined with a query_by_ function to produce a valid query. If
the generator is based on a list module, then it cannot be
combined with a query_by_ query.
gracefully()
# List the first 10 pages in the category 'Australian historians'
historians <- wiki_action_request() %>%
query_list_pages(
"categorymembers",
cmtitle = "Category:Australian_historians",
cmlimit = 10
) %>%
gracefully(next_batch)
historians
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.