Class: MediaWiktory::Wikipedia::Actions::Query

Inherits:
Get
  • Object
show all
Defined in:
lib/mediawiktory/wikipedia/actions/query.rb

Overview

Fetch data from and about MediaWiki.

Usage:

api.query.prop(value).perform # returns string with raw output
# or
api.query.prop(value).response # returns output parsed and wrapped into Response object

See Base for generic explanation of working with MediaWiki actions and Response for working with action responses.

All action's parameters are documented as its public methods, see below.

Instance Method Summary collapse

Methods inherited from Get

#perform

Methods inherited from Base

#inspect, #merge, #name, #perform, #response, #to_h, #to_param, #to_url

Methods included from GlobalParams

#assert, #assertuser, #centralauthtoken, #curtimestamp, #errorformat, #errorlang, #errorsuselocal, #format, #maxage, #maxlag, #origin, #requestid, #responselanginfo, #servedby, #smaxage, #uselang

Instance Method Details

#continue(value) ⇒ self

When more results are available, use this to continue.

Parameters:

  • value (String)

Returns:

  • (self)


203
204
205
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 203

def continue(value)
  merge(continue: value.to_s)
end

#converttitlesself

Convert titles to other variants if necessary. Only works if the wiki's content language supports variant conversion. Languages that support variant conversion include gan, iu, kk, ku, shi, sr, tg, uz and zh.

Returns:

  • (self)


320
321
322
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 320

def converttitles()
  merge(converttitles: 'true')
end

#exportself

Export the current revisions of all given or generated pages.

Returns:

  • (self)


181
182
183
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 181

def export()
  merge(export: 'true')
end

#exportnowrapself

Return the export XML without wrapping it in an XML result (same format as Special:Export). Can only be used with export.

Returns:

  • (self)


188
189
190
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 188

def exportnowrap()
  merge(exportnowrap: 'true')
end

#generator(value) ⇒ self

Get the list of pages to work on by executing the specified query module.

