Skip to contents

Many of the endpoints on the Action API can be used as generators. Use list_all_generators() to see a complete list. The main advantage of using a generator is that you can chain it with calls to query_page_properties() to find out specific information about the pages. This is not possible for queries constructed using query_list_pages().

Usage

query_generate_pages(.req, generator, ...)

list_all_generators()

Arguments

.req

A httr2_request, e.g. generated by wiki_action_request

generator

The generator module you wish to use. Most list and property modules can be used, though not all.

...

<dynamic-dots> Additional parameters to the generator

Value

query_generate_pages: The modified request, which can be passed to next_batch or retrieve_all as appropriate.

list_all_generators: a tibble of all the available generator modules. The name column gives the name of the generator, while the group column indicates whether the generator is based on a list module or a property module. Generators based on property modules can only be added to a query if you have already used query_by_ to specify which pages' properties should be generated.

Details

There are two kinds of generator: list-generators and prop-generators. If using a prop-generator, then you need to use a query_by_() function to tell the API where to start from, as shown in the examples.

To set additional parameters to a generator, prepend the parameter with "g". For instance, to set a limit of 10 to the number of pages returned by the categorymembers generator, set the parameter gcmlimit = 10.

See also

Examples

# Search for articles about seagulls
seagulls <- wiki_action_request() %>%
  query_generate_pages("search", gsrsearch = "seagull") %>%
  gracefully(next_batch)

seagulls
#> <complete/query_tbl>
#>  There are more results on the server. Retrieve them with `next_batch()` or `retrieve_all()`
#>  Data complete for all records
#> # A tibble: 10 × 4
#>      pageid    ns title                       index
#>       <int> <int> <chr>                       <int>
#>  1    45232     0 Jonathan Livingston Seagull     3
#>  2   210481     0 Gull                            1
#>  3   210492     0 Seagull (disambiguation)        5
#>  4   474370     0 The Seagull                     2
#>  5   887152     0 Barbara Hershey                 9
#>  6  2305766     0 British Seagull                10
#>  7  6386157     0 Seagull management              6
#>  8 12811837     0 Seagull Camera                  7
#>  9 22496419     0 HMS Seagull                     8
#> 10 73546753     0 BYD Seagull                     4