Wikirandom API
Wikirandom provides a simple API that allows other Web Applications to obtain a list of random pages from Wikipedia through an HTTP Request. The freely available Wikirandom API builds over the MediaWiki API, and supports the JSON data format.
Request
- The request must be set to GET.
- No authentication is needed.
Methods
At this time the API provides two methods:
JSON
Returns a variable containing pairs of urls and titles of Wikipedia random pages.
URL: http://www.wikirandom.org/json
PARAMETERS:
- languages. Optional. If not set, defaults to 'en'. Specifies which language flavors of Wikipedia the random pages should be picked from. You can set multiple languages separating them with commas. Accepted values are: en (English), de (German), fr (French), pl (Polish), ja (Japanese), it (Italian), nl (Dutch), pt (Portuguese), es (Spanish), sv (Swedish), ru (Russian), zh (Chinese), no (Norwegian (Bokmål)), fi (Finnish), vo (Volapük), ca (Catalan), ro (Romanian), tr (Turkish). You can use the same value more than once to increase the likelihood of that language being picked.
- pages. Optional. If not set, defaults to 1. Specifies the number of random pages that should be fetched. Accepted values are 1 to 10.
- callback. Optional. If set, the returned code will be wrapped inside a function named after this value. This is useful to insert the data in a page directly through JavaScript. For an usage example, see the code in the 'Embed' box.
EXAMPLE:
- A request directed to this URL:
http://www.wikirandom.org/json?languages=en,en,it,es&pages=2
would return the following JSON object:
{ "status": true, "data": [ { "url": "http://en.wikipedia.org/wiki/RANDOM_PAGE_1", "title": "RANDOM_TITLE_1" }, { "url": "http://en.wikipedia.org/wiki/RANDOM_PAGE_2", "title": "RANDOM_TITLE_2" } ] }.
The pages fetched would be 50% of the times in English, 25% in Italian, and 25% in Spanish.
COUNT
Returns the count of random pages fetched by Wikirandom, both on site and through the API.
URL: http://www.wikirandom.org/json/count
PARAMETERS:
- callback. Optional. If set, the returned code will be wrapped inside a function named after this value. This is useful to insert the data in a page directly through JavaScript. For an usage example, see the code in the 'Embed' box.
EXAMPLE:
- A request directed to this URL:
http://www.wikirandom.org/json/count
would return the following:
{ "internal": TOTAL_RANDOM_PAGES_FETCHED_ON_SITE, "api": TOTAL_RANDOM_PAGES_FETCHED_BY_API }
Facebook
MySpace
Twitter
Digg
StumbleUpon
Reddit
Newsvine
Delicious
Magnolia
Google
Yahoo