Parameters:

  • value (Symbol)

    Selecting an option includes tweaking methods from corresponding module:

    • :allcategories - Modules::GAllcategories Enumerate all categories. Generator module: for fetching pages corresponding to request.
    • :alldeletedrevisions - Modules::GAlldeletedrevisions List all deleted revisions by a user or in a namespace. Generator module: for fetching pages corresponding to request.
    • :allfileusages - Modules::GAllfileusages List all file usages, including non-existing. Generator module: for fetching pages corresponding to request.
    • :allimages - Modules::GAllimages Enumerate all images sequentially. Generator module: for fetching pages corresponding to request.
    • :alllinks - Modules::GAlllinks Enumerate all links that point to a given namespace. Generator module: for fetching pages corresponding to request.
    • :allpages - Modules::GAllpages Enumerate all pages sequentially in a given namespace. Generator module: for fetching pages corresponding to request.
    • :allredirects - Modules::GAllredirects List all redirects to a namespace. Generator module: for fetching pages corresponding to request.
    • :allrevisions - Modules::GAllrevisions List all revisions. Generator module: for fetching pages corresponding to request.
    • :alltransclusions - Modules::GAlltransclusions List all transclusions (pages embedded using {x}), including non-existing. Generator module: for fetching pages corresponding to request.
    • :backlinks - Modules::GBacklinks Find all pages that link to the given page. Generator module: for fetching pages corresponding to request.
    • :categories - Modules::GCategories List all categories the pages belong to. Generator module: for fetching pages corresponding to request.
    • :categorymembers - Modules::GCategorymembers List all pages in a given category. Generator module: for fetching pages corresponding to request.
    • :contenttranslation - Modules::GContenttranslation Query Content Translation database for translations. Generator module: for fetching pages corresponding to request.
    • :contenttranslationsuggestions - Modules::GContenttranslationsuggestions Get suggestion lists for Content Translation. Generator module: for fetching pages corresponding to request.
    • :deletedrevisions - Modules::GDeletedrevisions Get deleted revision information. Generator module: for fetching pages corresponding to request.
    • :duplicatefiles - Modules::GDuplicatefiles List all files that are duplicates of the given files based on hash values. Generator module: for fetching pages corresponding to request.
    • :embeddedin - Modules::GEmbeddedin Find all pages that embed (transclude) the given title. Generator module: for fetching pages corresponding to request.
    • :exturlusage - Modules::GExturlusage Enumerate pages that contain a given URL. Generator module: for fetching pages corresponding to request.
    • :fileusage - Modules::GFileusage Find all pages that use the given files. Generator module: for fetching pages corresponding to request.
    • :geosearch - Modules::GGeosearch Returns pages having coordinates that are located in a certain area. Generator module: for fetching pages corresponding to request.
    • :gettingstartedgetpages - Modules::GGettingstartedgetpages This API is for getting a list of one or more pages related to a particular GettingStarted task. Generator module: for fetching pages corresponding to request.
    • :images - Modules::GImages Returns all files contained on the given pages. Generator module: for fetching pages corresponding to request.
    • :imageusage - Modules::GImageusage Find all pages that use the given image title. Generator module: for fetching pages corresponding to request.
    • :iwbacklinks - Modules::GIwbacklinks Find all pages that link to the given interwiki link. Generator module: for fetching pages corresponding to request.
    • :langbacklinks - Modules::GLangbacklinks Find all pages that link to the given language link. Generator module: for fetching pages corresponding to request.
    • :links - Modules::GLinks Returns all links from the given pages. Generator module: for fetching pages corresponding to request.
    • :linkshere - Modules::GLinkshere Find all pages that link to the given pages. Generator module: for fetching pages corresponding to request.
    • :mostviewed - Modules::GMostviewed Lists the most viewed pages (based on last day's pageview count). Generator module: for fetching pages corresponding to request.
    • :oldreviewedpages - Modules::GOldreviewedpages Enumerates pages that have changes pending review. Generator module: for fetching pages corresponding to request.
    • :pageswithprop - Modules::GPageswithprop List all pages using a given page property. Generator module: for fetching pages corresponding to request.
    • :prefixsearch - Modules::GPrefixsearch Perform a prefix search for page titles. Generator module: for fetching pages corresponding to request.
    • :projectpages - Modules::GProjectpages List all pages associated with one or more projects. Generator module: for fetching pages corresponding to request.
    • :protectedtitles - Modules::GProtectedtitles List all titles protected from creation. Generator module: for fetching pages corresponding to request.
    • :querypage - Modules::GQuerypage Get a list provided by a QueryPage-based special page. Generator module: for fetching pages corresponding to request.
    • :random - Modules::GRandom Get a set of random pages. Generator module: for fetching pages corresponding to request.
    • :recentchanges - Modules::GRecentchanges Enumerate recent changes. Generator module: for fetching pages corresponding to request.
    • :redirects - Modules::GRedirects Returns all redirects to the given pages. Generator module: for fetching pages corresponding to request.
    • :revisions - Modules::GRevisions Get revision information. Generator module: for fetching pages corresponding to request.
    • :search - Modules::GSearch Perform a full text search. Generator module: for fetching pages corresponding to request.
    • :templates - Modules::GTemplates Returns all pages transcluded on the given pages. Generator module: for fetching pages corresponding to request.
    • :transcludedin - Modules::GTranscludedin Find all pages that transclude the given pages. Generator module: for fetching pages corresponding to request.
    • :watchlist - Modules::GWatchlist Get recent changes to pages in the current user's watchlist. Generator module: for fetching pages corresponding to request.
    • :watchlistraw - Modules::GWatchlistraw Get all pages on the current user's watchlist. Generator module: for fetching pages corresponding to request.
    • :wblistentityusage - Modules::GWblistentityusage Returns all pages that use the given entity IDs. Generator module: for fetching pages corresponding to request.

Returns:

  • (self)


301
302
303
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 301

def generator(value)
  _generator(value) or fail ArgumentError, "Unknown value for generator: #{value}"
end

#indexpageidsself

Include an additional pageids section listing all returned page IDs.

Returns:

  • (self)


174
175
176
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 174

def indexpageids()
  merge(indexpageids: 'true')
end

#iwurlself

Whether to get the full URL if the title is an interwiki link.

Returns:

  • (self)


195
196
197
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 195

def iwurl()
  merge(iwurl: 'true')
end

#list(*values) ⇒ self

Which lists to get.

Parameters:

Returns:

  • (self)


134
135
136
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 134

def list(*values)
  values.inject(self) { |res, val| res._list(val) or fail ArgumentError, "Unknown value for list: #{val}" }
end

#meta(*values) ⇒ self

Which metadata to get.

Parameters:

  • values (Array<Symbol>)

    All selected options include tweaking methods from corresponding modules:

Returns:

  • (self)


162
163
164
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 162

def meta(*values)
  values.inject(self) { |res, val| res._meta(val) or fail ArgumentError, "Unknown value for meta: #{val}" }
end

#pageids(*values) ⇒ self

A list of page IDs to work on.

Parameters:

  • values (Array<Integer>)

Returns:

  • (self)


231
232
233
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 231

def pageids(*values)
  values.inject(self) { |res, val| res._pageids(val) }
end

#prop(*values) ⇒ self

Which properties to get for the queried pages.

Parameters:

  • values (Array<Symbol>)

    All selected options include tweaking methods from corresponding modules:

    • :categories - Modules::Categories List all categories the pages belong to.
    • :categoryinfo - Modules::Categoryinfo Returns information about the given categories.
    • :contributors - Modules::Contributors Get the list of logged-in contributors and the count of anonymous contributors to a page.
    • :coordinates - Modules::Coordinates Returns coordinates of the given pages.
    • :deletedrevisions - Modules::Deletedrevisions Get deleted revision information.
    • :duplicatefiles - Modules::Duplicatefiles List all files that are duplicates of the given files based on hash values.
    • :extlinks - Modules::Extlinks Returns all external URLs (not interwikis) from the given pages.
    • :extracts - Modules::Extracts Returns plain-text or limited HTML extracts of the given pages.
    • :fileusage - Modules::Fileusage Find all pages that use the given files.
    • :flagged - Modules::Flagged Get information about the flagging status of the given pages.
    • :globalusage - Modules::Globalusage Returns global image usage for a certain image.
    • :imageinfo - Modules::Imageinfo Returns file information and upload history.
    • :images - Modules::Images Returns all files contained on the given pages.
    • :info - Modules::Info Get basic page information.
    • :iwlinks - Modules::Iwlinks Returns all interwiki links from the given pages.
    • :langlinks - Modules::Langlinks Returns all interlanguage links from the given pages.
    • :links - Modules::Links Returns all links from the given pages.
    • :linkshere - Modules::Linkshere Find all pages that link to the given pages.
    • :mapdata - Modules::Mapdata Request all map data from the page Metallica
    • :pageassessments - Modules::Pageassessments Return associated projects and assessments for the given pages.
    • :pageimages - Modules::Pageimages Returns information about images on the page, such as thumbnail and presence of photos.
    • :pageprops - Modules::Pageprops Get various page properties defined in the page content.
    • :pageterms - Modules::Pageterms Get terms associated with a page via an associated data item. On a wikibase entity page, the entity terms are used directly. Caveat: On a repo wiki, pageterms only works directly on entity pages, not on pages connected to an item. This may change in the future.
    • :pageviews - Modules::Pageviews Shows per-page pageview data (the number of daily pageviews for each of the last pvipdays days). The result format is page title (with underscores) => date (Ymd) => count.
    • :redirects - Modules::Redirects Returns all redirects to the given pages.
    • :references - Modules::References Return a data representation of references associated with the given pages.
    • :revisions - Modules::Revisions Get revision information.
    • :stashimageinfo - Modules::Stashimageinfo Returns file information for stashed files.
    • :templates - Modules::Templates Returns all pages transcluded on the given pages.
    • :transcludedin - Modules::Transcludedin Find all pages that transclude the given pages.
    • :transcodestatus - Modules::Transcodestatus Get transcode status for a given file page.
    • :videoinfo - Modules::Videoinfo Extends imageinfo to include video source (derivatives) information
    • :wbentityusage - Modules::Wbentityusage Returns all entity IDs used in the given pages.

Returns:

  • (self)


59
60
61
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 59

def prop(*values)
  values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" }
end

#rawcontinueself

Return raw query-continue data for continuation.

Returns:

  • (self)


210
211
212
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 210

def rawcontinue()
  merge(rawcontinue: 'true')
end

#redirectsself

Automatically resolve redirects in titles, pageids, and revids, and in pages returned by generator.

Returns:

  • (self)


313
314
315
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 313

def redirects()
  merge(redirects: 'true')
end

#revids(*values) ⇒ self

A list of revision IDs to work on.

Parameters:

  • values (Array<Integer>)

Returns:

  • (self)


244
245
246
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 244

def revids(*values)
  values.inject(self) { |res, val| res._revids(val) }
end

#titles(*values) ⇒ self

A list of titles to work on.

Parameters:

  • values (Array<String>)

Returns:

  • (self)


218
219
220
# File 'lib/mediawiktory/wikipedia/actions/query.rb', line 218

def titles(*values)
  values.inject(self) { |res, val| res._titles(val) }
end