CINXE.COM
Manual:Creating a bot - MediaWiki
<!DOCTYPE html> <html class="client-nojs vector-feature-language-in-header-disabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref--excluded vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-disabled skin-theme-clientpref-day vector-toc-available" lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <title>Manual:Creating a bot - MediaWiki</title> <script>(function(){var className="client-js vector-feature-language-in-header-disabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref--excluded vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-disabled skin-theme-clientpref-day vector-toc-available";var cookie=document.cookie.match(/(?:^|; )mediawikiwikimwclientpreferences=([^;]+)/);if(cookie){cookie[1].split('%2C').forEach(function(pref){className=className.replace(new RegExp('(^| )'+pref.replace(/-clientpref-\w+$|[^\w-]+/g,'')+'-clientpref-\\w+( |$)'),'$1'+pref+'$2');});}document.documentElement.className=className;}());RLCONF={"wgBreakFrames":false,"wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""], "wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgRequestId":"be7a87e7-f3a4-4095-922d-85a161479b3a","wgCanonicalNamespace":"Manual","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":100,"wgPageName":"Manual:Creating_a_bot","wgTitle":"Creating a bot","wgCurRevisionId":6845346,"wgRevisionId":6845346,"wgArticleId":308701,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Bots"],"wgPageViewLanguage":"en","wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Manual:Creating_a_bot","wgRelevantArticleId":308701,"wgIsProbablyEditable":true,"wgRelevantPageIsProbablyEditable":true,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgNoticeProject":"mediawiki","wgCiteReferencePreviewsActive":true,"wgMediaViewerOnClick":true,"wgMediaViewerEnabledByDefault":true,"wgVisualEditor":{"pageLanguageCode" :"en","pageLanguageDir":"ltr","pageVariantFallbacks":"en"},"wgMFDisplayWikibaseDescriptions":{"search":true,"watchlist":true,"tagline":false,"nearby":true},"wgWMESchemaEditAttemptStepOversample":false,"wgWMEPageLength":50000,"wgTranslatePageTranslation":"source","wgCentralAuthMobileDomain":false,"wgEditSubmitButtonLabelPublish":true,"wgULSPosition":"personal","wgULSisCompactLinksEnabled":true,"wgVector2022LanguageInHeader":false,"wgULSisLanguageSelectorEmpty":false,"wgCheckUserClientHintsHeadersJsApi":["brands","architecture","bitness","fullVersionList","mobile","model","platform","platformVersion"]};RLSTATE={"ext.globalCssJs.user.styles":"ready","site.styles":"ready","user.styles":"ready","ext.globalCssJs.user":"ready","user":"ready","user.options":"loading","ext.translate.tag.languages":"ready","ext.pygments":"ready","ext.cite.styles":"ready","skins.vector.search.codex.styles":"ready","skins.vector.styles":"ready","skins.vector.icons":"ready","jquery.tablesorter.styles":"ready", "ext.translate.edit.documentation.styles":"ready","ext.translate":"ready","ext.wikimediamessages.styles":"ready","ext.visualEditor.desktopArticleTarget.noscript":"ready","ext.uls.pt":"ready","wikibase.client.init":"ready","ext.wikimediaBadges":"ready"};RLPAGEMODULES=["ext.pygments.view","ext.cite.ux-enhancements","mediawiki.page.media","site","mediawiki.page.ready","jquery.tablesorter","mediawiki.toc","skins.vector.js","ext.centralNotice.geoIP","ext.centralNotice.startUp","ext.translate.pagetranslation.uls","ext.urlShortener.toolbar","ext.centralauth.centralautologin","mmv.bootstrap","ext.visualEditor.desktopArticleTarget.init","ext.visualEditor.targetLoader","ext.echo.centralauth","ext.eventLogging","ext.wikimediaEvents","ext.navigationTiming","ext.uls.compactlinks","ext.uls.interface","ext.checkUser.clientHints"];</script> <script>(RLQ=window.RLQ||[]).push(function(){mw.loader.impl(function(){return["user.options@12s5i",function($,jQuery,require,module){mw.user.tokens.set({"patrolToken":"+\\","watchToken":"+\\","csrfToken":"+\\"}); }];});});</script> <link rel="stylesheet" href="/w/load.php?lang=en&modules=ext.cite.styles%7Cext.pygments%2Ctranslate%2CwikimediaBadges%7Cext.translate.edit.documentation.styles%7Cext.translate.tag.languages%7Cext.uls.pt%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediamessages.styles%7Cjquery.tablesorter.styles%7Cskins.vector.icons%2Cstyles%7Cskins.vector.search.codex.styles%7Cwikibase.client.init&only=styles&skin=vector-2022"> <script async="" src="/w/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector-2022"></script> <meta name="ResourceLoaderDynamicStyles" content=""> <link rel="stylesheet" href="/w/load.php?lang=en&modules=site.styles&only=styles&skin=vector-2022"> <meta name="generator" content="MediaWiki 1.44.0-wmf.4"> <meta name="referrer" content="origin"> <meta name="referrer" content="origin-when-cross-origin"> <meta name="robots" content="max-image-preview:standard"> <meta name="format-detection" content="telephone=no"> <meta name="viewport" content="width=1120"> <meta property="og:site_name" content="MediaWiki"> <meta property="og:title" content="Manual:Creating a bot - MediaWiki"> <meta property="og:type" content="website"> <link rel="preconnect" href="//upload.wikimedia.org"> <link rel="alternate" media="only screen and (max-width: 640px)" href="//m.mediawiki.org/wiki/Manual:Creating_a_bot"> <link rel="alternate" type="application/x-wiki" title="Edit" href="/w/index.php?title=Manual:Creating_a_bot&action=edit"> <link rel="apple-touch-icon" href="/static/apple-touch/mediawiki.png"> <link rel="icon" href="/static/favicon/mediawiki.ico"> <link rel="search" type="application/opensearchdescription+xml" href="/w/rest.php/v1/search" title="MediaWiki (en)"> <link rel="EditURI" type="application/rsd+xml" href="//www.mediawiki.org/w/api.php?action=rsd"> <link rel="canonical" href="https://www.mediawiki.org/wiki/Manual:Creating_a_bot"> <link rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/"> <link rel="alternate" type="application/atom+xml" title="MediaWiki Atom feed" href="/w/index.php?title=Special:RecentChanges&feed=atom"> <link rel="dns-prefetch" href="//meta.wikimedia.org" /> <link rel="dns-prefetch" href="//login.wikimedia.org"> </head> <body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-100 ns-subject mw-editable page-Manual_Creating_a_bot rootpage-Manual_Creating_a_bot skin-vector-2022 action-view"><a class="mw-jump-link" href="#bodyContent">Jump to content</a> <div class="vector-header-container"> <header class="vector-header mw-header"> <div class="vector-header-start"> <nav class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-dropdown" class="vector-dropdown vector-main-menu-dropdown vector-button-flush-left vector-button-flush-right" > <input type="checkbox" id="vector-main-menu-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-main-menu-dropdown" class="vector-dropdown-checkbox " aria-label="Main menu" > <label id="vector-main-menu-dropdown-label" for="vector-main-menu-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-menu mw-ui-icon-wikimedia-menu"></span> <span class="vector-dropdown-label-text">Main menu</span> </label> <div class="vector-dropdown-content"> <div id="vector-main-menu-unpinned-container" class="vector-unpinned-container"> <div id="vector-main-menu" class="vector-main-menu vector-pinnable-element"> <div class="vector-pinnable-header vector-main-menu-pinnable-header vector-pinnable-header-unpinned" data-feature-name="main-menu-pinned" data-pinnable-element-id="vector-main-menu" data-pinned-container-id="vector-main-menu-pinned-container" data-unpinned-container-id="vector-main-menu-unpinned-container" > <div class="vector-pinnable-header-label">Main menu</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-main-menu.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-main-menu.unpin">hide</button> </div> <div id="p-navigation" class="vector-menu mw-portlet mw-portlet-navigation" > <div class="vector-menu-heading"> Navigation </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-mainpage-description" class="mw-list-item"><a href="/wiki/MediaWiki" title="Visit the main page [z]" accesskey="z"><span>Main page</span></a></li><li id="n-mw-download" class="mw-list-item"><a href="/wiki/Download"><span>Get MediaWiki</span></a></li><li id="n-mw-extensions" class="mw-list-item"><a href="/wiki/Special:MyLanguage/Category:Extensions"><span>Get extensions</span></a></li><li id="n-blog-text" class="mw-list-item"><a href="https://techblog.wikimedia.org/"><span>Tech blog</span></a></li><li id="n-mw-contribute" class="mw-list-item"><a href="/wiki/Special:MyLanguage/How_to_contribute"><span>Contribute</span></a></li> </ul> </div> </div> <div id="p-support" class="vector-menu mw-portlet mw-portlet-support" > <div class="vector-menu-heading"> Support </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-help" class="mw-list-item"><a href="/wiki/Special:MyLanguage/Help:Contents" title="The place to find out"><span>User help</span></a></li><li id="n-mw-faq" class="mw-list-item"><a href="/wiki/Special:MyLanguage/Manual:FAQ"><span>FAQ</span></a></li><li id="n-mw-manual" class="mw-list-item"><a href="/wiki/Special:MyLanguage/Manual:Contents"><span>Technical manual</span></a></li><li id="n-mw-supportdesk" class="mw-list-item"><a href="/wiki/Project:Support_desk"><span>Support desk</span></a></li><li id="n-mw-communication" class="mw-list-item"><a href="/wiki/Special:MyLanguage/Communication"><span>Communication</span></a></li> </ul> </div> </div> <div id="p-development" class="vector-menu mw-portlet mw-portlet-development" > <div class="vector-menu-heading"> Development </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-mw-developerportal" class="mw-list-item"><a href="https://developer.wikimedia.org/"><span>Developer portal</span></a></li><li id="n-svn-statistics" class="mw-list-item"><a href="/wiki/Development_statistics"><span>Code statistics</span></a></li> </ul> </div> </div> <div id="p-mediawiki.org" class="vector-menu mw-portlet mw-portlet-mediawiki_org" > <div class="vector-menu-heading"> mediawiki.org </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-portal" class="mw-list-item"><a href="/wiki/Project:Help" title="About the project, what you can do, where to find things"><span>Community portal</span></a></li><li id="n-recentchanges" class="mw-list-item"><a href="/wiki/Special:RecentChanges" title="A list of recent changes in the wiki [r]" accesskey="r"><span>Recent changes</span></a></li><li id="n-mw-translate" class="mw-list-item"><a href="/wiki/Special:LanguageStats"><span>Translate content</span></a></li><li id="n-randompage" class="mw-list-item"><a href="/wiki/Special:Random" title="Load a random page [x]" accesskey="x"><span>Random page</span></a></li><li id="n-mw-discussion" class="mw-list-item"><a href="/wiki/Project:Village_Pump"><span>Village pump</span></a></li><li id="n-Sandboxlink-portlet-label" class="mw-list-item"><a href="/wiki/Project:Sandbox"><span>Sandbox</span></a></li> </ul> </div> </div> <div id="p-lang" class="vector-menu mw-portlet mw-portlet-lang" > <div class="vector-menu-heading"> In other languages </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> <div class="after-portlet after-portlet-lang"><span class="wb-langlinks-add wb-langlinks-link"><a href="https://www.wikidata.org/wiki/Special:NewItem?site=mediawikiwiki&page=Manual%3ACreating+a+bot" title="Add interlanguage links" class="wbc-editpage">Add links</a></span></div> </div> </div> </div> </div> </div> </div> </nav> <a href="/wiki/MediaWiki" class="mw-logo"> <img class="mw-logo-icon" src="/static/images/icons/mediawikiwiki.svg" alt="" aria-hidden="true" height="50" width="50"> <span class="mw-logo-container skin-invert"> <img class="mw-logo-wordmark" alt="MediaWiki" src="/static/images/mobile/copyright/mediawikiwiki-wordmark.svg" style="width: 7.5em; height: 1.125em;"> </span> </a> </div> <div class="vector-header-end"> <div id="p-search" role="search" class="vector-search-box-vue vector-search-box-collapses vector-search-box-show-thumbnail vector-search-box-auto-expand-width vector-search-box"> <a href="/wiki/Special:Search" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only search-toggle" title="Search MediaWiki [f]" accesskey="f"><span class="vector-icon mw-ui-icon-search mw-ui-icon-wikimedia-search"></span> <span>Search</span> </a> <div class="vector-typeahead-search-container"> <div class="cdx-typeahead-search cdx-typeahead-search--show-thumbnail cdx-typeahead-search--auto-expand-width"> <form action="/w/index.php" id="searchform" class="cdx-search-input cdx-search-input--has-end-button"> <div id="simpleSearch" class="cdx-search-input__input-wrapper" data-search-loc="header-moved"> <div class="cdx-text-input cdx-text-input--has-start-icon"> <input class="cdx-text-input__input" type="search" name="search" placeholder="Search MediaWiki" aria-label="Search MediaWiki" autocapitalize="sentences" title="Search MediaWiki [f]" accesskey="f" id="searchInput" > <span class="cdx-text-input__icon cdx-text-input__start-icon"></span> </div> <input type="hidden" name="title" value="Special:Search"> </div> <button class="cdx-button cdx-search-input__end-button">Search</button> </form> </div> </div> </div> <nav class="vector-user-links vector-user-links-wide" aria-label="Personal tools"> <div class="vector-user-links-main"> <div id="p-vector-user-menu-preferences" class="vector-menu mw-portlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-uls" class="mw-list-item active user-links-collapsible-item"><a data-mw="interface" href="#" class="uls-trigger cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet"><span class="vector-icon mw-ui-icon-wikimedia-language mw-ui-icon-wikimedia-wikimedia-language"></span> <span>English</span></a> </li> </ul> </div> </div> <div id="p-vector-user-menu-userpage" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-dropdown" class="vector-dropdown " title="Change the appearance of the page's font size, width, and color" > <input type="checkbox" id="vector-appearance-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-appearance-dropdown" class="vector-dropdown-checkbox " aria-label="Appearance" > <label id="vector-appearance-dropdown-label" for="vector-appearance-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-appearance mw-ui-icon-wikimedia-appearance"></span> <span class="vector-dropdown-label-text">Appearance</span> </label> <div class="vector-dropdown-content"> <div id="vector-appearance-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <div id="p-vector-user-menu-notifications" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-overflow" class="vector-menu mw-portlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="https://donate.wikimedia.org/?utm_source=donate&utm_medium=sidebar&utm_campaign=spontaneous&uselang=en" class=""><span>Donate</span></a> </li> <li id="pt-createaccount-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:CreateAccount&returnto=Manual%3ACreating+a+bot" title="You are encouraged to create an account and log in; however, it is not mandatory" class=""><span>Create account</span></a> </li> <li id="pt-login-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:UserLogin&returnto=Manual%3ACreating+a+bot" title="You are encouraged to log in; however, it is not mandatory [o]" accesskey="o" class=""><span>Log in</span></a> </li> </ul> </div> </div> </div> <div id="vector-user-links-dropdown" class="vector-dropdown vector-user-menu vector-button-flush-right vector-user-menu-logged-out" title="More options" > <input type="checkbox" id="vector-user-links-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-user-links-dropdown" class="vector-dropdown-checkbox " aria-label="Personal tools" > <label id="vector-user-links-dropdown-label" for="vector-user-links-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-ellipsis mw-ui-icon-wikimedia-ellipsis"></span> <span class="vector-dropdown-label-text">Personal tools</span> </label> <div class="vector-dropdown-content"> <div id="p-personal" class="vector-menu mw-portlet mw-portlet-personal user-links-collapsible-item" title="User menu" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport" class="user-links-collapsible-item mw-list-item"><a href="https://donate.wikimedia.org/?utm_source=donate&utm_medium=sidebar&utm_campaign=spontaneous&uselang=en"><span>Donate</span></a></li><li id="pt-createaccount" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:CreateAccount&returnto=Manual%3ACreating+a+bot" title="You are encouraged to create an account and log in; however, it is not mandatory"><span class="vector-icon mw-ui-icon-userAdd mw-ui-icon-wikimedia-userAdd"></span> <span>Create account</span></a></li><li id="pt-login" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:UserLogin&returnto=Manual%3ACreating+a+bot" title="You are encouraged to log in; however, it is not mandatory [o]" accesskey="o"><span class="vector-icon mw-ui-icon-logIn mw-ui-icon-wikimedia-logIn"></span> <span>Log in</span></a></li> </ul> </div> </div> <div id="p-user-menu-anon-editor" class="vector-menu mw-portlet mw-portlet-user-menu-anon-editor" > <div class="vector-menu-heading"> Pages for logged out editors <a href="/wiki/Help:Introduction" aria-label="Learn more about editing"><span>learn more</span></a> </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-anoncontribs" class="mw-list-item"><a href="/wiki/Special:MyContributions" title="A list of edits made from this IP address [y]" accesskey="y"><span>Contributions</span></a></li><li id="pt-anontalk" class="mw-list-item"><a href="/wiki/Special:MyTalk" title="Discussion about edits from this IP address [n]" accesskey="n"><span>Talk</span></a></li> </ul> </div> </div> </div> </div> </nav> </div> </header> </div> <div class="mw-page-container"> <div class="mw-page-container-inner"> <div class="vector-sitenotice-container"> <div id="siteNotice"><!-- CentralNotice --></div> </div> <div class="vector-column-start"> <div class="vector-main-menu-container"> <div id="mw-navigation"> <nav id="mw-panel" class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-pinned-container" class="vector-pinned-container"> </div> </nav> </div> </div> <div class="vector-sticky-pinned-container"> <nav id="mw-panel-toc" aria-label="Contents" data-event-name="ui.sidebar-toc" class="mw-table-of-contents-container vector-toc-landmark"> <div id="vector-toc-pinned-container" class="vector-pinned-container"> <div id="vector-toc" class="vector-toc vector-pinnable-element"> <div class="vector-pinnable-header vector-toc-pinnable-header vector-pinnable-header-pinned" data-feature-name="toc-pinned" data-pinnable-element-id="vector-toc" > <h2 class="vector-pinnable-header-label">Contents</h2> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-toc.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-toc.unpin">hide</button> </div> <ul class="vector-toc-contents" id="mw-panel-toc-list"> <li id="toc-mw-content-text" class="vector-toc-list-item vector-toc-level-1"> <a href="#" class="vector-toc-link"> <div class="vector-toc-text">Beginning</div> </a> </li> <li id="toc-Why_would_I_need_to_create_a_bot?" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Why_would_I_need_to_create_a_bot?"> <div class="vector-toc-text"> <span class="vector-toc-numb">1</span> <span>Why would I need to create a bot?</span> </div> </a> <ul id="toc-Why_would_I_need_to_create_a_bot?-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Considerations_before_creating_a_bot" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Considerations_before_creating_a_bot"> <div class="vector-toc-text"> <span class="vector-toc-numb">2</span> <span>Considerations before creating a bot</span> </div> </a> <button aria-controls="toc-Considerations_before_creating_a_bot-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Considerations before creating a bot subsection</span> </button> <ul id="toc-Considerations_before_creating_a_bot-sublist" class="vector-toc-list"> <li id="toc-Reuse_existing_bots" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Reuse_existing_bots"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.1</span> <span>Reuse existing bots</span> </div> </a> <ul id="toc-Reuse_existing_bots-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Reuse_codebase" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Reuse_codebase"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.2</span> <span>Reuse codebase</span> </div> </a> <ul id="toc-Reuse_codebase-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Important_questions" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Important_questions"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3</span> <span>Important questions</span> </div> </a> <ul id="toc-Important_questions-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-How_does_a_MediaWiki_bot_work?" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#How_does_a_MediaWiki_bot_work?"> <div class="vector-toc-text"> <span class="vector-toc-numb">3</span> <span>How does a MediaWiki bot work?</span> </div> </a> <button aria-controls="toc-How_does_a_MediaWiki_bot_work?-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle How does a MediaWiki bot work? subsection</span> </button> <ul id="toc-How_does_a_MediaWiki_bot_work?-sublist" class="vector-toc-list"> <li id="toc-Overview_of_operation" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Overview_of_operation"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.1</span> <span>Overview of operation</span> </div> </a> <ul id="toc-Overview_of_operation-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-APIs_for_bots" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#APIs_for_bots"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.2</span> <span>APIs for bots</span> </div> </a> <ul id="toc-APIs_for_bots-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Logging_in" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Logging_in"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.3</span> <span>Logging in</span> </div> </a> <ul id="toc-Logging_in-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Editing;_edit_tokens" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Editing;_edit_tokens"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.4</span> <span>Editing; edit tokens</span> </div> </a> <ul id="toc-Editing;_edit_tokens-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Edit_conflicts" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Edit_conflicts"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.5</span> <span>Edit conflicts</span> </div> </a> <ul id="toc-Edit_conflicts-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Overview_of_the_process_of_developing_a_bot" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Overview_of_the_process_of_developing_a_bot"> <div class="vector-toc-text"> <span class="vector-toc-numb">4</span> <span>Overview of the process of developing a bot</span> </div> </a> <button aria-controls="toc-Overview_of_the_process_of_developing_a_bot-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Overview of the process of developing a bot subsection</span> </button> <ul id="toc-Overview_of_the_process_of_developing_a_bot-sublist" class="vector-toc-list"> <li id="toc-Idea" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Idea"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.1</span> <span>Idea</span> </div> </a> <ul id="toc-Idea-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Specification" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Specification"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.2</span> <span>Specification</span> </div> </a> <ul id="toc-Specification-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Software_architecture" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Software_architecture"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.3</span> <span>Software architecture</span> </div> </a> <ul id="toc-Software_architecture-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Implementation" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Implementation"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.4</span> <span>Implementation</span> </div> </a> <ul id="toc-Implementation-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Testing" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Testing"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.5</span> <span>Testing</span> </div> </a> <ul id="toc-Testing-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Documentation" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Documentation"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.6</span> <span>Documentation</span> </div> </a> <ul id="toc-Documentation-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Queries/Complaints" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Queries/Complaints"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.7</span> <span>Queries/Complaints</span> </div> </a> <ul id="toc-Queries/Complaints-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Maintenance" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Maintenance"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.8</span> <span>Maintenance</span> </div> </a> <ul id="toc-Maintenance-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-General_guidelines_for_running_a_bot" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#General_guidelines_for_running_a_bot"> <div class="vector-toc-text"> <span class="vector-toc-numb">5</span> <span>General guidelines for running a bot</span> </div> </a> <button aria-controls="toc-General_guidelines_for_running_a_bot-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle General guidelines for running a bot subsection</span> </button> <ul id="toc-General_guidelines_for_running_a_bot-sublist" class="vector-toc-list"> <li id="toc-Bot_best_practices" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Bot_best_practices"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.1</span> <span>Bot best practices</span> </div> </a> <ul id="toc-Bot_best_practices-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Common_bot_features_you_should_consider_implementing" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Common_bot_features_you_should_consider_implementing"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2</span> <span>Common bot features you should consider implementing</span> </div> </a> <ul id="toc-Common_bot_features_you_should_consider_implementing-sublist" class="vector-toc-list"> <li id="toc-Manual_assistance" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Manual_assistance"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2.1</span> <span>Manual assistance</span> </div> </a> <ul id="toc-Manual_assistance-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Disabling_the_bot" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Disabling_the_bot"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2.2</span> <span>Disabling the bot</span> </div> </a> <ul id="toc-Disabling_the_bot-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Signature" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Signature"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2.3</span> <span>Signature</span> </div> </a> <ul id="toc-Signature-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Bot_Flag" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Bot_Flag"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2.4</span> <span>Bot Flag</span> </div> </a> <ul id="toc-Bot_Flag-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Monitoring_the_bot_status" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Monitoring_the_bot_status"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2.5</span> <span>Monitoring the bot status</span> </div> </a> <ul id="toc-Monitoring_the_bot_status-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> </ul> </li> <li id="toc-Open-source_bots" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Open-source_bots"> <div class="vector-toc-text"> <span class="vector-toc-numb">6</span> <span>Open-source bots</span> </div> </a> <ul id="toc-Open-source_bots-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Programming_languages_and_libraries" class="vector-toc-list-item vector-toc-level-1"> <a class="vector-toc-link" href="#Programming_languages_and_libraries"> <div class="vector-toc-text"> <span class="vector-toc-numb">7</span> <span>Programming languages and libraries</span> </div> </a> <button aria-controls="toc-Programming_languages_and_libraries-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Programming languages and libraries subsection</span> </button> <ul id="toc-Programming_languages_and_libraries-sublist" class="vector-toc-list"> <li id="toc-Awk" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Awk"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.1</span> <span>Awk</span> </div> </a> <ul id="toc-Awk-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Perl" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Perl"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.2</span> <span>Perl</span> </div> </a> <ul id="toc-Perl-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-PHP" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#PHP"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.3</span> <span>PHP</span> </div> </a> <ul id="toc-PHP-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Python" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Python"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.4</span> <span>Python</span> </div> </a> <ul id="toc-Python-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Microsoft_.NET" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Microsoft_.NET"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.5</span> <span>Microsoft .NET</span> </div> </a> <ul id="toc-Microsoft_.NET-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Java" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Java"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.6</span> <span>Java</span> </div> </a> <ul id="toc-Java-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-JavaScript_(Node.js)" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#JavaScript_(Node.js)"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.7</span> <span>JavaScript (Node.js)</span> </div> </a> <ul id="toc-JavaScript_(Node.js)-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Ruby" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Ruby"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.8</span> <span>Ruby</span> </div> </a> <ul id="toc-Ruby-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Common_Lisp" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Common_Lisp"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.9</span> <span>Common Lisp</span> </div> </a> <ul id="toc-Common_Lisp-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Haskell" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Haskell"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.10</span> <span>Haskell</span> </div> </a> <ul id="toc-Haskell-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-VBScript" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#VBScript"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.11</span> <span>VBScript</span> </div> </a> <ul id="toc-VBScript-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Bash" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Bash"> <div class="vector-toc-text"> <span class="vector-toc-numb">7.12</span> <span>Bash</span> </div> </a> <ul id="toc-Bash-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> </ul> </div> </div> </nav> </div> </div> <div class="mw-content-container"> <main id="content" class="mw-body"> <header class="mw-body-header vector-page-titlebar"> <nav aria-label="Contents" class="vector-toc-landmark"> <div id="vector-page-titlebar-toc" class="vector-dropdown vector-page-titlebar-toc vector-button-flush-left" > <input type="checkbox" id="vector-page-titlebar-toc-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-titlebar-toc" class="vector-dropdown-checkbox " aria-label="Toggle the table of contents" > <label id="vector-page-titlebar-toc-label" for="vector-page-titlebar-toc-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-listBullet mw-ui-icon-wikimedia-listBullet"></span> <span class="vector-dropdown-label-text">Toggle the table of contents</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-titlebar-toc-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-namespace">Manual</span><span class="mw-page-title-separator">:</span><span class="mw-page-title-main">Creating a bot</span></h1> <div class="mw-indicators"> </div> </header> <div class="vector-page-toolbar"> <div class="vector-page-toolbar-container"> <div id="left-navigation"> <nav aria-label="Namespaces"> <div id="p-associated-pages" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-associated-pages" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-nstab-manual" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Manual:Creating_a_bot" title="View the subject page [c]" accesskey="c"><span>Manual</span></a></li><li id="ca-talk" class="vector-tab-noicon mw-list-item"><a href="/wiki/Manual_talk:Creating_a_bot" rel="discussion" title="Discussion about the content page [t]" accesskey="t"><span>Discussion</span></a></li> </ul> </div> </div> <div id="vector-variants-dropdown" class="vector-dropdown emptyPortlet" > <input type="checkbox" id="vector-variants-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-variants-dropdown" class="vector-dropdown-checkbox " aria-label="Change language variant" > <label id="vector-variants-dropdown-label" for="vector-variants-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">English</span> </label> <div class="vector-dropdown-content"> <div id="p-variants" class="vector-menu mw-portlet mw-portlet-variants emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> </div> </div> </nav> </div> <div id="right-navigation" class="vector-collapsible"> <nav aria-label="Views"> <div id="p-views" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-views" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-view" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Manual:Creating_a_bot"><span>Read</span></a></li><li id="ca-edit" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit" title="Edit the source code of this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-history" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Manual:Creating_a_bot&action=history" title="Past revisions of this page [h]" accesskey="h"><span>View history</span></a></li> </ul> </div> </div> </nav> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-dropdown" class="vector-dropdown vector-page-tools-dropdown" > <input type="checkbox" id="vector-page-tools-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-tools-dropdown" class="vector-dropdown-checkbox " aria-label="Tools" > <label id="vector-page-tools-dropdown-label" for="vector-page-tools-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">Tools</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-tools-unpinned-container" class="vector-unpinned-container"> <div id="vector-page-tools" class="vector-page-tools vector-pinnable-element"> <div class="vector-pinnable-header vector-page-tools-pinnable-header vector-pinnable-header-unpinned" data-feature-name="page-tools-pinned" data-pinnable-element-id="vector-page-tools" data-pinned-container-id="vector-page-tools-pinned-container" data-unpinned-container-id="vector-page-tools-unpinned-container" > <div class="vector-pinnable-header-label">Tools</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-page-tools.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-page-tools.unpin">hide</button> </div> <div id="p-cactions" class="vector-menu mw-portlet mw-portlet-cactions emptyPortlet vector-has-collapsible-items" title="More options" > <div class="vector-menu-heading"> Actions </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-more-view" class="selected vector-more-collapsible-item mw-list-item"><a href="/wiki/Manual:Creating_a_bot"><span>Read</span></a></li><li id="ca-more-edit" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit" title="Edit the source code of this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-more-history" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Manual:Creating_a_bot&action=history"><span>View history</span></a></li> </ul> </div> </div> <div id="p-tb" class="vector-menu mw-portlet mw-portlet-tb" > <div class="vector-menu-heading"> General </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="t-whatlinkshere" class="mw-list-item"><a href="/wiki/Special:WhatLinksHere/Manual:Creating_a_bot" title="A list of all wiki pages that link here [j]" accesskey="j"><span>What links here</span></a></li><li id="t-recentchangeslinked" class="mw-list-item"><a href="/wiki/Special:RecentChangesLinked/Manual:Creating_a_bot" rel="nofollow" title="Recent changes in pages linked from this page [k]" accesskey="k"><span>Related changes</span></a></li><li id="t-upload" class="mw-list-item"><a href="//commons.wikimedia.org/wiki/Special:UploadWizard" title="Upload files [u]" accesskey="u"><span>Upload file</span></a></li><li id="t-specialpages" class="mw-list-item"><a href="/wiki/Special:SpecialPages" title="A list of all special pages [q]" accesskey="q"><span>Special pages</span></a></li><li id="t-permalink" class="mw-list-item"><a href="/w/index.php?title=Manual:Creating_a_bot&oldid=6845346" title="Permanent link to this revision of this page"><span>Permanent link</span></a></li><li id="t-info" class="mw-list-item"><a href="/w/index.php?title=Manual:Creating_a_bot&action=info" title="More information about this page"><span>Page information</span></a></li><li id="t-cite" class="mw-list-item"><a href="/w/index.php?title=Special:CiteThisPage&page=Manual%3ACreating_a_bot&id=6845346&wpFormIdentifier=titleform" title="Information on how to cite this page"><span>Cite this page</span></a></li><li id="t-urlshortener" class="mw-list-item"><a href="/w/index.php?title=Special:UrlShortener&url=https%3A%2F%2Fwww.mediawiki.org%2Fwiki%2FManual%3ACreating_a_bot"><span>Get shortened URL</span></a></li><li id="t-urlshortener-qrcode" class="mw-list-item"><a href="/w/index.php?title=Special:QrCode&url=https%3A%2F%2Fwww.mediawiki.org%2Fwiki%2FManual%3ACreating_a_bot"><span>Download QR code</span></a></li> </ul> </div> </div> <div id="p-coll-print_export" class="vector-menu mw-portlet mw-portlet-coll-print_export" > <div class="vector-menu-heading"> Print/export </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="coll-create_a_book" class="mw-list-item"><a href="/w/index.php?title=Special:Book&bookcmd=book_creator&referer=Manual%3ACreating+a+bot"><span>Create a book</span></a></li><li id="coll-download-as-rl" class="mw-list-item"><a href="/w/index.php?title=Special:DownloadAsPdf&page=Manual%3ACreating_a_bot&action=show-download-screen"><span>Download as PDF</span></a></li><li id="t-print" class="mw-list-item"><a href="/w/index.php?title=Manual:Creating_a_bot&printable=yes" title="Printable version of this page [p]" accesskey="p"><span>Printable version</span></a></li> </ul> </div> </div> <div id="p-wikibase-otherprojects" class="vector-menu mw-portlet mw-portlet-wikibase-otherprojects emptyPortlet" > <div class="vector-menu-heading"> In other projects </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> </div> </div> </div> </div> </nav> </div> </div> </div> <div class="vector-column-end"> <div class="vector-sticky-pinned-container"> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-pinned-container" class="vector-pinned-container"> </div> </nav> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-pinned-container" class="vector-pinned-container"> <div id="vector-appearance" class="vector-appearance vector-pinnable-element"> <div class="vector-pinnable-header vector-appearance-pinnable-header vector-pinnable-header-pinned" data-feature-name="appearance-pinned" data-pinnable-element-id="vector-appearance" data-pinned-container-id="vector-appearance-pinned-container" data-unpinned-container-id="vector-appearance-unpinned-container" > <div class="vector-pinnable-header-label">Appearance</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-appearance.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-appearance.unpin">hide</button> </div> </div> </div> </nav> </div> </div> <div id="bodyContent" class="vector-body" aria-labelledby="firstHeading" data-mw-ve-target-container> <div class="vector-body-before-content"> <div id="siteSub" class="noprint">From mediawiki.org</div> </div> <div id="contentSub"><div id="mw-content-subtitle"></div></div> <div id="mw-content-text" class="mw-body-content"><div class="mw-pt-translate-header noprint nomobile" dir="ltr" lang="en"><a href="/w/index.php?title=Special:Translate&group=page-Manual%3ACreating+a+bot&action=page&filter=&action_source=translate_page" title="Special:Translate">Translate this page</a></div><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr"><div class="mw-pt-languages noprint navigation-not-searchable" lang="en" dir="ltr"><div class="mw-pt-languages-label">Languages:</div><ul class="mw-pt-languages-list"><li><a href="/wiki/Manual:Creating_a_bot/de" class="mw-pt-progress mw-pt-progress--med" title="Handbuch:Einen Bot erstellen (37% translated)" lang="de" dir="ltr">Deutsch</a></li> <li><span class="mw-pt-languages-ui mw-pt-languages-selected mw-pt-progress mw-pt-progress--complete" lang="en" dir="ltr">English</span></li> <li><a href="/wiki/Manual:Creating_a_bot/fr" class="mw-pt-progress mw-pt-progress--complete" title="Manuel:Créer un robot (100% translated)" lang="fr" dir="ltr">français</a></li> <li><a href="/wiki/Manual:Creating_a_bot/pt-br" class="mw-pt-progress mw-pt-progress--low" title="Manual:Creating a bot/pt-br (10% translated)" lang="pt-BR" dir="ltr">português do Brasil</a></li> <li><a href="/wiki/Manual:Creating_a_bot/ar" class="mw-pt-progress mw-pt-progress--low" title="دليل:إنشاء بوت (1% translated)" lang="ar" dir="rtl">العربية</a></li> <li><a href="/wiki/Manual:Creating_a_bot/zh" class="mw-pt-progress mw-pt-progress--med" title="Manual: (53% translated)" lang="zh" dir="ltr">中文</a></li> <li><a href="/wiki/Manual:Creating_a_bot/ja" class="mw-pt-progress mw-pt-progress--med" title="Manual:ボットを作成する (20% translated)" lang="ja" dir="ltr">日本語</a></li></ul></div> <style data-mw-deduplicate="TemplateStyles:r6824882">.mw-parser-output table.ambox{margin:0 10%;width:unset;border:1px solid #a2a9b1;border-left:10px solid #36c;background-color:#fbfbfb;box-sizing:border-box}.mw-parser-output table.ambox+table.ambox,.mw-parser-output table.ambox+link+table.ambox,.mw-parser-output table.ambox+style+table.ambox{margin-top:-1px}.mw-parser-output .ambox td.mbox-empty-cell{border:none;padding:0;width:1px}.mw-parser-output .ambox th.mbox-text,.mw-parser-output .ambox td.mbox-text{border:none;padding:0.25em 0.5em;width:100%}.mw-parser-output .ambox td.mbox-image{padding:2px 0 2px 0.5em}.mw-parser-output .ambox td.mbox-imageright{padding:2px 0.5em 2px 0}.mw-parser-output table.ambox-notice{border-left-color:#36c}.mw-parser-output table.ambox-speedy{background-color:var(--background-color-error-subtle,#fee7e6)}.mw-parser-output table.ambox-delete,.mw-parser-output table.ambox-speedy{border-left-color:var(--background-color-error--active,#b32424)}.mw-parser-output table.ambox-content{border-left-color:#f28500}.mw-parser-output table.ambox-style{border-left-color:#fc3}.mw-parser-output table.ambox-move{border-left-color:#9932cc}.mw-parser-output table.ambox-protection{border-left-color:#a2a9b1}html body.mediawiki .mw-parser-output .ambox.mbox-small{clear:right;float:right;margin:4px 0 4px 1em;box-sizing:border-box;width:238px;font-size:88%;line-height:1.25em}html body.mediawiki .mw-parser-output .ambox.mbox-small-left{margin:4px 1em 4px 0;box-sizing:border-box;overflow:hidden;width:238px;border-collapse:collapse;font-size:88%;line-height:1.25em}</style><table class="ambox-notice box-Notice ambox plainlinks metadata" role="presentation"><tbody><tr><td class="mbox-image"><div style="width:52px"><span typeof="mw:File"><span><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/e/ec/OOjs_UI_icon_information-progressive.svg/40px-OOjs_UI_icon_information-progressive.svg.png" decoding="async" width="40" height="40" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/e/ec/OOjs_UI_icon_information-progressive.svg/60px-OOjs_UI_icon_information-progressive.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/e/ec/OOjs_UI_icon_information-progressive.svg/80px-OOjs_UI_icon_information-progressive.svg.png 2x" data-file-width="20" data-file-height="20" /></span></span></div></td><td class="mbox-text"><div class="mbox-text-span">This article is based on <a href="https://en.wikipedia.org/wiki/Help:Creating_a_bot" class="extiw" title="w:Help:Creating a bot">Creating a bot</a> on English Wikipedia and was last synced in October 2022.</div></td></tr></tbody></table> <p><b>MediaWiki Robots</b> or just <b><a href="/wiki/Special:MyLanguage/Manual:Bots" title="Special:MyLanguage/Manual:Bots">bots</a></b> are automatic processes that interact with Wikipedia (and other Wikimedia projects) as though they were human editors. This page attempts to explain how to carry out the development of a bot for use on Wikimedia projects and much of this is transferable to other wikis based on MediaWiki. The explanation is geared mainly towards those who have some prior programming experience, but are unsure of how to apply this knowledge to creating a MediaWiki bot. </p> <meta property="mw:PageProp/toc" /> <div class="mw-heading mw-heading2"><h2 id="Why_would_I_need_to_create_a_bot?"><span id="Why_would_I_need_to_create_a_bot.3F"></span>Why would I need to create a bot?</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=1" title="Edit section: Why would I need to create a bot?"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Bots can automate tasks and perform them much faster than humans. If you have a simple task that you need to perform lots of times (an example might be to add a <a href="/wiki/Special:MyLanguage/Manual:Templates" title="Special:MyLanguage/Manual:Templates">template</a> to all pages in a category with 1,000 pages), then this is a task better suited to a bot than a human. </p> <div class="mw-heading mw-heading2"><h2 id="Considerations_before_creating_a_bot">Considerations before creating a bot</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=2" title="Edit section: Considerations before creating a bot"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-heading mw-heading3"><h3 id="Reuse_existing_bots">Reuse existing bots</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=3" title="Edit section: Reuse existing bots"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>It is often far simpler to request a bot job from an existing bot. If you have only periodic requests or are uncomfortable with programming, this is usually the best solution. Some wikis have a dedicated page where such requests can be made. In addition, there are a number of tools available to anyone. Most of these take the form of enhanced web browsers with MediaWiki-specific functionality. The most popular of these is <a href="/wiki/Special:MyLanguage/Project:AutoWikiBrowser" title="Special:MyLanguage/Project:AutoWikiBrowser">Project:AutoWikiBrowser</a><span style="display:none"><a href="/wiki/Project:AutoWikiBrowser" title="Project:AutoWikiBrowser"> </a></span> (AWB), a browser specifically designed to assist with editing on Wikipedia and other Wikimedia projects. A more complete list of tools can be found at <a href="https://en.wikipedia.org/wiki/Wikipedia:Tools/Editing_tools" class="extiw" title="w:Wikipedia:Tools/Editing tools">w:Wikipedia:Tools/Editing tools</a> on English Wikipedia. Tools, such as AWB, can often be operated with little or no understanding of programming. </p> <style data-mw-deduplicate="TemplateStyles:r6651107">.mw-parser-output .note{background-position:left 7px top 50%;padding:0.5em 0.5em 0.5em 40px;margin:0.5em 0;overflow:hidden;background-color:#f8f9fa;color:#333;background-repeat:no-repeat;border:1px solid #ddd}.mw-parser-output .note-inline{display:inline-block;vertical-align:middle}.mw-parser-output .note-info{background-color:#eaf3ff;color:#333;background-image:url("https://upload.wikimedia.org/wikipedia/commons/e/ec/OOjs_UI_icon_information-progressive.svg");background-size:25px;border-color:#a3caff;padding-left:40px;min-height:25px}.mw-parser-output .note-reminder{background-color:#fff9ea;color:#333;background-image:url("https://upload.wikimedia.org/wikipedia/commons/a/a8/OOjs_UI_icon_lightbulb-yellow.svg");background-size:25px;border-color:#fc3;min-height:25px}.mw-parser-output .note-warn{background-color:#fff9ea;color:#333;background-image:url("https://upload.wikimedia.org/wikipedia/commons/3/3b/OOjs_UI_icon_alert-warning.svg");background-size:25px;border-color:#fc3;min-height:25px}.mw-parser-output .note-error{background-color:#fee7e6;color:#333;background-image:url("https://upload.wikimedia.org/wikipedia/commons/b/bf/OOjs_UI_icon_notice-destructive.svg");background-size:25px;border-color:#c33;min-height:25px}@media screen{html.skin-theme-clientpref-night .mw-parser-output .note{background-color:transparent;color:inherit}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .note{background-color:transparent;color:inherit}}</style><div role="note" class="note note-reminder">Use <a class="external text" href="https://toolhub.wikimedia.org/">Toolhub</a> to explore available tools for Wikimedia wikis.</div> <div class="mw-heading mw-heading3"><h3 id="Reuse_codebase">Reuse codebase</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=4" title="Edit section: Reuse codebase"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>If you decide you need a bot of your own due to the frequency or novelty of your requirements, you don't need to write one from scratch. Many bots publish their source code, which can sometimes be reused with little additional development time. There are also a number of standard bot frameworks available for download. These frameworks comprise the vast majority of a bot's code. Since these bot frameworks are in common usage and the complex coding has been done by others and has been heavily tested, it is far easier to get bots based on these frameworks approved for use. The most popular and common of these frameworks is <a href="/wiki/Special:MyLanguage/Manual:Pywikibot" title="Special:MyLanguage/Manual:Pywikibot">Pywikibot</a><span style="display:none"><a href="/wiki/Manual:Pywikibot" title="Manual:Pywikibot"> </a></span> (PWB), a bot framework written in <a href="https://en.wikipedia.org/wiki/Python_(programming_language)" class="extiw" title="w:Python (programming language)">Python</a>. It is thoroughly documented and tested and many standardized Pywikibot scripts (bot instructions) are already available. Other examples of bot frameworks can be found <a href="#Programming_languages_and_libraries">below</a>. For some of these bot frameworks, such as PWB, a general familiarity with scripts is all that is necessary to run the bot successfully (it is important to update these frameworks regularly). </p> <div class="mw-heading mw-heading3"><h3 id="Important_questions">Important questions</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=5" title="Edit section: Important questions"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Writing a new bot requires significant programming ability. A completely new bot must undergo substantial testing before it will be approved for regular operation. Planning is crucial to obtain an error-free, efficient, and effective program. The following initial considerations are important: </p> <ul><li>Will the bot be manually assisted or fully automated?</li> <li>Will you create the bot alone, or with the help of other programmers?</li> <li>What language will be used to implement the bot?</li> <li>Will the bot's requests, edits, or other actions be logged? If so, will the logs be stored on local media, or on wiki pages?</li> <li>Will the bot run inside a web browser (for example, written in JavaScript), or will it be a standalone program?</li> <li>If the bot is a standalone program, will it run on your local computer, or on a remote server such as the <a href="https://wikitech.wikimedia.org/wiki/Help:Toolforge" class="extiw" title="wikitech:Help:Toolforge">Toolforge</a>?</li> <li>If the bot runs on a remote server, will other editors be able to operate the bot or start it running?</li></ul> <div class="mw-heading mw-heading2"><h2 id="How_does_a_MediaWiki_bot_work?"><span id="How_does_a_MediaWiki_bot_work.3F"></span>How does a MediaWiki bot work?</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=6" title="Edit section: How does a MediaWiki bot work?"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-heading mw-heading3"><h3 id="Overview_of_operation">Overview of operation</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=7" title="Edit section: Overview of operation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Just like a human editor, a MediaWiki bot reads wiki pages, and makes changes where it thinks changes need to be made. The difference is that although bots are faster and less prone to fatigue than humans, they are nowhere near as bright as we are. Bots are good at repetitive tasks that have easily defined patterns, where few decisions have to be made. </p><p>In the most typical case, a bot logs in to its own account and requests pages from the wiki in much the same way as a browser does – although it does not display the page on screen, but works on it in memory – and then programmatically examines the page code to see if any changes need to be made. It then makes and submits whatever edits it was designed to do, again in much the same way a browser would. </p><p>Because bots access pages the same way people do, bots can experience the same kind of difficulties that human users do. They can get caught in edit conflicts, have page timeouts, or run across other unexpected complications while requesting pages or making edits. Because the volume of work done by a bot is larger than that done by a live person, the bot is more likely to encounter these issues. Thus, it is important to consider these situations when writing a bot. </p> <div class="mw-heading mw-heading3"><h3 id="APIs_for_bots">APIs for bots</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=8" title="Edit section: APIs for bots"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In order to make changes to wiki pages, a bot necessarily has to retrieve pages from the wiki and send edits back. There are several Application Programming Interfaces (APIs) available for that purpose. </p> <ul><li><a href="/wiki/Special:MyLanguage/API" title="Special:MyLanguage/API">MediaWiki Action API</a> (api.php). This web service was specifically written to permit automated processes such as bots to make queries and post changes. Data is returned in <a href="https://en.wikipedia.org/wiki/JSON" class="extiw" title="w:JSON">JSON</a> format (see <a href="/wiki/Special:MyLanguage/API:Data_formats#Output" title="Special:MyLanguage/API:Data formats">output formats</a> for more details). <dl><dd><b>Status:</b> Built-in feature of MediaWiki, available on all Wikimedia servers. Other non-Wikimedia wikis may disable or restrict write access.</dd> <dd>There is also an <a href="/wiki/Special:ApiSandbox" title="Special:ApiSandbox">API sandbox</a> for those wanting to <a href="#tryapi">test api.php's features</a>.</dd></dl></li> <li><a href="/wiki/Special:Export" title="Special:Export">Special:Export</a> can be used to obtain bulk export of page content in XML form. See <a href="/wiki/Special:MyLanguage/" title="Special:MyLanguage/">Manual:Parameters to Special:Export</a><span style="display:none">[[:| ]]</span> for arguments; <dl><dd><b>Status:</b> Built-in feature of MediaWiki, available on all Wikimedia servers.</dd></dl></li> <li>Raw (Wikitext) page processing: sending a <code>action=raw</code> or a <code>action=raw&templates=expand</code> GET request to index.php will give the unprocessed wikitext source code of a page. For example:<br /><code><a class="external free" href="https://en.wikipedia.org/w/index.php?title=Help:Creating_a_bot&action=raw">https://en.wikipedia.org/w/index.php?title=Help:Creating_a_bot&action=raw</a></code>.<br /><span class="anchor" id="tryapi"></span>An API query with:<div class="plainlinks" style="margin-bottom: 0.3em"><b><a class="external text" href="https://en.wikipedia.org/w/api.php?action=query&titles=Help:Creating_a_bot&prop=revisions&rvprop=content">api.php<span style="margin:0 0.5em">?</span><wbr />action=query<span style="margin:0 0.5em">&</span><wbr />titles=Help:Creating_a_bot<span style="margin:0 0.5em">&</span><wbr />prop=revisions<span style="margin:0 0.5em">&</span><wbr />rvprop=content</a></b> <a class="external text" href="https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&titles=Help:Creating_a_bot&prop=revisions&rvprop=content">[try in ApiSandbox]</a></div>or<div class="plainlinks" style="margin-bottom: 0.3em"><b><a class="external text" href="https://en.wikipedia.org/w/api.php?action=query&titles=Help:Creating_a_bot&prop=revisions&rvprop=content&rvexpandtemplates=1">api.php<span style="margin:0 0.5em">?</span><wbr />action=query<span style="margin:0 0.5em">&</span><wbr />titles=Help:Creating_a_bot<span style="margin:0 0.5em">&</span><wbr />prop=revisions<span style="margin:0 0.5em">&</span><wbr />rvprop=content<span style="margin:0 0.5em">&</span><wbr />rvexpandtemplates=1</a></b> <a class="external text" href="https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&titles=Help:Creating_a_bot&prop=revisions&rvprop=content&rvexpandtemplates=1">[try in ApiSandbox]</a></div>is roughly equivalent, and allows for retrieving additional information. <dl><dd><b>Status:</b> Built-in feature of MediaWiki, available on all Wikimedia servers.</dd></dl></li></ul> <p>Some web servers are configured to grant requests for compressed (<a href="https://en.wikipedia.org/wiki/gzip" class="extiw" title="w:gzip">gzip</a>) content. This can be done by including a line "Accept-Encoding: gzip" in the HTTP request header; if the HTTP reply header contains "Content-Encoding: gzip", the document is in gzip form, otherwise, it is in the regular uncompressed form. Note that this is specific to the web server and not to the MediaWiki software. Other sites employing MediaWiki may not have this feature. If you are using an existing bot framework, it should handle low-level operations like this. </p> <div class="mw-heading mw-heading3"><h3 id="Logging_in">Logging in</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=9" title="Edit section: Logging in"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Approved bots need to be logged in to make edits. Although a bot can make read requests without logging in, bots that have completed testing should log in for all activities. Bots logged in from an account with the bot flag (see <a href="#Bot_Flag">#Bot Flag</a> below) can obtain more results per query from the Mediawiki API (api.php). Most bot frameworks should handle login and cookies automatically, but if you are not using an existing framework, you will need to follow these steps. </p><p>For security, login data must be passed using the <a href="https://en.wikipedia.org/wiki/HTTP_POST" class="extiw" title="w:HTTP POST">HTTP POST</a> method. Because parameters of <a href="https://en.wikipedia.org/wiki/HTTP_GET" class="extiw" title="w:HTTP GET">HTTP GET</a> requests are easily visible in URL, logins via GET are disabled. </p><p>To log a bot in using the MediaWiki API, 2 requests are needed: </p><p><b>Request 1 – this is a GET request to obtain a login token</b> </p> <ul><li>URL: <code><a class="external free" href="https://en.wikipedia.org/w/api.php?action=query&format=json&meta=tokens&type=login">https://en.wikipedia.org/w/api.php?action=query&format=json&meta=tokens&type=login</a></code></li></ul> <p>This will return a "logintoken" parameter in JSON form, as documented at <a href="/wiki/Special:MyLanguage/API:Login" title="Special:MyLanguage/API:Login">API:Login</a><span style="display:none"><a href="/wiki/API:Login" title="API:Login"> </a></span>. Other output formats are available. It will also return HTTP cookies as described below. </p><p><b>Request 2 – this is a POST to complete the login</b> </p> <ul><li>URL: <code><a class="external free" href="https://en.wikipedia.org/w/api.php?action=login&format=json">https://en.wikipedia.org/w/api.php?action=login&format=json</a></code></li> <li>POST parameters: <ul><li><code>lgname=BOTUSERNAME</code></li> <li><code>lgpassword=BOTPASSWORD</code></li> <li><code>lgtoken=TOKEN</code></li></ul></li></ul> <p>where TOKEN is the token from the previous result. The HTTP cookies from the previous request must also be passed with the second request. </p><p>A successful login attempt will result in the Wikimedia server setting several <a href="https://en.wikipedia.org/wiki/HTTP_cookie" class="extiw" title="w:HTTP cookie">HTTP cookies</a>. The bot must save these cookies and send them back every time it makes a request (this is particularly crucial for editing). On the English Wikipedia, the following cookies should be used: <b>enwikiUserID</b>, <b>enwikiToken</b>, and <b>enwikiUserName</b>. The <b>enwikisession</b> cookie is required to actually send an edit or commit some change, otherwise the <a href="/wiki/MediaWiki:Session_fail_preview" title="MediaWiki:Session fail preview">MediaWiki:Session fail preview</a> error message will be returned. </p><p>Main-account login via <code>action=login</code> is deprecated and may stop working without warning. To continue using bot code which logs in with <code>action=login</code>, see <a href="/wiki/Special:BotPasswords" title="Special:BotPasswords">Special:BotPasswords</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Editing;_edit_tokens"><span id="Editing.3B_edit_tokens"></span>Editing; edit tokens</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=10" title="Edit section: Editing; edit tokens"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>MediaWiki uses a system of <a href="/wiki/Special:MyLanguage/Manual:Edit_token" title="Special:MyLanguage/Manual:Edit token">edit tokens</a> for making edits to MediaWiki pages, as well as other operations that modify existing content such as rollback. The token looks like a long hexadecimal number followed by '+\', for example: </p> <dl><dd><b>d41d8cd98f00b204e9800998ecf8427e+\</b></dd></dl> <p>The role of edit tokens is to prevent "edit hijacking", where users are tricked into making an edit by clicking a single link. </p><p>The editing process involves two HTTP requests. First, a request for an edit token must be made. Then, a second HTTP request must be made that sends the new content of the page along with the edit token just obtained. It is not possible to make an edit in a single HTTP request. An edit token remains the same for the duration of a logged-in session, so the edit token needs to be retrieved only once and can be used for all subsequent edits. </p><p>To obtain an edit token, follow these steps: </p> <ul> <li><b>MediaWiki API (api.php)</b>. Make a request with the following parameters (see <a href="/wiki/Special:MyLanguage/API:Edit_-_Create%26Edit_pages" title="Special:MyLanguage/API:Edit - Create&Edit pages">Special:MyLanguage/API:Edit - Create&Edit pages</a>). <ul> <li><code>action=query</code></li> <li><code>meta=tokens</code></li> </ul> <p>The token will be returned in the <code>edittoken</code> attribute of the response. </p> </li> </ul> <p>If the edit token the bot receives does not have the hexadecimal string (<i>i.e.</i>, the edit token is just '+\') then the bot most likely is not logged in. This might be due to a number of factors: failure in authentication with the server, a dropped connection, a timeout of some sort, or an error in storing or returning the correct cookies. If it is not because of a programming error, just log in again to refresh the login cookies. The bots <i>must</i> use <a href="/wiki/Special:MyLanguage/API:Assert" title="Special:MyLanguage/API:Assert">assertion</a> to make sure that they are logged in. </p> <div class="mw-heading mw-heading3"><h3 id="Edit_conflicts">Edit conflicts</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=11" title="Edit section: Edit conflicts"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Edit conflicts occur when multiple, overlapping edit attempts are made on the same page. Almost every bot <i>will</i> eventually get caught in an edit conflict of one sort or another, and should include some mechanism to test for and accommodate these issues. </p><p> Bots that use the Mediawiki API (api.php) should retrieve the edit token, along with the <code>starttimestamp</code> and the last revision "base" timestamp, <i>before</i> loading the page text in preparation for the edit; <code>prop=info|revisions</code> can be used to retrieve both the token and page contents in one query. Example:</p><div class="plainlinks" style="margin-bottom: 0.3em"><b><a rel="nofollow" class="external text" href="https:////en.wikipedia.org/w/api.php?titles=Wikipedia:Sandbox&prop=info&inprop=&intoken=edit&rvprop=timestamp">api.php<span style="margin:0 0.5em">?</span><wbr />titles=Wikipedia:Sandbox<span style="margin:0 0.5em">&</span><wbr />prop=info<span style="margin:0 0.5em">&</span><wbr />inprop=<span style="margin:0 0.5em">&</span><wbr />intoken=edit<span style="margin:0 0.5em">&</span><wbr />rvprop=timestamp</a></b> <a rel="nofollow" class="external text" href="https:////en.wikipedia.org/wiki/Special:ApiSandbox#titles=Wikipedia:Sandbox&prop=info&inprop=&intoken=edit&rvprop=timestamp">[try in ApiSandbox]</a></div> <p>When submitting the edit, set the <code>starttimestamp</code> and <code>basetimestamp</code> attributes, and check the server responses for indications of errors. For more details, see <a href="/wiki/Special:MyLanguage/API:Edit_-_Create%26Edit_pages" title="Special:MyLanguage/API:Edit - Create&Edit pages">API:Edit - Create&Edit pages</a><span style="display:none"><a href="/wiki/API:Edit_-_Create%26Edit_pages" class="mw-redirect" title="API:Edit - Create&Edit pages"> </a></span>. </p><p>Generally speaking, if an edit fails to complete the bot should check the page again before trying to make a new edit, to make sure the edit is still appropriate. Further, if a bot rechecks a page to resubmit a change, it should be careful to avoid any behavior that could lead to an infinite loop and any behavior that could even resemble <a href="https://en.wikipedia.org/wiki/WP:EW" class="extiw" title="w:WP:EW">edit warring</a>. </p> <div class="mw-heading mw-heading2"><h2 id="Overview_of_the_process_of_developing_a_bot">Overview of the process of developing a bot</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=12" title="Edit section: Overview of the process of developing a bot"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Actually, coding or writing a bot is only one part of developing a bot. </p><p>The development cycle below is a recommendation from English Wikipedia. </p> <figure class="mw-halign-none" typeof="mw:File/Thumb"><a href="/wiki/File:Bot_development_cycle.svg" class="mw-file-description"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/5/51/Bot_development_cycle.svg/600px-Bot_development_cycle.svg.png" decoding="async" width="600" height="538" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/5/51/Bot_development_cycle.svg/900px-Bot_development_cycle.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/5/51/Bot_development_cycle.svg/1200px-Bot_development_cycle.svg.png 2x" data-file-width="580" data-file-height="520" /></a><figcaption>Overview of English Wikipedia bot development cycle</figcaption></figure> <p>On Wikimedia wikis, ensure that your bot follows any potential bot policies of the wiki. </p> <div class="mw-heading mw-heading4"><h4 id="Idea">Idea</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=13" title="Edit section: Idea"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li>The first task in creating a MediaWiki bot is extracting the requirements or coming up with an idea.</li> <li>Make sure an existing bot isn't already doing what you think your bot should do.</li></ul> <div class="mw-heading mw-heading4"><h4 id="Specification">Specification</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=14" title="Edit section: Specification"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li><a href="https://en.wikipedia.org/wiki/Formal_specification" class="extiw" title="w:Formal specification">Specification</a> is the task of precisely describing the software to be written, possibly in a rigorous way. You should come up with a detailed proposal of what you want it to do. Try to discuss this proposal with some editors and refine it based on feedback. Even a great idea can be made better by incorporating ideas from other editors.</li> <li>In the most basic form, your specified bot must meet the following criteria:</li></ul> <dl><dd><ul><li>The bot is harmless (it must not make edits that could be considered disruptive to the smooth running of the wiki)</li> <li>The bot is useful (it provides a useful service more effectively than a human editor could)</li> <li>The bot does not waste server resources.</li></ul></dd></dl> <div class="mw-heading mw-heading4"><h4 id="Software_architecture">Software architecture</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=15" title="Edit section: Software architecture"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li>Think about <b>how</b> you might create it and which programming language(s) and tools you would use. <a href="https://en.wikipedia.org/wiki/Software_architecture" class="extiw" title="w:Software architecture">Architecture</a> is concerned with making sure the software system will meet the requirements of the product as well as ensuring that future requirements can be addressed. Certain programming languages are better suited to some tasks than others, for more details see <a href="#Programming_languages_and_libraries">the section on programming languages below</a>.</li></ul> <div class="mw-heading mw-heading4"><h4 id="Implementation">Implementation</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=16" title="Edit section: Implementation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="https://en.wikipedia.org/wiki/Computer_programming" class="extiw" title="w:Computer programming">Implementation</a> (or coding) involves turning design and planning into code. It may be the most obvious part of the software engineering job, but it is not necessarily the largest portion. In the implementation stage you should: </p> <ul><li>Create an account for your bot. Go to the <a href="/wiki/Special:CreateAccount" title="Special:CreateAccount">sign up page</a> when logged in to create the account, linking it to yours. (If you do not create the bot account while logged in, it might be blocked on some wikis according to their policies)</li> <li>Create a user page for your bot. Your bot's edits must not be made under your own account. Your bot will need its own account with its own username and password.</li> <li>Add the same information to the user page of the bot. It would be a good idea to add a link to the approval page (whether approved or not) for each function.</li> <li>Code your bot in your chosen programming language.</li></ul> <div class="mw-heading mw-heading4"><h4 id="Testing">Testing</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=17" title="Edit section: Testing"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A good way of testing your bot as you are developing is to have it show the changes (if any) it would have made to a page, rather than actually editing the live wiki. Some bot frameworks (such as <a href="/wiki/Special:MyLanguage/Manual:Pywikibot" title="Special:MyLanguage/Manual:Pywikibot">pywikibot</a>) have pre-coded methods for showing diffs. </p> <div class="mw-heading mw-heading4"><h4 id="Documentation">Documentation</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=18" title="Edit section: Documentation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>An important (and often overlooked) task is <a href="https://en.wikipedia.org/wiki/software_documentation" class="extiw" title="w:software documentation">documenting</a> the internal design of your bot for the purpose of future maintenance and enhancement. This is especially important if you are going to allow clones of your bot. Ideally, you should post the source code of your bot on its userpage or in a revision control system (see <a href="#Open-source_bots">#Open-source bots</a>) if you want others to be able to run clones of it. This code should be well documented (usually using comments) for ease of use. </p> <div class="mw-heading mw-heading4"><h4 id="Queries/Complaints"><span id="Queries.2FComplaints"></span>Queries/Complaints</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=19" title="Edit section: Queries/Complaints"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>You should be ready to respond to queries about or objections to your bot on your user talk page, especially if it is operating in a potentially sensitive area. </p> <div class="mw-heading mw-heading4"><h4 id="Maintenance">Maintenance</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=20" title="Edit section: Maintenance"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="https://en.wikipedia.org/wiki/software_maintenance" class="extiw" title="w:software maintenance">Maintaining</a> and enhancing your bot to cope with newly discovered bugs or new requirements can take far more time than the initial development of the software. Not only may it be necessary to add code that does not fit the original design, but just determining how software works at some point after it is completed may require significant effort (this is another reason to document your code as you go along). </p> <div class="mw-heading mw-heading2"><h2 id="General_guidelines_for_running_a_bot">General guidelines for running a bot</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=21" title="Edit section: General guidelines for running a bot"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In addition to the official bot policy, which covers the main points to consider when developing your bot, there are a number of more general advisory points to consider when developing your bot. </p> <div class="mw-heading mw-heading3"><h3 id="Bot_best_practices">Bot best practices</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=22" title="Edit section: Bot best practices"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li>Set a custom <a href="https://en.wikipedia.org/wiki/User_agent" class="extiw" title="w:User agent">User-Agent</a> header for your bot (per the <a href="https://meta.wikimedia.org/wiki/User-Agent_policy" class="extiw" title="meta:User-Agent policy">Wikimedia User-Agent policy</a>, if your bot will be operating on Wikimedia wikis). If you don't, your bot may encounter errors and may end up blocked at the server level.</li> <li>Use the <a href="/wiki/Special:MyLanguage/Manual:Maxlag_parameter" title="Special:MyLanguage/Manual:Maxlag parameter">maxlag parameter</a> with a maximum lag of 5 seconds. This will enable the bot to run quickly when server load is low, and throttle the bot when server load is high. <ul><li>If writing a bot in a framework that does not support maxlag, limit the total requests (read and write requests together) to no more than 10/minute.</li></ul></li> <li>Use the <a href="/wiki/Special:MyLanguage/API" title="Special:MyLanguage/API">MediaWiki API</a> whenever possible, and set the query limits to the largest values that the server permits, to minimize the total number of requests that must be made.</li> <li>Edit (write) requests are more expensive in server time than read requests. Be edit-light and design your code to keep edits to a minimum. <ul><li>Try to consolidate edits. One single large edit is better than 10 smaller ones.</li></ul></li> <li>Enable <a href="https://en.wikipedia.org/wiki/HTTP_persistent_connection" class="extiw" title="w:HTTP persistent connection">HTTP persistent connections</a> and <a href="https://en.wikipedia.org/wiki/HTTP_compression" class="extiw" title="w:HTTP compression">compression</a> in your HTTP client library, if possible.</li> <li>Do not make multi-threaded requests. Wait for one server request to complete before beginning another</li> <li>Back off upon receiving errors from the server. Errors such as timeouts are often an indication of heavy server load. Use <a href="https://en.wikipedia.org/wiki/exponential_backoff" class="extiw" title="w:exponential backoff">a sequence of increasingly longer delays between repeated requests</a>.</li> <li>Make use of <a href="/wiki/Special:MyLanguage/API:Assert" title="Special:MyLanguage/API:Assert">assertion</a> to ensure your bot is logged in.</li> <li>Test your code thoroughly before making large automated runs. Individually examine all edits on trial runs to verify they are perfect.</li></ul> <div class="mw-heading mw-heading3"><h3 id="Common_bot_features_you_should_consider_implementing">Common bot features you should consider implementing</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=23" title="Edit section: Common bot features you should consider implementing"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-heading mw-heading4"><h4 id="Manual_assistance">Manual assistance</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=24" title="Edit section: Manual assistance"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>If your bot is doing anything that requires judgment or evaluation of context (e.g., correcting spelling) then you should consider making your bot manually-assisted, which means that a human verifies all edits before they are saved. This significantly reduces the bot's speed, but it also significantly reduces errors. </p> <div class="mw-heading mw-heading4"><h4 id="Disabling_the_bot">Disabling the bot</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=25" title="Edit section: Disabling the bot"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>It is good bot policy to have a feature to disable the bot's operation if it is requested. Remember that if your bot goes bad, it is your responsibility to clean up after it! <span class="plainlinks">You could have the bot refuse to run if a message has been left on its talk page, on the assumption that the message may be a complaint against its activities; this can be checked using the API <code>meta=userinfo</code> query.</span> Example on English Wikipedia: </p> <dl><dd><div class="plainlinks" style="margin-bottom: 0.3em"><b><a class="external text" href="https://en.wikipedia.org/w/api.php?action=query&meta=userinfo&uiprop=hasmsg">api.php<span style="margin:0 0.5em">?</span><wbr />action=query<span style="margin:0 0.5em">&</span><wbr />meta=userinfo<span style="margin:0 0.5em">&</span><wbr />uiprop=hasmsg</a></b> <a class="external text" href="https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&meta=userinfo&uiprop=hasmsg">[try in ApiSandbox]</a></div></dd></dl> <p>Or you could have a page that will turn the bot off if text on the page is changed (e.g. require the page be empty, contain only the word "True", or something similar); this can be checked by loading the page contents before each edit. </p> <div class="mw-heading mw-heading4"><h4 id="Signature">Signature</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=26" title="Edit section: Signature"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Just like a human, if your bot makes edits to a talk page in MediaWiki, it should sign its post with four tildes (~~~~). Signatures usually belong <b>only</b> on talk namespaces. </p> <div class="mw-heading mw-heading4"><h4 id="Bot_Flag">Bot Flag</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=27" title="Edit section: Bot Flag"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A bot's edits will be visible at <a href="/wiki/Special:RecentChanges" title="Special:RecentChanges">Special:RecentChanges</a>, unless the edits are set to indicate a bot. Once the bot has been approved and given its bot flag permission, one can add the "bot=True" to the API call - see <a href="/wiki/Special:MyLanguage/API:Edit#Parameters" title="Special:MyLanguage/API:Edit">API:Edit</a><span style="display:none"><a href="/wiki/API:Edit#Parameters" title="API:Edit"> </a></span> in order to hide the bot's edits in <a href="/wiki/Special:RecentChanges" title="Special:RecentChanges">Special:RecentChanges</a>. </p><p> In Python, using either mwclient or wikitools, then adding <b><span style="color:#14866d" dir="ltr">Bot=True</span></b> to the edit/save command will set the edit as a bot edit - e.g. </p><div class="mw-highlight mw-highlight-lang-bash mw-content-ltr" dir="ltr"><pre><span></span>PageObject.edit<span class="o">(</span><span class="nv">text</span><span class="o">=</span>pagetext,<span class="w"> </span><span class="nv">bot</span><span class="o">=</span>True,<span class="w"> </span><span class="nv">summary</span><span class="o">=</span>pagesummary<span class="o">)</span> </pre></div> <div class="mw-heading mw-heading4"><h4 id="Monitoring_the_bot_status">Monitoring the bot status</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=28" title="Edit section: Monitoring the bot status"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>If the bot is fully automated and performs regular edits, you should periodically check it runs as specified, and its behavior has not been altered by software changes. </p> <div class="mw-heading mw-heading2"><h2 id="Open-source_bots">Open-source bots</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=29" title="Edit section: Open-source bots"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Many bot operators choose to make their code open source, and occasionally it may be required before approval for particularly complex bots. Making your code open source has several advantages: </p> <ul><li>It allows others to review your code for potential bugs. As with prose, it is often difficult for the author of code to adequately review it.</li> <li>Others can use your code to build their own bots. A user new to bot writing may be able to use your code as an example or a template for their own bots.</li> <li>It encourages good security practices, rather than <a href="https://en.wikipedia.org/wiki/security_through_obscurity" class="extiw" title="w:security through obscurity">security through obscurity</a>.</li> <li>If you leave the project, it allows other users to run your bot tasks without having to write new code.</li></ul> <p>Open-source code, while rarely required, is typically encouraged in keeping with the open and transparent nature of wikis, though there are some cases when code should not be made public. For example, the open proxy-finding code of <a href="https://en.wikipedia.org/wiki/User:ProcseeBot" class="extiw" title="w:User:ProcseeBot">ProcseeBot</a> could be used for malicious purposes on other sites. </p><p>Making code open source can add some extra work to coding. One has to make sure that sensitive information such as passwords is separated into a file that isn't made public. </p><p>There are several options available for users wishing to make their code open. Some users choose to put the code in a subpage of the bot's userspace, although this can be a hassle to maintain if not automated and results in the code being multi-licensed under the wiki's licensing terms in addition to any other terms you may specify. Another solution is to use a <a href="https://en.wikipedia.org/wiki/Revision_Control_System" class="extiw" title="w:Revision Control System">revision control system</a> such as <a href="https://en.wikipedia.org/wiki/Apache_Subversion" class="extiw" title="w:Apache Subversion">SVN</a>, <a href="https://en.wikipedia.org/wiki/Git" class="extiw" title="w:Git">Git</a>, or <a href="https://en.wikipedia.org/wiki/Mercurial" class="extiw" title="w:Mercurial">Mercurial</a>. Wikipedia has articles comparing the different <a href="https://en.wikipedia.org/wiki/Comparison_of_revision_control_software" class="extiw" title="w:Comparison of revision control software">software options</a> and <a href="https://en.wikipedia.org/wiki/Comparison_of_open_source_software_hosting_facilities" class="extiw" title="w:Comparison of open source software hosting facilities">websites for code hosting</a>, many of which have no cost. Wikimedia also offers Git code repository hosting for its users and running Wikimedia related software tools via <a href="https://wikitech.wikimedia.org/wiki/Help:Cloud_Services_introduction" class="extiw" title="wikitech:Help:Cloud Services introduction">Wikimedia Cloud Services</a>. </p> <div class="mw-heading mw-heading2"><h2 id="Programming_languages_and_libraries">Programming languages and libraries</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=30" title="Edit section: Programming languages and libraries"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <dl><dd><i>See also: <a href="/wiki/Special:MyLanguage/API:Client_code" title="Special:MyLanguage/API:Client code">API:Client code</a><span style="display:none"><a href="/wiki/API:Client_code" title="API:Client code"> </a></span></i></dd></dl> <p>Bots can be written in almost any programming language. The choice of a language often depends on the experience of the bot writer (which languages are familiar) or on the availability of pre-developed libraries to perform the desired task. The following list includes some languages that have libraries to assist with bot tasks. </p> <div class="mw-heading mw-heading4"><h4 id="Awk">Awk</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=31" title="Edit section: Awk"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li>Framework and libraries: <a href="https://en.wikipedia.org/wiki/WP:BOTWIKIAWK" class="extiw" title="w:WP:BOTWIKIAWK">BotWikiAwk</a></li> <li>Example bots in the GitHub account of <a href="/wiki/User:GreenC" title="User:GreenC">User:GreenC</a> at <a rel="nofollow" class="external text" href="https://github.com/greencardamom?tab=repositories">GitHub</a></li></ul> <div class="mw-heading mw-heading4"><h4 id="Perl">Perl</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=32" title="Edit section: Perl"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>If located on a webserver, you can start your program running and interface with your program while it is running via the <a href="https://en.wikipedia.org/wiki/Common_Gateway_Interface" class="extiw" title="w:Common Gateway Interface">w:Common Gateway Interface</a> from your browser. If your internet service provider provides you with webspace, the chances are good that you have access to a perl build on the webserver from which you can run your Perl programs. </p><p>Libraries: </p> <ul><li><a rel="nofollow" class="external text" href="https://metacpan.org/pod/MediaWiki::API">MediaWiki::API</a> – Basic interface to the API, allowing scripts to automate editing and extraction of data from MediaWiki driven sites.</li> <li><a rel="nofollow" class="external text" href="https://metacpan.org/pod/MediaWiki::Bot">MediaWiki::Bot</a> – A fairly complete MediaWiki bot framework written in Perl. Provides a higher level of abstraction than MediaWiki::API. Plugins provide administrator and steward functionality. Currently unsupported.</li></ul> <div class="mw-heading mw-heading4"><h4 id="PHP">PHP</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=33" title="Edit section: PHP"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="https://en.wikipedia.org/wiki/PHP" class="extiw" title="w:PHP">PHP</a> can also be used for programming bots. MediaWiki developers are already familiar with PHP, since that is the language MediaWiki and its extensions are written in. PHP is an especially good choice if you wish to provide a webform-based interface to your bot. For example, suppose you wanted to create a bot for renaming categories. You could create an HTML form into which you will type the current and desired names of a category. When the form is submitted, your bot could read these inputs, then edit all the articles in the current category and move them to the desired category. (Obviously, any bot with a form interface would need to be secured somehow from random web surfers.) </p><p>The <a href="https://en.wikipedia.org/wiki/Wikipedia:PHP_bot_functions" class="extiw" title="w:Wikipedia:PHP bot functions">PHP bot functions</a> table on English Wikipedia may provide some insight into the capabilities of the major bot frameworks. </p> <table class="wikitable sortable" border="1"> <caption>PHP Bot frameworks </caption> <tbody><tr> <th>Key people<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>php 1<span class="cite-bracket">]</span></a></sup></th> <th>Name</th> <th>PHP Version</th> <th>last update</th> <th>Uses API<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>php 2<span class="cite-bracket">]</span></a></sup></th> <th><a href="https://en.wikipedia.org/wiki/Template:Bots" class="extiw" title="w:Template:Bots">Exclusion compliant</a></th> <th>Admin functions</th> <th>Plugins</th> <th>Repository</th> <th>Notes </th></tr> <tr> <td><a href="https://en.wikipedia.org/wiki/User:Cyberpower678" class="extiw" title="w:User:Cyberpower678">Cyberpower678</a>, <a href="https://en.wikipedia.org/wiki/User:Addshore" class="extiw" title="w:User:Addshore">Addshore</a>, and <a href="https://en.wikipedia.org/wiki/User:Jarry1250" class="extiw" title="w:User:Jarry1250">Jarry1250</a></td> <td><a href="https://en.wikipedia.org/wiki/WP:Peachy" class="extiw" title="w:WP:Peachy">Peachy</a></td> <td>5.2.1</td> <td>2015</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td>GitHub</td> <td>Large framework, currently undergoing rewrite. Documentation currently non-existent, so poke <a href="https://en.wikipedia.org/wiki/User:Cyberpower678" class="extiw" title="w:User:Cyberpower678">w:User:Cyberpower678</a> for help. </td></tr> <tr> <td><a href="https://en.wikipedia.org/wiki/User:Addshore" class="extiw" title="w:User:Addshore">Addshore</a></td> <td><a rel="nofollow" class="external text" href="https://github.com/addwiki/mediawiki-api-base">mediawiki-api-base</a></td> <td>7.4+</td> <td>2021</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">N/A</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">N/A</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">extra libs</td> <td><a rel="nofollow" class="external text" href="https://github.com/addwiki">GitHub</a></td> <td>Base library for interaction with the mediawiki api, provides you with ways to handle logging in, out and handling tokens as well as easily getting and posting requests. </td></tr> <tr> <td><a href="https://en.wikipedia.org/wiki/User:Addshore" class="extiw" title="w:User:Addshore">Addshore</a></td> <td><a rel="nofollow" class="external text" href="https://github.com/addwiki/mediawiki-api">mediawiki-api</a></td> <td>7.4+</td> <td>2021</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">some</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">extra libs</td> <td><a rel="nofollow" class="external text" href="https://github.com/addwiki">GitHub</a></td> <td>Build on top of mediawiki-api-base this adds more advanced services for the api such as RevisionGetter, UserGetter, PageDeleter, RevisionPatroller, RevisionSaver etc. </td></tr> <tr> <td><a href="https://en.wikipedia.org/wiki/User:Kaspo" class="extiw" title="w:User:Kaspo">Kaspo</a></td> <td><a href="https://en.wikipedia.org/wiki/User:Kaspo/Phpwikibot" class="extiw" title="w:User:Kaspo/Phpwikibot">Phpwikibot</a></td> <td style="background: #E4E4E4; color: black; vertical-align: middle; text-align: center;" class="unknown table-unknown">Unknown</td> <td>2009</td> <td style="background:#FFB;vertical-align:middle;text-align:center;" class="table-partial">Partial</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td>Google Code</td> <td>Uses a single class. </td></tr> <tr> <td><a href="https://en.wikipedia.org/wiki/User:Jarry1250" class="extiw" title="w:User:Jarry1250">Jarry1250</a></td> <td><a href="https://en.wikipedia.org/wiki/User:LivingBot/Wikibot" class="extiw" title="w:User:LivingBot/Wikibot">Wikibot</a></td> <td>5</td> <td>2009</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td>enwiki</td> <td>Used solely by <a href="https://en.wikipedia.org/wiki/User:LivingBot" class="extiw" title="w:User:LivingBot">LivingBot</a>. A fork of Phpwikibot. Uses a single class. </td></tr> <tr> <td><a href="https://en.wikipedia.org/wiki/User:Foxy_Loxy" class="extiw" title="w:User:Foxy Loxy">Foxy Loxy</a></td> <td><a rel="nofollow" class="external text" href="https://pwiki.sourceforge.net/">PHPediaWiki</a></td> <td>5</td> <td>2009</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td>SourceForge</td> <td>Fork of SxWiki </td></tr> <tr> <td><a href="https://en.wikipedia.org/wiki/User:Nzhamstar" class="extiw" title="w:User:Nzhamstar">Nzhamstar</a>, <a href="https://en.wikipedia.org/wiki/User:Xymph" class="extiw" title="w:User:Xymph">Xymph</a>, <a href="https://en.wikipedia.org/wiki/User:Waldyrious" class="extiw" title="w:User:Waldyrious">Waldyrious</a></td> <td><a rel="nofollow" class="external text" href="https://github.com/hamstar/Wikimate">Wikimate</a></td> <td>5.3-5.6,<br />7.x, 8.x</td> <td>2023</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td>GitHub</td> <td>Supports main article and file stuff. Authentication, checking if pages exist, reading and editing pages/sections. Getting file information, downloading and uploading files. Aims to be easy to use. </td></tr> <tr> <td><a href="https://en.wikipedia.org/wiki/User:kalebheitzman" class="extiw" title="w:User:kalebheitzman">Kaleb Heitzman</a></td> <td><a rel="nofollow" class="external text" href="https://github.com/kalebheitzman/mediawikibot">MediaWIkiBot</a></td> <td>5</td> <td>2012</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td><a href="/wiki/GitHub" title="GitHub">GitHub</a></td> <td>Supports the entire API including uploading and importing. Also supports Semantic MediaWiki. Single Class that creates dynamic methods to work with any of the API calls. </td></tr> <tr> <td><a href="https://en.wikipedia.org/wiki/User:Edward_Z._Yang" class="extiw" title="w:User:Edward Z. Yang">Edward Z. Yang</a></td> <td><a href="https://en.wikipedia.org/wiki/User:Edward_Z._Yang/Wikipedia_Bot_in_PHP" class="extiw" title="w:User:Edward Z. Yang/Wikipedia Bot in PHP">Wikipedia Bot in PHP</a></td> <td style="background: #E4E4E4; color: black; vertical-align: middle; text-align: center;" class="unknown table-unknown">Unknown</td> <td>2005</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td>enwiki</td> <td>"Probably stale" source code </td></tr> <tr> <td><a href="https://en.wikipedia.org/wiki/User:Cobi" class="extiw" title="w:User:Cobi">Cobi</a></td> <td><a href="https://en.wikipedia.org/wiki/user:ClueBot/Source#Classes_(wikibot.classes.php)" class="extiw" title="w:user:ClueBot/Source">wikibot.classes</a></td> <td>5</td> <td>2010</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td>enwiki</td> <td>Used by multiple large bots (e.g. <a href="https://en.wikipedia.org/wiki/User:ClueBot" class="extiw" title="w:User:ClueBot">ClueBot</a> and <a href="https://en.wikipedia.org/wiki/User:SoxBot" class="extiw" title="w:User:SoxBot">SoxBot</a>). Uses several <a href="https://en.wikipedia.org/wiki/class_(programming)" class="extiw" title="w:class (programming)">classes</a>. </td></tr> <tr> <td><a href="https://meta.wikimedia.org/wiki/User:Valerio_Bozzolan" class="extiw" title="meta:User:Valerio Bozzolan">Valerio Bozzolan</a></td> <td><a rel="nofollow" class="external text" href="https://github.com/valerio-bozzolan/boz-mw/">boz-mw</a></td> <td>5.6</td> <td>2019</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">N/A</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">extra libs</td> <td>GitHub</td> <td>Object-oriented. 80+ classes also to handle Wikidata. Inline documentation. Support for file uploading. </td></tr></tbody></table> <div class="reflist" style="list-style-type: decimal;"> <div class="mw-references-wrap"><ol class="references"> <li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">Does not include those who worked on frameworks forked to create listed framework.</span> </li> <li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">Where possible. Excludes uploading images and other such tasks which are not currently supported by the API.</span> </li> </ol></div></div> <div class="mw-heading mw-heading4"><h4 id="Python">Python</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=34" title="Edit section: Python"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="https://en.wikipedia.org/wiki/Python_(programming_language)" class="extiw" title="w:Python (programming language)">Python</a> is a popular interpreted language with object-oriented features. </p> <dl><dt>Libraries</dt></dl> <dl><dd><i>Please help update this table.</i></dd></dl> <table class="wikitable sortable"> <caption>Python Bot frameworks </caption> <tbody><tr> <th>Key people<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>py 1<span class="cite-bracket">]</span></a></sup></th> <th>Name</th> <th>Python Version</th> <th>last update</th> <th>Uses API<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>py 2<span class="cite-bracket">]</span></a></sup></th> <th><a href="https://en.wikipedia.org/wiki/Template:Bots" class="extiw" title="w:Template:Bots">Exclusion compliant</a></th> <th>Admin functions</th> <th>Plugins</th> <th>Repository</th> <th>Notes </th></tr> <tr> <td><a href="/wiki/User:Xqt" title="User:Xqt">xqt</a></td> <td><a href="/wiki/Special:MyLanguage/Manual:Pywikibot" title="Special:MyLanguage/Manual:Pywikibot">Pywikibot</a><span style="display:none"><a href="/wiki/Manual:Pywikibot" title="Manual:Pywikibot"> </a></span></td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes"><a href="/wiki/Special:MyLanguage/Manual:Pywikibot/Compatibility" title="Special:MyLanguage/Manual:Pywikibot/Compatibility">Python 3.7 or higher</a><span style="display:none"><a href="/wiki/Manual:Pywikibot/Compatibility" title="Manual:Pywikibot/Compatibility"> </a></span> or PyPy</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">2023</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes </td> <td> <ul><li><a class="external text" href="https://gerrit.wikimedia.org/r/q/project:pywikibot%252Fcore">Gerrit</a></li> <li><a class="external text" href="https://phabricator.wikimedia.org/diffusion/PWBC/">Diffusion</a></li> <li><a rel="nofollow" class="external text" href="https://github.com/wikimedia/pywikibot">Github</a> (Mirror)</li> <li><a class="external text" href="https://pywikibot.toolforge.org/">Toolforge</a> (Nightly)</li> <li><a rel="nofollow" class="external text" href="https://pypi.org/project/pywikibot/">PyPI</a></li></ul> </td> <td> <p>The most used Python bot framework. Includes ready to use scripts. </p> <ul><li><a class="external text" href="https://doc.wikimedia.org/pywikibot/master/">Documentation master</a></li> <li><a class="external text" href="https://doc.wikimedia.org/pywikibot/stable/">Documentation stable</a></li></ul> </td></tr> <tr> <td><a href="/w/index.php?title=User:Myst&action=edit&redlink=1" class="new" title="User:Myst (page does not exist)">Myst</a></td> <td>WikibaseIntegrator</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Python 3.7 or higher</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">2022</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td>Not applicable</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">No</td> <td><a rel="nofollow" class="external text" href="https://github.com/LeMyst/WikibaseIntegrator">GitHub</a></td> <td>Only to interact with Wikibase instances like Wikidata </td></tr> <tr> <td><a href="/wiki/User:Mr.Z-man" title="User:Mr.Z-man">Mr.Z-man</a></td> <td>wikitools</td> <td>2</td> <td>2016</td> <td></td> <td></td> <td></td> <td></td> <td><a rel="nofollow" class="external text" href="https://github.com/alexz-enwp/wikitools">GitHub</a></td> <td>Incompatible with Python 3. (<a rel="nofollow" class="external text" href="https://pypi.python.org/pypi/wikitools">downloads</a>) </td></tr> <tr> <td><a href="https://en.wikipedia.org/wiki/User:Bryan" class="extiw" title="w:User:Bryan">Bryan</a></td> <td>mwclient</td> <td></td> <td>2021</td> <td></td> <td></td> <td></td> <td></td> <td><a rel="nofollow" class="external text" href="https://github.com/mwclient/mwclient">GitHub</a></td> <td>An API-based framework </td></tr> <tr> <td><a href="https://en.wikipedia.org/wiki/User:The_Earwig" class="extiw" title="w:User:The Earwig">The Earwig</a></td> <td>mwparserfromhell</td> <td></td> <td>2021</td> <td></td> <td></td> <td></td> <td></td> <td><a rel="nofollow" class="external text" href="https://github.com/earwig/mwparserfromhell">GitHub</a></td> <td>A Python parser for MediaWiki text </td></tr></tbody></table> <div class="reflist" style="list-style-type: decimal;"> <div class="mw-references-wrap"><ol class="references"> <li id="cite_note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a></span> <span class="reference-text">Does not include those who worked on frameworks forked to create listed framework.</span> </li> <li id="cite_note-4"><span class="mw-cite-backlink"><a href="#cite_ref-4">↑</a></span> <span class="reference-text">Where possible. Excludes uploading images and other such tasks which are not currently supported by the API.</span> </li> </ol></div></div> <div class="mw-heading mw-heading4"><h4 id="Microsoft_.NET">Microsoft .NET</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=35" title="Edit section: Microsoft .NET"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="https://en.wikipedia.org/wiki/Microsoft_.NET" class="extiw" title="w:Microsoft .NET">Microsoft .NET</a> is a set of languages including <a href="https://en.wikipedia.org/wiki/Microsoft_Visual_C_Sharp" class="extiw" title="w:Microsoft Visual C Sharp">C#</a>, <a href="https://en.wikipedia.org/wiki/C%2B%2B/CLI" class="extiw" title="w:C++/CLI">C++/CLI</a>, <a href="https://en.wikipedia.org/wiki/Visual_Basic_.NET" class="extiw" title="w:Visual Basic .NET">Visual Basic .NET</a>, <a href="https://en.wikipedia.org/wiki/J_Sharp" class="extiw" title="w:J Sharp">J#</a>, <a href="https://en.wikipedia.org/wiki/JScript_.NET" class="extiw" title="w:JScript .NET">JScript .NET</a>, <a href="https://en.wikipedia.org/wiki/IronPython" class="extiw" title="w:IronPython">IronPython</a>, and <a href="https://en.wikipedia.org/wiki/Windows_PowerShell" class="extiw" title="w:Windows PowerShell">Windows PowerShell</a>. The <a href="https://en.wikipedia.org/wiki/Microsoft_Visual_Studio" class="extiw" title="w:Microsoft Visual Studio">Microsoft Visual Studio</a> <a href="https://en.wikipedia.org/wiki/integrated_development_environment" class="extiw" title="w:integrated development environment">integrated development environment</a> is often used, or the free <a href="https://en.wikipedia.org/wiki/Microsoft_Visual_Studio_Express" class="extiw" title="w:Microsoft Visual Studio Express">Microsoft Visual Studio Express</a> versions. Using <a href="https://en.wikipedia.org/wiki/Mono_(software)" class="extiw" title="w:Mono (software)">Mono Project</a>, .NET programs can also run on <a href="https://en.wikipedia.org/wiki/Linux" class="extiw" title="w:Linux">Linux</a>, <a href="https://en.wikipedia.org/wiki/Unix" class="extiw" title="w:Unix">Unix</a>, <a href="https://en.wikipedia.org/wiki/BSD" class="extiw" title="w:BSD">BSD</a>, <a href="https://en.wikipedia.org/wiki/Solaris" class="extiw" title="w:Solaris">Solaris</a> and <a href="https://en.wikipedia.org/wiki/Mac_OS_X" class="extiw" title="w:Mac OS X">Mac OS X</a> as well as under <a href="https://en.wikipedia.org/wiki/Windows" class="extiw" title="w:Windows">Windows</a>. </p><p>Libraries: </p> <ul><li><a rel="nofollow" class="external text" href="https://dotnetwikibot.sourceforge.net/">DotNetWikiBot Framework</a> – a full-featured client <a href="/wiki/API" class="mw-disambig" title="API">API</a> on .NET, that allows to build programs and web robots easily to manage information on MediaWiki-powered sites. Now translated to several languages. Detailed compiled documentation is available in English.</li> <li><a rel="nofollow" class="external text" href="https://sourceforge.net/projects/autowikibrowser/files/">WikiFunctions .NET library</a> – Bundled with <a href="https://en.wikipedia.org/wiki/WP:AWB" class="extiw" title="w:WP:AWB">AWB</a>, is a library of stuff useful for bots, such as generating lists, loading/editing articles, connecting to the recent changes IRC channel and more.</li></ul> <div class="mw-heading mw-heading4"><h4 id="Java">Java</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=36" title="Edit section: Java"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="https://en.wikipedia.org/wiki/Java_(programming_language)" class="extiw" title="w:Java (programming language)">Java</a> programs are generally developed with an IDE, such as <a href="https://en.wikipedia.org/wiki/Eclipse_(software)" class="extiw" title="w:Eclipse (software)">Eclipse</a> or <a href="https://en.wikipedia.org/wiki/NetBeans" class="extiw" title="w:NetBeans">NetBeans</a>; development using a command line console (with the <a href="https://en.wikipedia.org/wiki/javac" class="extiw" title="w:javac">javac</a> and java programs) is also an option. </p><p>Libraries: </p> <ul><li><a rel="nofollow" class="external text" href="https://github.com/eldur/jwbf">Java Wiki Bot Framework</a> – A Java wiki bot framework</li> <li><a rel="nofollow" class="external text" href="https://github.com/mer-c/wiki-java">wiki-java</a> – A Java wiki bot framework that is only one file</li> <li><a rel="nofollow" class="external text" href="https://github.com/WPCleaner/wpcleaner">WPCleaner</a> – The library used by the WPCleaner tool</li> <li><a rel="nofollow" class="external text" href="https://github.com/fastily/jwiki">jwiki</a> – A simple and easy-to-use Java wiki bot framework</li></ul> <div class="mw-heading mw-heading4"><h4 id="JavaScript_(Node.js)"><span id="JavaScript_.28Node.js.29"></span>JavaScript (Node.js)</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=37" title="Edit section: JavaScript (Node.js)"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="https://en.wikipedia.org/wiki/JavaScript" class="extiw" title="w:JavaScript">JavaScript</a> is a <a href="https://en.wikipedia.org/wiki/scripting_language" class="extiw" title="w:scripting language">scripting language</a> used mainly on web pages, such as for user scripts added to <a href="/wiki/Special:MyPage/vector.js" title="Special:MyPage/vector.js">your vector.js</a> or <a href="/wiki/Special:MyPage/monobook.js" title="Special:MyPage/monobook.js">your monobook.js</a> pages. Using <a href="https://en.wikipedia.org/wiki/Node.js" class="extiw" title="w:Node.js">Node.js</a> it is possible to use JavaScript server-side, such as for developing bots. </p> <dl><dd><i>Please help to update this table.</i></dd></dl> <table class="wikitable sortable" border="1"> <caption>NodeJS Bot frameworks </caption> <tbody><tr> <th>Key people<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>js 1<span class="cite-bracket">]</span></a></sup></th> <th>Name</th> <th>Nodejs Version</th> <th>last update</th> <th>Uses API<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>js 2<span class="cite-bracket">]</span></a></sup></th> <th><a href="https://en.wikipedia.org/wiki/Template:Bots" class="extiw" title="w:Template:Bots">Exclusion compliant</a></th> <th>Admin functions</th> <th>Package</th> <th>Repository</th> <th>Notes </th></tr> <tr> <td><a href="https://en.wikipedia.org/wiki/User:SD0001" class="extiw" title="en:User:SD0001">SD0001</a></td> <td>mwn</td> <td>10+</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">2021</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td><a rel="nofollow" class="external text" href="https://www.npmjs.com/package/mwn">npm</a></td> <td><a rel="nofollow" class="external text" href="https://github.com/siddharthvp/mwn">GitHub</a></td> <td>Large library with classes for working with page titles and wikitext. Works with <a href="/wiki/TypeScript" title="TypeScript">TypeScript</a> also. Promise-based API (<code>async</code>–<code>await</code>). Limited wikitext parsing capabilities. </td></tr> <tr> <td><a href="/wiki/User:Kanashimi" title="User:Kanashimi">kanashimi</a></td> <td>wikiapi</td> <td>0.10–15.x</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">2021</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#9F9;vertical-align:middle;text-align:center;" class="table-yes">Yes</td> <td style="background:#FFB;vertical-align:middle;text-align:center;" class="table-partial">Partial</td> <td><a rel="nofollow" class="external text" href="https://www.npmjs.com/package/wikiapi">npm</a></td> <td><a rel="nofollow" class="external text" href="https://github.com/kanasimi/wikiapi">GitHub</a></td> <td>JavaScript MediaWiki API for node.js with modern <a href="https://en.wikipedia.org/wiki/en:ECMAScript_2016" class="extiw" title="w:en:ECMAScript 2016">ECMAScript 2016</a> <code>async</code>–<code>await</code> and <a rel="nofollow" class="external text" href="https://kanasimi.github.io/CeJS/_test%20suite/wikitext_parser.html">wikitext parser</a>. </td></tr> <tr> <td></td> <td>MediaWiki module</td> <td></td> <td style="background:#F99;vertical-align:middle;text-align:center;" class="table-no">2014</td> <td></td> <td></td> <td></td> <td></td> <td><a rel="nofollow" class="external text" href="https://github.com/oliver-moran/mediawiki">GitHub</a></td> <td>Provides a <a href="https://en.wikipedia.org/wiki/Software_framework" class="extiw" title="w:Software framework">framework</a> of standard requests (e.g. log in, log out, etc.) as well as a general wrapper method for the MediaWiki API and includes throttling. The module can also be added to your Wikimedia .js page and used as library for on-wiki JS calls. </td></tr></tbody></table> <div class="reflist" style="list-style-type: decimal;"> <div class="mw-references-wrap"><ol class="references"> <li id="cite_note-5"><span class="mw-cite-backlink"><a href="#cite_ref-5">↑</a></span> <span class="reference-text">Does not include those who worked on frameworks forked to create listed framework.</span> </li> <li id="cite_note-6"><span class="mw-cite-backlink"><a href="#cite_ref-6">↑</a></span> <span class="reference-text">Where possible. Excludes uploading images and other such tasks which are not currently supported by the API.</span> </li> </ol></div></div> <div class="mw-heading mw-heading4"><h4 id="Ruby">Ruby</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=38" title="Edit section: Ruby"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="https://en.wikipedia.org/wiki/Ruby_(programming_language)" class="extiw" title="w:Ruby (programming language)">Ruby</a> is a popular <a href="https://en.wikipedia.org/wiki/dynamic_programming_language" class="extiw" title="w:dynamic programming language">dynamic</a>, <a href="https://en.wikipedia.org/wiki/object-oriented_programming_language" class="extiw" title="w:object-oriented programming language">object-oriented</a> programming language. </p><p>Libraries: </p> <ul><li><a rel="nofollow" class="external text" href="https://github.com/ftb-gamepedia/mediawiki-butt-ruby">MediaWiki::Butt</a> - Ruby framework for the API in active development. Tested with versions as up-to-date as CurseGamepedia is.</li> <li><a rel="nofollow" class="external text" href="https://github.com/wikimedia/mediawiki-ruby-api">mediawiki/ruby/api</a>, Ruby API client library. Last updated December 2017, no longer maintained, but still works.</li> <li><a rel="nofollow" class="external text" href="https://github.com/jpatokal/mediawiki-gateway">MediaWiki::Gateway</a> – Ruby framework for the API. Last updated January 2016. No longer in active development, tested up to MediaWiki 1.22, compatible with Wikimedia wikis. Unknown if still works.</li> <li><a rel="nofollow" class="external text" href="https://github.com/kenpratt/wikipedia-client">wikipedia-client</a> - Ruby framework using the API. Last updated March 2018. Unknown if still works.</li></ul> <div class="mw-heading mw-heading4"><h4 id="Common_Lisp">Common Lisp</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=39" title="Edit section: Common Lisp"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li><a rel="nofollow" class="external text" href="https://www.cliki.net/CL-MediaWiki">CL-MediaWiki</a> implements MediaWiki API as a <a href="https://en.wikipedia.org/wiki/Common_Lisp" class="extiw" title="w:Common Lisp">Common Lisp</a> package. Is planned to use <a href="https://en.wikipedia.org/wiki/JSON" class="extiw" title="w:JSON">JSON</a> as a query data format. Supports maxlag and assertion.</li></ul> <div class="mw-heading mw-heading4"><h4 id="Haskell">Haskell</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=40" title="Edit section: Haskell"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li><a rel="nofollow" class="external free" href="https://hackage.haskell.org/package/mediawiki">https://hackage.haskell.org/package/mediawiki</a></li></ul> <div class="mw-heading mw-heading4"><h4 id="VBScript">VBScript</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=41" title="Edit section: VBScript"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="https://en.wikipedia.org/wiki/VBScript" class="extiw" title="w:VBScript">VBScript</a> is a <a href="https://en.wikipedia.org/wiki/scripting_language" class="extiw" title="w:scripting language">scripting language</a> based on the <a href="https://en.wikipedia.org/wiki/Visual_Basic" class="extiw" title="w:Visual Basic">Visual Basic</a> programming language. There are no published bot frameworks for VBScript, but some examples of bots that use it can be seen below: </p><p>Examples: </p> <ul><li><a href="https://en.wikipedia.org/wiki/User:Smallman12q/Scripts/cleanuplistingtowiki" class="extiw" title="w:User:Smallman12q/Scripts/cleanuplistingtowiki">w:User:Smallman12q/Scripts/cleanuplistingtowiki</a> (2013) - Login and give preview of edit</li> <li><a href="https://en.wikipedia.org/wiki/User:Smallman12q/VBS/Savewatchlist" class="extiw" title="w:User:Smallman12q/VBS/Savewatchlist">w:User:Smallman12q/VBS/Savewatchlist</a> (2012) - Login, get raw watchlist, save to file, logout, close IE</li> <li><a href="https://en.wikipedia.org/wiki/Commons:User:Smallbot#Sources" class="extiw" title="w:Commons:User:Smallbot">w:Commons:User:Smallbot#Sources</a> - Several scripts showing the usage of VBScript (JavaScript, XMLHTTP, MSHTML, XMLDOM, COM) for batch uploads.</li></ul> <div class="mw-heading mw-heading4"><h4 id="Bash">Bash</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Manual:Creating_a_bot&action=edit&section=42" title="Edit section: Bash"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="https://en.wikipedia.org/wiki/Bash_(Unix_shell)" class="extiw" title="w:Bash (Unix shell)">Bash</a> is a <a href="https://en.wikipedia.org/wiki/Unix_shell" class="extiw" title="w:Unix shell">Unix shell</a>. </p> <ul><li>See <a href="/wiki/Special:MyLanguage/API:Client_code/Bash" title="Special:MyLanguage/API:Client code/Bash">API:Client_code/Bash</a><span style="display:none"><a href="/wiki/API:Client_code/Bash" title="API:Client code/Bash"> </a></span>. Requires <a href="https://en.wikipedia.org/wiki/cURL" class="extiw" title="w:cURL">cURL</a> package.</li></ul> <!-- NewPP limit report Parsed by mw‐api‐int.codfw.main‐849f99967d‐m9zdp Cached time: 20241122114215 Cache expiry: 2592000 Reduced expiry: false Complications: [show‐toc] CPU time usage: 0.371 seconds Real time usage: 0.487 seconds Preprocessor visited node count: 2715/1000000 Post‐expand include size: 18347/2097152 bytes Template argument size: 4211/2097152 bytes Highest expansion depth: 15/100 Expensive parser function count: 17/500 Unstrip recursion depth: 0/20 Unstrip post‐expand size: 7591/5000000 bytes Lua time usage: 0.052/10.000 seconds Lua memory usage: 1598825/52428800 bytes Number of Wikibase entities loaded: 0/400 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 216.791 1 -total 34.54% 74.871 10 Template:Ll 21.25% 46.059 1 Template:Notice 20.24% 43.880 1 Template:Ambox 13.82% 29.971 20 Template:Translatable 10.57% 22.907 11 Template:Pagelang 7.25% 15.726 1 Template:Tip 6.45% 13.979 37 Template:Yes 6.42% 13.917 1 Template:Note 5.53% 11.979 4 Template:ApiEx --> <!-- Saved in parser cache with key mediawikiwiki:pcache:idhash:308701-0!canonical and timestamp 20241122114215 and revision id 6845346. Rendering was triggered because: api-parse --> </div><!--esi <esi:include src="/esitest-fa8a495983347898/content" /> --><noscript><img src="https://login.wikimedia.org/wiki/Special:CentralAutoLogin/start?type=1x1" alt="" width="1" height="1" style="border: none; position: absolute;"></noscript> <div class="printfooter" data-nosnippet="">Retrieved from "<a dir="ltr" href="https://www.mediawiki.org/w/index.php?title=Manual:Creating_a_bot&oldid=6845346">https://www.mediawiki.org/w/index.php?title=Manual:Creating_a_bot&oldid=6845346</a>"</div></div> <div id="catlinks" class="catlinks" data-mw="interface"><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="/wiki/Special:Categories" title="Special:Categories">Category</a>: <ul><li><a href="/wiki/Category:Bots" title="Category:Bots">Bots</a></li></ul></div></div> </div> </main> </div> <div class="mw-footer-container"> <footer id="footer" class="mw-footer" > <ul id="footer-info"> <li id="footer-info-lastmod"> This page was last edited on 8 November 2024, at 11:23.</li> <li id="footer-info-copyright">Text is available under the <a rel="nofollow" class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-ShareAlike License</a>; additional terms may apply. Text in <a class="external text" href="https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents">the Help: namespace</a> is available under the <a rel="nofollow" class="external text" href="https://creativecommons.org/publicdomain/zero/1.0/">Creative Commons CC0 License</a>. By using this site, you agree to the <a class="external text" href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Terms_of_Use">Terms of Use</a> and <a class="external text" href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy">Privacy Policy</a>.</li> </ul> <ul id="footer-places"> <li id="footer-places-privacy"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy">Privacy policy</a></li> <li id="footer-places-about"><a href="/wiki/Project:About">About mediawiki.org</a></li> <li id="footer-places-disclaimers"><a href="/wiki/Project:General_disclaimer">Disclaimers</a></li> <li id="footer-places-wm-codeofconduct"><a href="https://www.mediawiki.org/wiki/Special:MyLanguage/Code_of_Conduct">Code of Conduct</a></li> <li id="footer-places-developers"><a href="https://developer.wikimedia.org">Developers</a></li> <li id="footer-places-statslink"><a href="https://stats.wikimedia.org/#/www.mediawiki.org">Statistics</a></li> <li id="footer-places-cookiestatement"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement">Cookie statement</a></li> <li id="footer-places-mobileview"><a href="//m.mediawiki.org/w/index.php?title=Manual:Creating_a_bot&mobileaction=toggle_view_mobile" class="noprint stopMobileRedirectToggle">Mobile view</a></li> </ul> <ul id="footer-icons" class="noprint"> <li id="footer-copyrightico"><a href="https://wikimediafoundation.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><img src="/static/images/footer/wikimedia-button.svg" width="84" height="29" alt="Wikimedia Foundation" loading="lazy"></a></li> <li id="footer-poweredbyico"><a href="https://www.mediawiki.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><img src="/w/resources/assets/poweredby_mediawiki.svg" alt="Powered by MediaWiki" width="88" height="31" loading="lazy"></a></li> </ul> </footer> </div> </div> </div> <div class="vector-settings" id="p-dock-bottom"> <ul></ul> </div><script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgHostname":"mw-web.codfw.main-f69cdc8f6-5zrpf","wgBackendResponseTime":113,"wgPageParseReport":{"limitreport":{"cputime":"0.371","walltime":"0.487","ppvisitednodes":{"value":2715,"limit":1000000},"postexpandincludesize":{"value":18347,"limit":2097152},"templateargumentsize":{"value":4211,"limit":2097152},"expansiondepth":{"value":15,"limit":100},"expensivefunctioncount":{"value":17,"limit":500},"unstrip-depth":{"value":0,"limit":20},"unstrip-size":{"value":7591,"limit":5000000},"entityaccesscount":{"value":0,"limit":400},"timingprofile":["100.00% 216.791 1 -total"," 34.54% 74.871 10 Template:Ll"," 21.25% 46.059 1 Template:Notice"," 20.24% 43.880 1 Template:Ambox"," 13.82% 29.971 20 Template:Translatable"," 10.57% 22.907 11 Template:Pagelang"," 7.25% 15.726 1 Template:Tip"," 6.45% 13.979 37 Template:Yes"," 6.42% 13.917 1 Template:Note"," 5.53% 11.979 4 Template:ApiEx"]},"scribunto":{"limitreport-timeusage":{"value":"0.052","limit":"10.000"},"limitreport-memusage":{"value":1598825,"limit":52428800}},"cachereport":{"origin":"mw-api-int.codfw.main-849f99967d-m9zdp","timestamp":"20241122114215","ttl":2592000,"transientcontent":false}}});});</script> </body> </html>