Code snippets in Python demonstrating how to use various modules of the MediaWiki Action API
- API:Tokens
- tokens.py: get tokens for data modifying operations
- API:Login
- login.py & clientlogin.py: login
- API:Logout
- logout.py: logout
- API:Account creation
- create_account.py: create an account on a wiki without any special authentication extensions
- create_account_with_captcha.py: create an account on a wiki with a captcha enabling extension installed
- API:Users
- get_users.py: get information about a list of users
- API:User contributions
- get_usercontribs.py: list user contributions
- API:User group membership
- userrights.py: add and remove user rights
- API:Watchlist feed
- get_my_watchlist_feed: access an RSS feed of your own watchlist
- get_user_watchlist_feed: access an RSS feed of another user's watchlist
- get_my_watchlist_feed: access an RSS feed of your own watchlist
- API:Parse
- parse.py: parse content of a page
- parse_wikitable.py: parse a section of its page and fetch its table data
- API:Categorymembers
- get_category_items.py: list twenty items in a category
- get_recent_category_items.py: get the ten articles most recently added to a category
- get_subcategories.py: get ten subcategories of a category
- API:Images
- get_page_images.py: get page images embedded on a page
- API:Purge
- purge_two_pages.py: purge cache of two or more pages
- purge_namespace_pages.py: purge cache of the first 10 pages in the main namespace
- API:Redirects
- redirects.py: return redirects to the given page(s)
- API:Delete
- delete.py: delete a page
- API:Revisions
- get_pages_revisions.py: get revision data of multiple pages
- get_filtered_page_revisions.py: get revision data of a page filtered by date and user
- API:Links
- get_links.py: get links embedded on a page
- get_red_links.py: get the first twenty red links in a page
- API:Info
- get_info.py: get basic information about a page
- API:Allpages
- get_allpages.py: get all pages which fit a certain criteria, within a namespace
- API:Edit
- edit.py: edit a page
- API:Allimages
- get_allimages_by_date.py: list all images in a namespace, starting from a certain timestamp
- get_allimages_by_name.py: list all images in a namespace, starting from a certain filename
- API:Imageinfo
- get_imageinfo.py get information about an image file
- API:Categories
- get_categories.py: get categories associated with a page
- API:Allcategories
- get_allcategories.py: get all categories that fit certain criteria relating to their titles
- API:Allusers
- get_allusers.py: get a list of all registered users, as ordered by username
- get_allcategories.py: get all categories that fit certain criteria relating to their titles
- API:Backlinks
- get_backlinks.py: list pages which link to a certain page
- API:Random
- get_random.py: get a list of random pages
- API:Move
- move.py: move a page
- API:Watch
- watch.py: add a page to your watchlist
- API:Alllinks
- get_alllinks.py: list links to a namespace
- API:Search
- search.py: search for a title or a text
- API:Geosearch
- geosearch.py: search for pages nearby
- geoimagesearch.py: search for pages nearby with images
- geocoordinates.py: obtain coordinates for wiki pages nearby
- API:Opensearch
- opensearch.py: fetch results in an opensearch format
- API:Prefixsearch
- prefixsearch.py: perform a prefix search for page titles
- API:Languagesearch
- languagesearch.py: search for a language
- API:Parameter information
- paraminfo.py: get information about another action API module and its parameters
- Article suggestion: A sample app that uses MediaWiki Action API:Search allows you to pick a category and suggest articles to write on that don't yet exist on English Wikipedia. This app uses Flask and WTForms for rendering form.
- Nearby places viewer: Demo of geo search for wiki pages near a location using the Geolocation API and MediaWiki Action API's Geosearch module.
- Picture of the day viewer: Demo app that uses prop=images module to fetch Wikipedia's Picture of the Day (POTD) from a template page and displays it on a webpage. The app also allows users to go backward or forward a date to view other POTD.
$ git clone https://github.com/srish/MediaWiki_Action_API_Code_Samples
$ cd MediaWiki-Action-API-Code-Samples
Install the necessary python modules with pip
$ python3 name_of_the_file.py #Enter any credentials if required in the file
First, propose an idea for a code sample, demo app, etc. by creating an issue around it in the repository. After discussing your idea with the repo contributors, start working, and then send a pull request, when you've your changes ready to be accepted/ merged! You can autogenerate python files for GET Requests demos where feasible by following the instructions below:
$ cd MediaWiki-Action-API-Code-Samples
$ Add module information to `modules.json`
$ cd python
$ python autogenerator.py
$ Make desired changes to the newly generated file(s)