How to Use the MediaWiki API

Read the MediaWiki API documentation., Select an output format., Choose an action., Select a query or a list., Pass the posted data to the API through the use of CURL or another tool that allows you to use the POST method to the script., Make sure...

9 Steps 2 min read Medium

Step-by-Step Guide

  1. Step 1: Read the MediaWiki API documentation.

    It is located at 'api.php' in the same directory as the usual index.php.

    Example: https://www.LifeGuide Hub.com/api.php. , The MediaWiki offers data output in the form of JSON, JSONFM, PHP (serialized format), PHPFM, WDDX, WDDXFM, XML, XMLFM, YAML, YAMLFM, and RAWFM.

    The formats suffixed "FM" are pretty-print in HTML. , The MediaWiki API supports the following actions: help
    - See the help screen login
    - Login to MediaWiki opensearch
    - Implement the opensearch protocol. (Not all MediaWiki installations have this). feedwatchlist
    - Return a watchlist feed. query
    - Has a variety of options.

    See the MediaWiki API documentation for them. , Besides the standard actions, MediaWiki supports different queries and lists, such as listing pages that contain a link to another article, number of recent changes diffs, contributions, etc. , The GET method may also work. ,, The edit token is used to determine edit collisions and avoid overriding another edit already done (This is used in rollback as well.).

    Keep in mind it is easier for things to go awry if you are acting with the user interface of the wiki.

    Be mindful of any regexes you use to make sure that they will only do the intended result. , The results will be sent to you in an HTTP response, which can be read by many parsers.

    Take extra care of the format you choose.

    Make sure you use the appropriate parser for that format.

    It is usually a good practice to explicitly state the format to MediaWiki even if it has a default format that you want to use.
  2. Step 2: Select an output format.

  3. Step 3: Choose an action.

  4. Step 4: Select a query or a list.

  5. Step 5: Pass the posted data to the API through the use of CURL or another tool that allows you to use the POST method to the script.

  6. Step 6: Make sure to keep cookies sent to an application (Some scripts/applications may wish to store it in a subfolder.

  7. Step 7: When interacting with the MediaWiki user interface

  8. Step 8: mind your edit token kept in most edit pages.

  9. Step 9: Read the results sent by the wiki.

Detailed Guide

It is located at 'api.php' in the same directory as the usual index.php.

Example: https://www.LifeGuide Hub.com/api.php. , The MediaWiki offers data output in the form of JSON, JSONFM, PHP (serialized format), PHPFM, WDDX, WDDXFM, XML, XMLFM, YAML, YAMLFM, and RAWFM.

The formats suffixed "FM" are pretty-print in HTML. , The MediaWiki API supports the following actions: help
- See the help screen login
- Login to MediaWiki opensearch
- Implement the opensearch protocol. (Not all MediaWiki installations have this). feedwatchlist
- Return a watchlist feed. query
- Has a variety of options.

See the MediaWiki API documentation for them. , Besides the standard actions, MediaWiki supports different queries and lists, such as listing pages that contain a link to another article, number of recent changes diffs, contributions, etc. , The GET method may also work. ,, The edit token is used to determine edit collisions and avoid overriding another edit already done (This is used in rollback as well.).

Keep in mind it is easier for things to go awry if you are acting with the user interface of the wiki.

Be mindful of any regexes you use to make sure that they will only do the intended result. , The results will be sent to you in an HTTP response, which can be read by many parsers.

Take extra care of the format you choose.

Make sure you use the appropriate parser for that format.

It is usually a good practice to explicitly state the format to MediaWiki even if it has a default format that you want to use.

About the Author

K

Kimberly Davis

Specializes in breaking down complex hobbies topics into simple steps.

41 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: