API:Random
Jump to navigation
Jump to search
| This page is part of the MediaWiki action API documentation. |
MediaWiki action API
- Introduction and quick start
- FAQ
- Formats
- Error reporting
- Restricting usage
- Cross-site requests
- Authentication
- Queries
- Searching (by title, content, coordinates...)
- Parsing wikitext and expanding templates
- Purging pages' caches
- Parameter information
- Changing wiki content
- Create and edit pages
- Move pages
- Merge pages
- Rollback
- Delete pages
- Restore deleted revisions
- (Un)protect pages
- (Un)block users
- (Un)watch pages
- Mark revisions of watched pages as visited
- Send email
- Patrol changes
- Import pages
- Change user group membership
- Upload files
- User options
- Tokens
- Page language
- More...
- Watchlist feed
- Wikidata
- Extensions
- Using the API in MediaWiki and extensions
- Miscellaneous
- Implementation
- Client code
- Asserting
| Random | ||
|---|---|---|
This module can be used as a Generator. |
||
| Prefix | rn | |
| Required rights | none | |
| Post only? | No | |
| Generated help | Current | |
| Version added |
|
|
Get a list of random pages.
Pages are listed in a fixed sequence, only the starting point is random. This means that if, for example, "Main Page" is the first random page on your list, "List of fictional monkeys" will always be second, "List of people on stamps of Vanuatu" third, etc.
If the number of pages in the namespace is lower than rnlimit, you will get fewer pages.
You will not get the same page twice.
Parameters[edit]
rnlimit: Limit how many random pages will be returned. No more than 10 (20 for bots) allowed. (Default: 1)rnnamespace: Only list pages in these namespaces. (Default: all namespaces)rnredirect: Load a random redirect instead of a random page. (Default: false) 1.14+ (Deprecated in 1.26)rnfilterredir: How to filter for redirects. Possible values:all,redirects,nonredirects. (Default:nonredirects) 1.26+
Example[edit]
Get 5 random pages
| Result |
|---|
<?xml version="1.0" encoding="utf-8"?>
<api batchcomplete="">
<continue rncontinue="0.480311742596|0.480311970289|19545028|0" continue="-||" />
<query>
<random>
<page id="26932925" ns="2" title="User:Caselogistix/monobook.js" />
<page id="3322513" ns="3" title="User talk:69.4.146.113" />
<page id="34711504" ns="3" title="User talk:109.152.196.220" />
<page id="19612336" ns="3" title="User talk:71.142.128.20" />
<page id="26149148" ns="6" title="File:Native Sons of the Golden West logo.jpg" />
</random>
</query>
</api>
|
Possible errors[edit]
None