Create Bots to Automate Tasks in MediaWiki
MediaWiki is the underlying code that gives Wikipedia the look and feel we are all familiar with. It is freely available so that anyone can use it to create their own wiki. In a previous article I covered how to set up your own Wiki using the MediaWiki code on Microsoft Azure. Run A Small/Medium Sized Wikipedia Clone on Microsoft Azure
Once you have your own wiki up and running it may seem like a daunting task to fill it in and maintain it. Fortunately, the MediaWiki code has some very helpful features that we can use to automate many day to day tasks. Specifically, Bot accounts and an Application Interface (API).
Bot accounts are a special subset of user accounts that are able to send requests to the wiki Application Interface. Bots must be tied to a user account and will only have the same level of access as the user who creates them. When creating them it is possible to restrict them further. Giving them the least amount of access they need to perform their tasks is best practice to minimize errors.
How do you create a bot?
To create a bot account you first need to navigate to the Special Pages of the wiki. There is a link on the left hand side of the screen that will take you to a list of pages that are designed to help you perform common tasks.
Under Users and Rights there is a link to Bot Passwords.
Once you click on this link you will be taken to a page where you can see any bots you have already created and a prompt to enter a name for creating a new bot account.
After you enter the name for you new bot you will be taken to a page where it will show you the user account it is being linked to, and you will be asked to select what permissions you want to grant to this bot.
At the bottom of this page you will be able to restrict the IP addresses that are able to log in with this bot account. You can specify a single IP as well as ranges.
Once you click create an account username and password will be generated. These are the credentials you can use when making calls to the API.
What kinds of things can a bot account do?
Now that you have a Bot account you can write code to login to the wiki and perform tasks accessible to the API. The MediaWiki API Reference is a good source for learning what the API is capable of. A few of the best places to start are.