Code snippets in MediaWiki native Javascript demonstrating how to use various modules of the MediaWiki Action API. These code snippets are vaild within MediaWiki Sites. And works in MediaWiki Javascript wikipages like MediaWiki:Common.js, User:ABC/common.js and User:ABC/global.js
These code snippets are usefull to create Userscripts and Gadgets.
- API:Tokens
- tokens.js: get tokens for data modifying operations
- API:Logout
- logout.js: logout
- API:Login
- login.js: Sending request to login
- API:User contributions
- get_usercontribs.js: list user contributions
- API:Watchlist
- get_watchlist.js: get the currently logged-in user's watchlist
- API:Block
- block_user.js: block a user
- API:Options
- change_user_options.js: change three options for current user
- API:Blocks
- get_blocker_user.js: get request to list recent blocked users
- API:Users
- get_users.js: get information about several users: [[1.2.3.4]], [[Catrope]], [[Vandal01]], and [[Bob]]
- API:Emailuser
- send_email.js: post request to send email to wiki user
- API:Userrights
- userrights.js: add and remove user rights by changing the user's group membership
- API:Rsd
- rsd.js: export an RSD schema
- API:Validatepassword
- validatepassword.js: validate a password against the wiki's password policies
- API:Resetpassword
- reset_password.py: Reset password for all users with an email address.
- API:Feedcontributions
- get_user_contributions_feed.js: Show contributions of a user as an RSS feed.
- API:Userinfo
- userinfo.js: get general user info and user rights
- API:Parse
- parse.js: parse content of a page
- API:Categorymembers
- get_category_items.js: list twenty items in a category
- get_recent_category_items.js: get the ten articles most recently added to a category
- get_subcategories.js: get ten subcategories of a category
- API:Images
- get_page_images.js: get page images embedded on a page
- API:Redirects
- get_redirects.js: return redirects to the given page(s)
- API:Deletedrevs
- get_deleted_revisions.js: list deleted revisions from a user
- API:Deletedrevisions
- get_deleted_revs.js: list deleted revisions for a page
- API:Revisions
- get_pages_revisions.js: get revision data of multiple pages
- get_filtered_page_revisions.js: get revision data of a page filtered by date and user
- API:Alldeletedrevisions
- get_alldeletedrevs.js: get all deleted revision data by a user or in a namespace.
- API:Links
- get_links.js: get links embedded on a page
- get_red_links.js: get the first twenty red links in a page
- API:Info
- get_info.js: get basic information about a page
- API:Allpages
- get_allpages.js: get all pages which fit a certain criteria, within a namespace
- API:Edit
- edit.js: edit a page
- API:Allimages
- get_allimages_by_date.js: list all images in a namespace, starting from a certain timestamp
- get_allimages_by_name.js: list all images in a namespace, starting from a certain filename
- API:Imageinfo
- get_imageinfo.js get information about an image file
- API:Categories
- get_categories.js: get categories associated with a page
- API:Allcategories
- get_allcategories.js: get all categories that fit certain criteria relating to their titles
- API:Allusers
- get_allusers.js: get a list of all registered users, as ordered by username
- get_allcategories.js: get all categories that fit certain criteria relating to their titles
- API:Backlinks
- get_backlinks.js: list pages which link to a certain page
- API:Random
- get_random.js: get a list of random pages
- API:Alllinks
- get_alllinks.js: list links to a namespace
- API:Embeddedin
- get_embedded_pages.js: get all page(s) that embed a page
- API:Contributors
- get_contributors.js: get request to list all logged-in contributors and count of anonymous contributors to a page
- API:Delete
- delete.js: delete a page
- API:Fileusage
- get_allfileusage.js: list all file usages, including non-existing
- API:Allredirects
- get_allredirects.js: get the first three unique pages containing redirects to the main namespace
- API:Allrevisions
- get_allrevisions.js: get revision data of multiple pages and users
- API:Alltransclusions
- get_alltransclusions.js: get three unique pages in the main namespace which contain transclusions
- API:Categoryinfo
- get_category_info.js: get information about a few categories
- API:Exturlusage
- get_exturlusage.js: enumerate pages that contain a given URL
- API:Imageusage
- get_imageusage.js: list the first 3 pages that use a given image title
- API:Iwlinks
- get_iwlinks.js: get the interwiki links from a given page
- API:Logevents
- get_logevents.js: get the three most recent logevents
- API:Pagepropnames
- get_pagepropnames.js: list page property names on the given wiki
- API:Protectedtitles
- get_protectedtitles.js: get the first 2 titles which only sysops can create
- API:Querypage
- get_querypage_list.js: list first 10 pages which are uncategorized
- API:RecentChanges
- get_recent_changes.js: get the three most recent changes with sizes and flags
- API:Tags
- get_tags.js: get the first three change tags and their hitcounts
- API:Watchlistraw
- get_watchlistraw.js: get three pages on the logged-in user's watchlist from the main namespace.
- API:Import
- import_interwiki.js: import a page from another wiki by specifying its title
- API:Move
- move.js: Move a page with its talk page, leaving a redirect behind
- API:Patrol
- patrol.js: Patrol a recent change
- API:Protect
- protect.js: demo to change the edit protection
- API:Purge
- purge_namespace_pages.js: post request to purge first 10 pages in the main namespace
- purge_two_pages.js: post request to purge two or more pages
- API:Rollback
- rollback.js: post request to rollback the last edits made to a given page
- API:SetPageLanguage
- set_page_language.js: post request to change the language of a page
- API:Undelete
- undelete.js: restore two revisions of a deleted page
- API:Upload
- upload_file_directly.js: post request to upload a file directly
- upload_file_from_url.js: post request to upload a file from a URL
- upload_file_in_chunks.js: step-by-step process to upload a file in chunks
- API:Watch
- watch.js: add a page to your watchlist
- API:Filearchive
- filearchive.js: Enumerate all deleted files from filearchive table sequentially
- API:Siteinfo
- general_site_info.js: obtain general site info
- API:Expandtemplates
- expand_templates.js: expand the Project:Sandbox template
- API:ClearHasMsg
- clear_has_msg.js: clear the hasmsg flag for the current user
- API:Compare
- compare.js: Compare the current revisions of two different pages
- API:Tag
- tag.js: Remove the spam tag from log entry ID 123 with the reason Wrongly applied
- API:Duplicatefiles
- duplicate_files.js: list duplicates of the given files
- API:Filerepoinfo
- file_repo_info.js: get information about file repositories
- API:Iwbacklinks
- iwbacklinks.js: Get pages that link to a given interwiki link.
- API:Checktoken
- check_token.js: Check a CSRF token
- API:Deletedrevisions
- deleted_revisions.js: Get a list of deleted revisions for Talk:Main Page.
- API:Revisiondelete
- revision_delete.js: Hide all information about a certain revision ID.
- API:Filearchive
- file_archive.js: Get a list of all deleted files.
- API:Fileusage
- get_file_usage.js: Get a list of pages using a given file.
- API:Feedrecentchanges
- get_feed_recent_changes.js: Show recent changes as an RSS feed.
- API:Setnotificationtimestamp
- set_notification_timestamp.js: Reset the notification status for the entire watchlist.
- API:Langbacklinks
- langbacklinks.js: get pages linking to a given language link
- API:Templates
- templates.js: get a list of templates used on a page
- API:Pageprops
- pageprops.js: get various properties defined in the page content
- API:Extlinks
- get_extlinks.js: get a list of external links on a page
- API:Allmessages
- all_messages.js: get the Dutch translations of some messages
- API:Transcludedin
- get_transcluded_in.js: get a list of pages which transclude a given page
- API:Langlinks
- langlinks.js: get a list of language links that a given page has
- API:Stashimageinfo
- stash_image_info.js: return information for a stashed file
- API:Search
- search.js: search for a title or a text
- API:Geosearch
- geosearch.js: search for pages nearby
- geoimagesearch.js: search for pages nearby with images
- geocoordinates.js: obtain coordinates for wiki pages nearby
- API:Opensearch
- opensearch.js: fetch results in an opensearch format
- API:Prefixsearch
- prefixsearch.js: perform a prefix search for page titles
- API:Languagesearch
- languagesearch.js: search for a language
- API:Pageswithprop
- get_pageswithprop.js: list all pages using a given page property
- API:Parameter information
- paraminfo.js: get information about another action API module and its parameters
- API:Main_module
- main_module.js: Get help for the main module.
- API:Help
- get_help.js: Get help for a specified module.