Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Numinix MediaWiki Demo
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
API/Query
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Example 6: Generators === <!--T:35--> <!--T:60--> Use generators if you want to get data about a set of pages. <!--T:61--> For example, to get data about pages in a certain category, instead of querying <tvar name=1><code>list=categorymembers</code></tvar> and then querying again with <tvar name=2><code>pageids</code></tvar> set to all the returned pages, combine the two API calls into one by using <tvar name=3><code>generator=categorymembers</code></tvar>. <!--T:62--> When using a list module as a generator, you don't need to specify the pages. <!--T:63--> However, for a property module, you should [[<tvar name=1>#Specifying pages</tvar>|specify the pages]] which the generator will work on. <!--T:64--> For example, to load all pages that are linked to from the main page, use <tvar name=1><code>generator=links&titles=Main%20Page</code></tvar>. <!--T:68--> Parameters passed to a generator must be prefixed with a <code>g</code>. For instance, when using <code>generator=backlinks</code>, use <code>gbllimit</code> instead of <code>bllimit</code>. <!--T:69--> The sample query below gets links and categories for the first three pages in the main namespace starting with "Ba". </translate> <translate> ==== GET request ==== <!--T:36--> </translate> categories |p6=format=json |p7=formatversion=2 }} <translate> ==== Response ==== <!--T:37--> </translate> <syntaxhighlight lang="json"> { "continue": { "plcontinue": "14977970|0|Kirkwall_Ba_game", "continue": "||categories" }, "query": { "pages": [ { "pageid": 98178, "ns": 0, "title": "Ba", "links": [ { "ns": 0, "title": "BA" }, { "ns": 4, "title": "Wikipedia:Mainspace" }, { "ns": 4, "title": "Wikipedia:Naming conventions (capitalization)" }, { "ns": 4, "title": "Wikipedia:Protection policy" }, { "ns": 4, "title": "Wikipedia:Redirect" }, { "ns": 10, "title": "Template:R from miscapitalisation" }, { "ns": 10, "title": "Template:R from modification" }, { "ns": 10, "title": "Template:R to disambiguation page" }, { "ns": 14, "title": "Category:Redirects from ambiguous terms" }, { "ns": 14, "title": "Category:Redirects from other capitalisations" } ], "categories": [ { "ns": 14, "title": "Category:Redirects from ambiguous terms" }, { "ns": 14, "title": "Category:Redirects from other capitalisations" }, { "ns": 14, "title": "Category:Unprintworthy redirects" } ] }, { "pageid": 14977970, "ns": 0, "title": "Ba'" }, { "pageid": 33351890, "ns": 0, "title": "Ba'Al Shem Tov" } ] } } </syntaxhighlight> <translate>
Summary:
Please note that all contributions to Numinix MediaWiki Demo may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Project:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)