CINXE.COM
Wikidata:Creating a bot - Wikidata
<!DOCTYPE html> <html class="client-nojs" lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <title>Wikidata:Creating a bot - Wikidata</title> <script>(function(){var className="client-js";var cookie=document.cookie.match(/(?:^|; )wikidatawikimwclientpreferences=([^;]+)/);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":"e2362afc-9b32-4304-96b2-9d91db767259","wgCanonicalNamespace":"Project","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":4,"wgPageName":"Wikidata:Creating_a_bot","wgTitle":"Creating a bot","wgCurRevisionId":2033204669,"wgRevisionId":2033204669,"wgArticleId":7399363,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":[ "*"],"wgCategories":["Wikidata:Bots","Pywikibot tutorial","Wikidata:Creating a bot","Wikidata-en"],"wgPageViewLanguage":"en","wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Wikidata:Creating_a_bot","wgRelevantArticleId":7399363,"wgIsProbablyEditable":true,"wgRelevantPageIsProbablyEditable":true,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgNoticeProject":"wikidata","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":30000,"wgTranslatePageTranslation":"source","wgCentralAuthMobileDomain":false,"wgEditSubmitButtonLabelPublish":true,"wgDiscussionToolsFeaturesEnabled":{"replytool":true,"newtopictool":true,"sourcemodetoolbar":true,"topicsubscription": false,"autotopicsub":false,"visualenhancements":false,"visualenhancements_reply":false,"visualenhancements_pageframe":false},"wgDiscussionToolsFallbackEditMode":"source","wgULSPosition":"personal","wgULSisCompactLinksEnabled":true,"wgVector2022LanguageInHeader":false,"wgULSisLanguageSelectorEmpty":false,"wgWikibaseItemId":"Q9384748","wgCheckUserClientHintsHeadersJsApi":["architecture","bitness","brands","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.discussionTools.init.styles":"ready","oojs-ui-core.styles":"ready","oojs-ui.styles.indicators":"ready","mediawiki.widgets.styles":"ready","oojs-ui-core.icons":"ready","skins.vector.styles.legacy":"ready","jquery.makeCollapsible.styles":"ready","ext.translate.edit.documentation.styles":"ready", "ext.translate":"ready","ext.visualEditor.desktopArticleTarget.noscript":"ready","codex-search-styles":"ready","ext.uls.pt":"ready","wikibase.client.init":"ready","ext.wikimediaBadges":"ready"};RLPAGEMODULES=["ext.pygments.view","site","mediawiki.page.ready","jquery.makeCollapsible","mediawiki.toc","skins.vector.legacy.js","wikibase.ui.entitysearch","ext.centralNotice.geoIP","ext.centralNotice.startUp","ext.translate.pagetranslation.uls","ext.gadget.Search","ext.gadget.ProtectionIndicators","ext.gadget.imagelinks","ext.gadget.NewSection","ext.gadget.formWizard","ext.urlShortener.toolbar","ext.centralauth.centralautologin","mmv.bootstrap","ext.visualEditor.desktopArticleTarget.init","ext.visualEditor.targetLoader","ext.echo.centralauth","ext.discussionTools.init","ext.eventLogging","ext.wikimediaEvents","ext.wikimediaEvents.wikibase","ext.navigationTiming","ext.uls.compactlinks","ext.uls.interface","ext.checkUser.clientHints","wikibase.sidebar.tracking"];</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=codex-search-styles%7Cext.discussionTools.init.styles%7Cext.pygments%2Ctranslate%2CwikimediaBadges%7Cext.translate.edit.documentation.styles%7Cext.translate.tag.languages%7Cext.uls.pt%7Cext.visualEditor.desktopArticleTarget.noscript%7Cjquery.makeCollapsible.styles%7Cmediawiki.widgets.styles%7Coojs-ui-core.icons%2Cstyles%7Coojs-ui.styles.indicators%7Cskins.vector.styles.legacy%7Cwikibase.client.init&only=styles&skin=vector"> <script async="" src="/w/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector"></script> <meta name="ResourceLoaderDynamicStyles" content=""> <link rel="stylesheet" href="/w/load.php?lang=en&modules=site.styles&only=styles&skin=vector"> <meta name="generator" content="MediaWiki 1.44.0-wmf.3"> <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"> <link rel="preconnect" href="//upload.wikimedia.org"> <link rel="alternate" media="only screen and (max-width: 640px)" href="//m.wikidata.org/wiki/Wikidata:Creating_a_bot"> <link rel="alternate" type="application/x-wiki" title="Edit" href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit"> <link rel="apple-touch-icon" href="/static/apple-touch/wikidata.png"> <link rel="icon" href="/static/favicon/wikidata.ico"> <link rel="search" type="application/opensearchdescription+xml" href="/w/rest.php/v1/search" title="Wikidata (en)"> <link rel="EditURI" type="application/rsd+xml" href="//www.wikidata.org/w/api.php?action=rsd"> <link rel="canonical" href="https://www.wikidata.org/wiki/Wikidata:Creating_a_bot"> <link rel="license" href="/wiki/Wikidata:Copyright"> <link rel="alternate" type="application/atom+xml" title="Wikidata 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="ext-discussiontools-replytool-enabled ext-discussiontools-newtopictool-enabled ext-discussiontools-sourcemodetoolbar-enabled skin-vector-legacy mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-4 ns-subject mw-editable page-Wikidata_Creating_a_bot rootpage-Wikidata_Creating_a_bot skin-vector action-view"><div id="mw-page-base" class="noprint"></div> <div id="mw-head-base" class="noprint"></div> <div id="content" class="mw-body" role="main"> <a id="top"></a> <div id="siteNotice"><!-- CentralNotice --></div> <div class="mw-indicators"> </div> <h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-namespace">Wikidata</span><span class="mw-page-title-separator">:</span><span class="mw-page-title-main">Creating a bot</span></h1> <div id="bodyContent" class="vector-body"> <div id="siteSub" class="noprint">From Wikidata</div> <div id="contentSub"><div id="mw-content-subtitle"></div></div> <div id="contentSub2"></div> <div id="jump-to-nav"></div> <a class="mw-jump-link" href="#mw-head">Jump to navigation</a> <a class="mw-jump-link" href="#searchInput">Jump to search</a> <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-Wikidata%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">Other languages:</div><ul class="mw-pt-languages-list"><li><a href="/wiki/Wikidata:Creating_a_bot/id" class="mw-pt-progress mw-pt-progress--low" title="Wikidata:Creating a bot/id (2% translated)" lang="id" dir="ltr">Bahasa Indonesia</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/en-gb" class="mw-pt-progress mw-pt-progress--med" title="Wikidata:Creating a bot (22% translated)" lang="en-GB" dir="ltr">British English</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/de" class="mw-pt-progress mw-pt-progress--high" title="Wikidata:Einen Bot erstellen (98% 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/Wikidata:Creating_a_bot/eo" class="mw-pt-progress mw-pt-progress--low" title="Vikidatumoj:Kreado de roboto (5% translated)" lang="eo" dir="ltr">Esperanto</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/fy" class="mw-pt-progress mw-pt-progress--low" title="Wikidata:Creating a bot/fy (5% translated)" lang="fy" dir="ltr">Frysk</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/lb" class="mw-pt-progress mw-pt-progress--low" title="Wikidata:Creating a bot/lb (10% translated)" lang="lb" dir="ltr">Lëtzebuergesch</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/nl" class="mw-pt-progress mw-pt-progress--complete" title="Wikidata:Aanmaken van een bot (100% translated)" lang="nl" dir="ltr">Nederlands</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/ksh" class="mw-pt-progress mw-pt-progress--low" title="Wikidata:Creating a bot/ksh (2% translated)" lang="ksh" dir="ltr">Ripoarisch</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/diq" class="mw-pt-progress mw-pt-progress--med" title="Wikidata:Bot vıraşten (22% translated)" lang="diq" dir="ltr">Zazaki</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/ca" class="mw-pt-progress mw-pt-progress--low" title="Wikidata:Creating a bot/ca (11% translated)" lang="ca" dir="ltr">català</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/da" class="mw-pt-progress mw-pt-progress--med" title="Wikidata:Lav en bot (64% translated)" lang="da" dir="ltr">dansk</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/es" class="mw-pt-progress mw-pt-progress--high" title="Wikidata:Creación de un bot (72% translated)" lang="es" dir="ltr">español</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/fr" class="mw-pt-progress mw-pt-progress--complete" title="Wikidata:Créer un robot (100% translated)" lang="fr" dir="ltr">français</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/it" class="mw-pt-progress mw-pt-progress--med" title="Wikidata:Creare un bot (31% translated)" lang="it" dir="ltr">italiano</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/lv" class="mw-pt-progress mw-pt-progress--med" title="Wikidata:Bota izveide (34% translated)" lang="lv" dir="ltr">latviešu</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/lt" class="mw-pt-progress mw-pt-progress--low" title="Vikidata:Boto sukūrimas (4% translated)" lang="lt" dir="ltr">lietuvių</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/hu" class="mw-pt-progress mw-pt-progress--med" title="Wikidata:Botok létrehozása (32% translated)" lang="hu" dir="ltr">magyar</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/oc" class="mw-pt-progress mw-pt-progress--med" title="Wikidata:Crear un robòt (19% translated)" lang="oc" dir="ltr">occitan</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/pl" class="mw-pt-progress mw-pt-progress--med" title="Wikidata:Tworzenie bota (53% translated)" lang="pl" dir="ltr">polski</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/pt" class="mw-pt-progress mw-pt-progress--med" title="Wikidados:Criar um robô (27% translated)" lang="pt" dir="ltr">português</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/pt-br" class="mw-pt-progress mw-pt-progress--low" title="Wikidata:Criando um robô (8% translated)" lang="pt-BR" dir="ltr">português do Brasil</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/fi" class="mw-pt-progress mw-pt-progress--low" title="Wikidata:Botin luonti (11% translated)" lang="fi" dir="ltr">suomi</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/sv" class="mw-pt-progress mw-pt-progress--med" title="Wikidata:Skapa en bot (21% translated)" lang="sv" dir="ltr">svenska</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/cs" class="mw-pt-progress mw-pt-progress--low" title="Wikidata:Creating a bot/cs (9% translated)" lang="cs" dir="ltr">čeština</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/szl" class="mw-pt-progress mw-pt-progress--low" title="Wikidata:Creating a bot/szl (1% translated)" lang="szl" dir="ltr">ślůnski</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/el" class="mw-pt-progress mw-pt-progress--med" title="Wikidata:Δημιουργία μποτ (19% translated)" lang="el" dir="ltr">Ελληνικά</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/bg" class="mw-pt-progress mw-pt-progress--med" title="Уикиданни:Създаване на бот (19% translated)" lang="bg" dir="ltr">български</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/ru" class="mw-pt-progress mw-pt-progress--high" title="Викиданные: Создание бота (82% translated)" lang="ru" dir="ltr">русский</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/uk" class="mw-pt-progress mw-pt-progress--med" title="Вікідані:Створення бота (58% translated)" lang="uk" dir="ltr">українська</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/hy" class="mw-pt-progress mw-pt-progress--low" title="Wikidata:Creating a bot/hy (7% translated)" lang="hy" dir="ltr">հայերեն</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/ar" class="mw-pt-progress mw-pt-progress--high" title="ويكي بيانات:إنشاء بوت (78% translated)" lang="ar" dir="rtl">العربية</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/fa" class="mw-pt-progress mw-pt-progress--low" title="Wikidata:ایجاد یک ربات (2% translated)" lang="fa" dir="rtl">فارسی</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/gu" class="mw-pt-progress mw-pt-progress--low" title="વિકિડેટા:બોટ બનાવવું (2% translated)" lang="gu" dir="ltr">ગુજરાતી</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/ta" class="mw-pt-progress mw-pt-progress--low" title="விக்கித்தரவு:தானியங்கியை உருவாக்கல் (8% translated)" lang="ta" dir="ltr">தமிழ்</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/te" class="mw-pt-progress mw-pt-progress--low" title="Wikidata:Creating a bot/te (2% translated)" lang="te" dir="ltr">తెలుగు</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/ml" class="mw-pt-progress mw-pt-progress--low" title="Wikidata:Creating a bot/ml (2% translated)" lang="ml" dir="ltr">മലയാളം</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/th" class="mw-pt-progress mw-pt-progress--low" title="วิกิสนเทศ:สร้างบอท (9% translated)" lang="th" dir="ltr">ไทย</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/zh" class="mw-pt-progress mw-pt-progress--med" title="维基数据:制作一个机器人 (44% translated)" lang="zh" dir="ltr">中文</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/ja" class="mw-pt-progress mw-pt-progress--med" title="Wikidata:ボットの作成 (62% translated)" lang="ja" dir="ltr">日本語</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/yue" class="mw-pt-progress mw-pt-progress--low" title="維基數據:整一個機械人 (9% translated)" lang="yue" dir="ltr">粵語</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/nan" class="mw-pt-progress mw-pt-progress--low" title="Wikidata:Kiàn-li̍p chi̍t chiah ke-khì-lâng (5% translated)" lang="nan" dir="ltr">閩南語 / Bân-lâm-gú</a></li> <li><a href="/wiki/Wikidata:Creating_a_bot/ko" class="mw-pt-progress mw-pt-progress--med" title="Wikidata:봇 만들기 (19% translated)" lang="ko" dir="ltr">한국어</a></li></ul></div> <p>This page explains <b>how to create <a href="/wiki/Special:MyLanguage/Wikidata:Bots" title="Special:MyLanguage/Wikidata:Bots">bots</a></b> for Wikidata. Please, consider sharing your code, add new examples and any improvements you want. </p> <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#Requirements"><span class="tocnumber">1</span> <span class="toctext">Requirements</span></a></li> <li class="toclevel-1 tocsection-2"><a href="#Recommendation"><span class="tocnumber">2</span> <span class="toctext">Recommendation</span></a></li> <li class="toclevel-1 tocsection-3"><a href="#Pywikibot"><span class="tocnumber">3</span> <span class="toctext">Pywikibot</span></a> <ul> <li class="toclevel-2 tocsection-4"><a href="#Installation"><span class="tocnumber">3.1</span> <span class="toctext">Installation</span></a></li> <li class="toclevel-2 tocsection-5"><a href="#Configuration"><span class="tocnumber">3.2</span> <span class="toctext">Configuration</span></a></li> <li class="toclevel-2 tocsection-6"><a href="#Login"><span class="tocnumber">3.3</span> <span class="toctext">Login</span></a></li> <li class="toclevel-2 tocsection-7"><a href="#Example_1:_Get_data"><span class="tocnumber">3.4</span> <span class="toctext">Example 1: Get data</span></a> <ul> <li class="toclevel-3 tocsection-8"><a href="#Alternatives"><span class="tocnumber">3.4.1</span> <span class="toctext">Alternatives</span></a></li> </ul> </li> <li class="toclevel-2 tocsection-9"><a href="#Example_2:_Get_interwiki_links"><span class="tocnumber">3.5</span> <span class="toctext">Example 2: Get interwiki links</span></a></li> <li class="toclevel-2 tocsection-10"><a href="#Example_4:_Set_a_description"><span class="tocnumber">3.6</span> <span class="toctext">Example 4: Set a description</span></a></li> <li class="toclevel-2 tocsection-11"><a href="#Example_6:_Set_a_sitelink"><span class="tocnumber">3.7</span> <span class="toctext">Example 6: Set a sitelink</span></a></li> <li class="toclevel-2 tocsection-12"><a href="#Example_7:_Set_a_statement"><span class="tocnumber">3.8</span> <span class="toctext">Example 7: Set a statement</span></a></li> <li class="toclevel-2 tocsection-13"><a href="#Example_8:_Add_a_qualifier"><span class="tocnumber">3.9</span> <span class="toctext">Example 8: Add a qualifier</span></a></li> <li class="toclevel-2 tocsection-14"><a href="#Example_9:_Add_a_source"><span class="tocnumber">3.10</span> <span class="toctext">Example 9: Add a source</span></a></li> <li class="toclevel-2 tocsection-15"><a href="#Example_10:_Page_generators"><span class="tocnumber">3.11</span> <span class="toctext">Example 10: Page generators</span></a></li> <li class="toclevel-2 tocsection-16"><a href="#Example_11:_Get_values_of_sub-properties"><span class="tocnumber">3.12</span> <span class="toctext">Example 11: Get values of sub-properties</span></a></li> <li class="toclevel-2 tocsection-17"><a href="#More_examples"><span class="tocnumber">3.13</span> <span class="toctext">More examples</span></a></li> </ul> </li> <li class="toclevel-1 tocsection-18"><a href="#Wikidata_Integrator"><span class="tocnumber">4</span> <span class="toctext">Wikidata Integrator</span></a> <ul> <li class="toclevel-2 tocsection-19"><a href="#Example_Notebook"><span class="tocnumber">4.1</span> <span class="toctext">Example Notebook</span></a></li> </ul> </li> <li class="toclevel-1 tocsection-20"><a href="#WikibaseIntegrator"><span class="tocnumber">5</span> <span class="toctext">WikibaseIntegrator</span></a> <ul> <li class="toclevel-2 tocsection-21"><a href="#Example_semi-automatic_script"><span class="tocnumber">5.1</span> <span class="toctext">Example semi-automatic script</span></a></li> </ul> </li> <li class="toclevel-1 tocsection-22"><a href="#Wikibase.NET_(Deprecated)"><span class="tocnumber">6</span> <span class="toctext">Wikibase.NET (Deprecated)</span></a> <ul> <li class="toclevel-2 tocsection-23"><a href="#Download_&_Installation"><span class="tocnumber">6.1</span> <span class="toctext">Download & Installation</span></a></li> <li class="toclevel-2 tocsection-24"><a href="#Known_issues"><span class="tocnumber">6.2</span> <span class="toctext">Known issues</span></a></li> <li class="toclevel-2 tocsection-25"><a href="#Examples"><span class="tocnumber">6.3</span> <span class="toctext">Examples</span></a></li> </ul> </li> <li class="toclevel-1 tocsection-26"><a href="#DotNetDataBot_(Deprecated)"><span class="tocnumber">7</span> <span class="toctext">DotNetDataBot (Deprecated)</span></a> <ul> <li class="toclevel-2 tocsection-27"><a href="#Installation_2"><span class="tocnumber">7.1</span> <span class="toctext">Installation</span></a></li> <li class="toclevel-2 tocsection-28"><a href="#Configuration_2"><span class="tocnumber">7.2</span> <span class="toctext">Configuration</span></a></li> <li class="toclevel-2 tocsection-29"><a href="#Login_2"><span class="tocnumber">7.3</span> <span class="toctext">Login</span></a></li> <li class="toclevel-2 tocsection-30"><a href="#Example_1:_Get_id_using_wiki_page"><span class="tocnumber">7.4</span> <span class="toctext">Example 1: Get id using wiki page</span></a></li> <li class="toclevel-2 tocsection-31"><a href="#Example_2:_Get_interwiki_links_2"><span class="tocnumber">7.5</span> <span class="toctext">Example 2: Get interwiki links</span></a></li> <li class="toclevel-2 tocsection-32"><a href="#Example_3:_Set_a_description"><span class="tocnumber">7.6</span> <span class="toctext">Example 3: Set a description</span></a></li> <li class="toclevel-2 tocsection-33"><a href="#Example_4:_Set_a_label"><span class="tocnumber">7.7</span> <span class="toctext">Example 4: Set a label</span></a></li> <li class="toclevel-2 tocsection-34"><a href="#Example_5:_Get_interwiki_links_for_100_pages"><span class="tocnumber">7.8</span> <span class="toctext">Example 5: Get interwiki links for 100 pages</span></a></li> </ul> </li> <li class="toclevel-1 tocsection-35"><a href="#Wikibase_api_for_PHP"><span class="tocnumber">8</span> <span class="toctext">Wikibase api for PHP</span></a> <ul> <li class="toclevel-2 tocsection-36"><a href="#Example_1:_Basic_example"><span class="tocnumber">8.1</span> <span class="toctext">Example 1: Basic example</span></a></li> <li class="toclevel-2 tocsection-37"><a href="#Example_2:_Creating_claims"><span class="tocnumber">8.2</span> <span class="toctext">Example 2: Creating claims</span></a></li> </ul> </li> <li class="toclevel-1 tocsection-38"><a href="#VBot_(no_updates_since_2017)"><span class="tocnumber">9</span> <span class="toctext">VBot (no updates since 2017)</span></a> <ul> <li class="toclevel-2 tocsection-39"><a href="#Overview"><span class="tocnumber">9.1</span> <span class="toctext">Overview</span></a></li> <li class="toclevel-2 tocsection-40"><a href="#Download"><span class="tocnumber">9.2</span> <span class="toctext">Download</span></a></li> <li class="toclevel-2 tocsection-41"><a href="#Instruction"><span class="tocnumber">9.3</span> <span class="toctext">Instruction</span></a></li> <li class="toclevel-2 tocsection-42"><a href="#Example_1"><span class="tocnumber">9.4</span> <span class="toctext">Example 1</span></a></li> </ul> </li> <li class="toclevel-1 tocsection-43"><a href="#LexData_(Python;_for_Lexicographical_data)"><span class="tocnumber">10</span> <span class="toctext">LexData (Python; for Lexicographical data)</span></a> <ul> <li class="toclevel-2 tocsection-44"><a href="#Tips"><span class="tocnumber">10.1</span> <span class="toctext">Tips</span></a></li> <li class="toclevel-2 tocsection-45"><a href="#Installation_3"><span class="tocnumber">10.2</span> <span class="toctext">Installation</span></a></li> <li class="toclevel-2 tocsection-46"><a href="#Login_3"><span class="tocnumber">10.3</span> <span class="toctext">Login</span></a></li> <li class="toclevel-2 tocsection-47"><a href="#Retrieve_a_Lexeme"><span class="tocnumber">10.4</span> <span class="toctext">Retrieve a Lexeme</span></a></li> <li class="toclevel-2 tocsection-48"><a href="#Searching_and_creating_Lexemes"><span class="tocnumber">10.5</span> <span class="toctext">Searching and creating Lexemes</span></a></li> <li class="toclevel-2 tocsection-49"><a href="#Adding_information"><span class="tocnumber">10.6</span> <span class="toctext">Adding information</span></a></li> </ul> </li> <li class="toclevel-1 tocsection-50"><a href="#Using_Wikidata's_API_directly"><span class="tocnumber">11</span> <span class="toctext">Using Wikidata's API directly</span></a> <ul> <li class="toclevel-2 tocsection-51"><a href="#Example_1:_Get_Q_number"><span class="tocnumber">11.1</span> <span class="toctext">Example 1: Get Q number</span></a> <ul> <li class="toclevel-3 tocsection-52"><a href="#Python"><span class="tocnumber">11.1.1</span> <span class="toctext">Python</span></a></li> </ul> </li> <li class="toclevel-2 tocsection-53"><a href="#Example_2:_Get_list_of_items_without_particular_interwiki"><span class="tocnumber">11.2</span> <span class="toctext">Example 2: Get list of items without particular interwiki</span></a></li> </ul> </li> <li class="toclevel-1 tocsection-54"><a href="#See_also"><span class="tocnumber">12</span> <span class="toctext">See also</span></a></li> <li class="toclevel-1 tocsection-55"><a href="#External_links"><span class="tocnumber">13</span> <span class="toctext">External links</span></a></li> </ul> </div> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="Requirements" data-mw-thread-id="h-Requirements"><span data-mw-comment-start="" id="h-Requirements"></span>Requirements<span data-mw-comment-end="h-Requirements"></span></h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=1" title="Edit section: Requirements"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Requirements","replies":[]}}--></div> <p>To create bots you need: </p> <ul><li>Some coding skills (Python, Perl, PHP...)</li> <li>A framework (one of the frameworks below) and some code to run to complete a task</li> <li>A bot account (and <a href="/wiki/Wikidata:Requests_for_permissions/Bot" title="Wikidata:Requests for permissions/Bot">approved</a>)</li> <li>A source code editor (Notepad++, Geany, vim, emacs)</li></ul> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="Recommendation" data-mw-thread-id="h-Recommendation"><span data-mw-comment-start="" id="h-Recommendation"></span>Recommendation<span data-mw-comment-end="h-Recommendation"></span></h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=2" title="Edit section: Recommendation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Recommendation","replies":[]}}--></div> <ul><li>Join a <a class="external text" href="https://meta.wikimedia.org/wiki/Telegram#Wikidata">Wikidata telegram channel</a> and participate in the discussions (and ask for help if you get stuck programming).</li></ul> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="Pywikibot" data-mw-thread-id="h-Pywikibot"><span data-mw-comment-start="" id="h-Pywikibot"></span>Pywikibot<span data-mw-comment-end="h-Pywikibot"></span></h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=3" title="Edit section: Pywikibot"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Pywikibot","replies":["h-Installation-Pywikibot","h-Configuration-Pywikibot","h-Login-Pywikibot","h-Example_1:_Get_data-Pywikibot","h-Example_2:_Get_interwiki_links-Pywikibot","h-Example_4:_Set_a_description-Pywikibot","h-Example_6:_Set_a_sitelink-Pywikibot","h-Example_7:_Set_a_statement-Pywikibot","h-Example_8:_Add_a_qualifier-Pywikibot","h-Example_9:_Add_a_source-Pywikibot","h-Example_10:_Page_generators-Pywikibot","h-Example_11:_Get_values_of_sub-properties-Pywikibot","h-More_examples-Pywikibot"]}}--></div> <style data-mw-deduplicate="TemplateStyles:r2202362292">.mw-parser-output th.mbox-text,.mw-parser-output td.mbox-text{border:none;padding:0.25em 0.9em;width:100%}.mw-parser-output td.mbox-image{border:none;padding:2px 0 2px 0.9em;text-align:center}.mw-parser-output td.mbox-imageright{border:none;padding:2px 0.9em 2px 0;text-align:center}.mw-parser-output td.mbox-empty-cell{border:none;padding:0;width:1px}.mw-parser-output table.ambox{margin:0 10%;border:1px solid var(--border-color-base,#a2a9b1);border-left:10px solid var(--border-color-progressive,#36c);background-color:var(--background-color-interactive-subtle,#f8f9fa);box-sizing:border-box}.mw-parser-output table.ambox+table.ambox{margin-top:-1px}.mw-parser-output .ambox th.mbox-text,.mw-parser-output .ambox td.mbox-text{padding:0.25em 0.5em}.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:10px solid var(--border-color-progressive,#36c)}.mw-parser-output table.ambox-speedy{border-left:10px solid var(--border-color-error,#b32424);background-color:#fee7e6}.mw-parser-output table.ambox-delete{border-left:10px solid var(--border-color-error,#b32424)}.mw-parser-output table.ambox-content{border-left:10px solid #f28500}.mw-parser-output table.ambox-style{border-left:10px solid var(--border-color-content-removed,#fc3)}.mw-parser-output table.ambox-move{border-left:10px solid #9932cc}.mw-parser-output table.ambox-protection{border-left:10px solid var(--border-color-base,#a2a9b1)}.mw-parser-output table.imbox{margin:4px 10%;border-collapse:collapse;border:3px solid var(--border-color-progressive,#36c);background-color:var(--background-color-neutral-subtle,#f8f9fa);box-sizing:border-box}.mw-parser-output .imbox .mbox-text .imbox{margin:0 -0.5em;display:block}.mw-parser-output .mbox-inside .imbox{margin:4px}.mw-parser-output table.imbox-notice{border:3px solid var(--border-color-progressive,#36c)}.mw-parser-output table.imbox-speedy{border:3px solid var(--border-color-error,#b32424);background-color:#fee7e6}.mw-parser-output table.imbox-delete{border:3px solid var(--border-color-error,#b32424)}.mw-parser-output table.imbox-content{border:3px solid #f28500}.mw-parser-output table.imbox-style{border:3px solid var(--border-color-content-removed,#fc3)}.mw-parser-output table.imbox-move{border:3px solid #9932cc}.mw-parser-output table.imbox-protection{border:3px solid var(--border-color-base,#a2a9b1)}.mw-parser-output table.imbox-license{border:3px solid #88a;background-color:#f7f8ff}.mw-parser-output table.imbox-featured{border:3px solid #cba135}.mw-parser-output table.cmbox{margin:3px 10%;border-collapse:collapse;border:1px solid var(--border-color-base,#a2a9b1);background-color:#dfe8ff;box-sizing:border-box}.mw-parser-output table.cmbox-notice{background-color:#d8e8ff}.mw-parser-output table.cmbox-speedy{margin-top:4px;margin-bottom:4px;border:4px solid var(--border-color-error,#b32424);background-color:#ffdbdb}.mw-parser-output table.cmbox-delete{background-color:#ffdbdb}.mw-parser-output table.cmbox-content{background-color:#ffe7ce}.mw-parser-output table.cmbox-style{background-color:#fff9db}.mw-parser-output table.cmbox-move{background-color:#e4d8ff}.mw-parser-output table.cmbox-protection{background-color:#efefe1}.mw-parser-output table.ombox{margin:4px 10%;border-collapse:collapse;border:1px solid var(--border-color-base,#a2a9b1);background-color:var(--background-color-neutral-subtle,#f8f9fa);box-sizing:border-box}.mw-parser-output table.ombox-notice{border:1px solid var(--border-color-base,#a2a9b1)}.mw-parser-output table.ombox-speedy{border:2px solid var(--border-color-error,#b32424);background-color:#fee7e6}.mw-parser-output table.ombox-delete{border:2px solid var(--border-color-error,#b32424)}.mw-parser-output table.ombox-content{border:1px solid #f28500}.mw-parser-output table.ombox-style{border:1px solid var(--border-color-content-removed,#fc3)}.mw-parser-output table.ombox-move{border:1px solid #9932cc}.mw-parser-output table.ombox-protection{border:2px solid var(--border-color-base,#a2a9b1)}.mw-parser-output table.tmbox{margin:4px 10%;border-collapse:collapse;border:1px solid var(--border-color-base,#a2a9b1);background-color:var(--background-color-neutral-subtle,#f8f9fa);min-width:80%;box-sizing:border-box}.mw-parser-output .tmbox.mbox-small{min-width:0}.mw-parser-output .mediawiki .mbox-inside .tmbox{margin:2px 0;width:100%}.mw-parser-output .mbox-inside .tmbox.mbox-small{line-height:1.5em;font-size:100%}.mw-parser-output table.tmbox-speedy{border:2px solid var(--border-color-error,#b32424);background-color:#fee7e6}.mw-parser-output table.tmbox-delete{border:2px solid var(--border-color-error,#b32424)}.mw-parser-output table.tmbox-content{border:2px solid #f28500}.mw-parser-output table.tmbox-style{border:2px solid var(--border-color-content-removed,#fc3)}.mw-parser-output table.tmbox-move{border:2px solid #9932cc}.mw-parser-output table.tmbox-protection{border:1px solid #c0c090}.mw-parser-output table.fmbox{clear:both;margin:0.2em 0;width:100%;border:1px solid var(--border-color-base,#a2a9b1);background-color:var(--background-color-neutral-subtle,#f8f9fa);box-sizing:border-box}.mw-parser-output table.fmbox-system{background-color:var(--background-color-neutral-subtle,#f8f9fa)}.mw-parser-output table.fmbox-warning{border:1px solid #bb7070;background-color:#ffdbdb}.mw-parser-output table.fmbox-editnotice{background-color:transparent}html body.mediawiki .mw-parser-output .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 .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="plainlinks ombox ombox-style" role="presentation"><tbody><tr><td class="mbox-image"><bdi lang="en"><span typeof="mw:File"><a href="/wiki/File:OOjs_UI_icon_notice-warning.svg" class="mw-file-description"><img alt="Warning" src="//upload.wikimedia.org/wikipedia/commons/thumb/4/4c/OOjs_UI_icon_notice-warning.svg/40px-OOjs_UI_icon_notice-warning.svg.png" decoding="async" width="40" height="40" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/4/4c/OOjs_UI_icon_notice-warning.svg/60px-OOjs_UI_icon_notice-warning.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/4/4c/OOjs_UI_icon_notice-warning.svg/80px-OOjs_UI_icon_notice-warning.svg.png 2x" data-file-width="20" data-file-height="20"/></a></span></bdi></td><td class="mbox-text"><bdi lang="en"><strong>Warning:</strong></bdi> This bot framework has incomplete support of lexemes as of June 2022. See other libraries below for full support.</td></tr></tbody></table> <p>In the following sections, you will learn how to install, configure and login using <b>pywikibot</b>. You only need to do these first three steps once. Also, there are some basic examples which are useful for learning the basics about bot programming. </p> <div class="mw-heading mw-heading3"><h3 id="Installation" data-mw-thread-id="h-Installation-Pywikibot"><span data-mw-comment-start="" id="h-Installation-Pywikibot"></span>Installation<span data-mw-comment-end="h-Installation-Pywikibot"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=4" title="Edit section: Installation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <dl><dd><i>For further details about pywikibot installation, see <a href="https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Pywikibot/Installation" class="extiw" title="mw:Special:MyLanguage/Manual:Pywikibot/Installation">Manual:Pywikibot/Installation</a> and <a href="/wiki/Wikidata:Pywikibot_-_Python_3_Tutorial/Setting_up_Shop" title="Wikidata:Pywikibot - Python 3 Tutorial/Setting up Shop">Wikidata:Pywikibot - Python 3 Tutorial/Setting up Shop</a></i></dd> <dd><i>To use pywikibot without installation, see <a href="https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Pywikibot/PAWS" class="extiw" title="mw:Special:MyLanguage/Manual:Pywikibot/PAWS">Manual:Pywikibot/PAWS</a></i></dd></dl> <p>To install pywikibot: </p> <ul><li>Install <a rel="nofollow" class="external text" href="https://www.python.org/downloads/">Python</a> (Python v3.5.2 or higher is required)</li> <li>Download pywikibot: <ul><li>As a <a class="external text" href="https://pywikibot.toolforge.org/">zip file</a></li> <li>Or using the git repository: <a href="https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Pywikibot/Gerrit" class="extiw" title="mw:Special:MyLanguage/Manual:Pywikibot/Gerrit">Manual:Pywikibot/Gerrit</a></li></ul></li></ul> <div class="mw-heading mw-heading3"><h3 id="Configuration" data-mw-thread-id="h-Configuration-Pywikibot"><span data-mw-comment-start="" id="h-Configuration-Pywikibot"></span>Configuration<span data-mw-comment-end="h-Configuration-Pywikibot"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=5" title="Edit section: Configuration"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <dl><dd><i>For further details about pywikibot configuration, see <a href="https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Pywikibot/user-config.py" class="extiw" title="mw:Special:MyLanguage/Manual:Pywikibot/user-config.py">Manual:Pywikibot/user-config.py</a>.</i></dd></dl> <p>You must configure <code>user-config.py</code> file with the bot username, family project and language. For Wikidata both family and language parameters are the same, <code>wikidata</code>. </p> <style data-mw-deduplicate="TemplateStyles:r2241526210">.mw-parser-output .navbox{border:1px solid var(--border-color-base,#a2a9b1);width:100%;margin:auto;clear:both;font-size:88%;text-align:center;padding:1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output th.navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.8em;border-color:#fdfdfd}.mw-parser-output .navbox th,.mw-parser-output .navbox-title{background:#ccccff}.mw-parser-output .navbox-abovebelow,.mw-parser-output th.navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background:#ddddff}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background:#e6e6ff}.mw-parser-output .navbox-even{background:#f7f7f7}.mw-parser-output .navbox-odd{background:transparent}.mw-parser-output table.navbox+table.navbox{margin-top:-1px}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output ol+table.navbox,.mw-parser-output ul+table.navbox{margin-top:0.5em}</style><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="n">mylang</span> <span class="o">=</span> <span class="s2">"wikidata"</span> <span class="n">family</span> <span class="o">=</span> <span class="s2">"wikidata"</span> <span class="n">usernames</span><span class="p">[</span><span class="s2">"wikidata"</span><span class="p">][</span><span class="s2">"wikidata"</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'MyBotName'</span> </pre></div> </td></tr></tbody></table></div> <p>You can reduce the delay between edits by adding: <code>put_throttle = 1</code> </p> <div class="mw-heading mw-heading3"><h3 id="Login" data-mw-thread-id="h-Login-Pywikibot"><span data-mw-comment-start="" id="h-Login-Pywikibot"></span>Login<span data-mw-comment-end="h-Login-Pywikibot"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=6" title="Edit section: Login"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>After you configure the <code>user-config.py</code> file, login as follows: </p> <div class="mw-highlight mw-highlight-lang-shell-session mw-content-ltr" dir="ltr"><pre><span></span><span class="gp">$ </span>python<span class="w"> </span>login.py </pre></div> <p>It will ask you for <a href="/wiki/Special:BotPasswords" title="Special:BotPasswords">your bot password</a>, insert it and press enter. You should be logged in now. </p> <div class="mw-heading mw-heading3"><h3 id="Example_1:_Get_data" data-mw-thread-id="h-Example_1:_Get_data-Pywikibot"><span data-mw-comment-start="" id="h-Example_1:_Get_data-Pywikibot"></span>Example 1: Get data<span data-mw-comment-end="h-Example_1:_Get_data-Pywikibot"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=7" title="Edit section: Example 1: Get data"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>This example gets data for the page referring to Douglas Adams. Save the following source code in a file and execute it with <kbd>python example1.py</kbd> </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="kn">import</span> <span class="nn">pywikibot</span> <span class="n">site</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">Site</span><span class="p">(</span><span class="s2">"en"</span><span class="p">,</span> <span class="s2">"wikipedia"</span><span class="p">)</span> <span class="n">page</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">Page</span><span class="p">(</span><span class="n">site</span><span class="p">,</span> <span class="s1">'Douglas Adams'</span><span class="p">)</span> <span class="n">item</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">ItemPage</span><span class="o">.</span><span class="n">fromPage</span><span class="p">(</span><span class="n">page</span><span class="p">)</span> <span class="n">dictionary</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">get</span><span class="p">()</span> <span class="nb">print</span><span class="p">(</span><span class="n">dictionary</span><span class="p">)</span> <span class="nb">print</span><span class="p">(</span><span class="n">dictionary</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> <span class="nb">print</span><span class="p">(</span><span class="n">item</span><span class="p">)</span> </pre></div> </td></tr></tbody></table></div> <p><code>item.get()</code> connects to Wikidata and fetches the data. The output is (reformatted for clarity): </p> <dl><dd><div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="p">{</span> <span class="s1">'claims'</span><span class="p">:</span> <span class="p">{</span> <span class="s1">'P646'</span><span class="p">:</span> <span class="p">[</span><span class="o"><</span><span class="n">pywikibot</span><span class="o">.</span><span class="n">page</span><span class="o">.</span><span class="n">Claim</span> <span class="n">instance</span> <span class="n">at</span> <span class="mh">0x7f1880188b48</span><span class="o">></span><span class="p">],</span> <span class="s1">'P800'</span><span class="p">:</span> <span class="p">[</span><span class="o"><</span><span class="n">pywikibot</span><span class="o">.</span><span class="n">page</span><span class="o">.</span><span class="n">Claim</span> <span class="n">instance</span> <span class="n">at</span> <span class="mh">0x7f1880188488</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">pywikibot</span><span class="o">.</span><span class="n">page</span><span class="o">.</span><span class="n">Claim</span> <span class="n">instance</span> <span class="n">at</span> <span class="mh">0x7f1880188368</span><span class="o">></span><span class="p">]</span> <span class="o">...</span> <span class="p">}</span> <span class="s1">'labels'</span><span class="p">:</span> <span class="p">{</span> <span class="s1">'gu'</span><span class="p">:</span> <span class="s1">'</span><span class="se">\u0aa1\u0a97\u0acd\u0ab2\u0abe\u0ab8</span><span class="s1"> </span><span class="se">\u0a8f\u0aa1\u0aae\u0acd\u0ab8</span><span class="s1">'</span><span class="p">,</span> <span class="s1">'scn'</span><span class="p">:</span> <span class="s1">'Douglas Adams'</span><span class="p">,</span> <span class="o">...</span> <span class="p">}</span> <span class="s1">'sitelinks'</span><span class="p">:</span> <span class="p">{</span> <span class="s1">'fiwiki'</span><span class="p">:</span> <span class="s1">'Douglas Adams'</span><span class="p">,</span> <span class="s1">'fawiki'</span><span class="p">:</span> <span class="s1">'</span><span class="se">\u062f\u0627\u06af\u0644\u0627\u0633</span><span class="s1"> </span><span class="se">\u0622\u062f\u0627\u0645\u0632</span><span class="s1">'</span><span class="p">,</span> <span class="s1">'elwikiquote'</span><span class="p">:</span> <span class="s1">'</span><span class="se">\u039d\u03c4\u03ac\u03b3\u03ba\u03bb\u03b1\u03c2</span><span class="s1"> </span><span class="se">\u0386\u03bd\u03c4\u03b1\u03bc\u03c2</span><span class="s1">'</span><span class="p">,</span> <span class="o">...</span> <span class="p">}</span> <span class="s1">'descriptions'</span><span class="p">:</span> <span class="p">{</span> <span class="s1">'eo'</span><span class="p">:</span> <span class="s1">'angla a</span><span class="se">\u016d</span><span class="s1">toro de sciencfikcio-romanoj kaj humoristo'</span><span class="p">,</span> <span class="s1">'en'</span><span class="p">:</span> <span class="s1">'English writer and humorist'</span><span class="p">,</span> <span class="p">},</span> <span class="s1">'aliases'</span><span class="p">:</span> <span class="p">{</span> <span class="s1">'ru'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'</span><span class="se">\u0410\u0434\u0430\u043c\u0441</span><span class="s1">, </span><span class="se">\u0414\u0443\u0433\u043b\u0430\u0441</span><span class="s1">'</span><span class="p">],</span> <span class="s1">'fr'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'Douglas Noel Adams'</span><span class="p">,</span> <span class="s1">'Douglas No</span><span class="se">\xeb</span><span class="s1">l Adams'</span><span class="p">],</span> <span class="o">...</span> <span class="p">}</span> <span class="p">}</span> <span class="p">[</span><span class="s1">'claims'</span><span class="p">,</span> <span class="s1">'labels'</span><span class="p">,</span> <span class="s1">'sitelinks'</span><span class="p">,</span> <span class="s1">'descriptions'</span><span class="p">,</span> <span class="s1">'aliases'</span><span class="p">]</span> <span class="p">[[</span><span class="n">wikidata</span><span class="p">:</span><span class="n">Q42</span><span class="p">]]</span> </pre></div></dd></dl> <p>It prints a dictionary with keys for </p> <ul><li>the set of claims in the page: <a href="/wiki/Property:P646" title="Property:P646">Property:P646</a> is the Freebase identifier, <a href="/wiki/Property:P800" title="Property:P800">Property:P800</a> is "notable work", etc.</li> <li>the label of the item in many languages</li> <li>the sitelinks for the item, not just Wikipedias in many languages, but also Wikiquote in many languages</li> <li>the item description in many languages</li> <li>the aliases for the item in many languages</li></ul> <p>Then a list with all the keys for the key-values pairs in the dictionary. Finally, you can see that the Wikidata item about Douglas Adams is <a href="/wiki/Q42" title="Q42">Q42</a>. </p> <div class="mw-heading mw-heading4"><h4 id="Alternatives" data-mw-thread-id="h-Alternatives-Example_1:_Get_data"><span data-mw-comment-start="" id="h-Alternatives-Example_1:_Get_data"></span>Alternatives<span data-mw-comment-end="h-Alternatives-Example_1:_Get_data"></span></h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=8" title="Edit section: Alternatives"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The example above gets the ItemPage using the en wikipedia article. Alternatively, we can also get the ItemPage directly: </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="kn">import</span> <span class="nn">pywikibot</span> <span class="n">site</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">Site</span><span class="p">(</span><span class="s2">"wikidata"</span><span class="p">,</span> <span class="s2">"wikidata"</span><span class="p">)</span> <span class="n">repo</span> <span class="o">=</span> <span class="n">site</span><span class="o">.</span><span class="n">data_repository</span><span class="p">()</span> <span class="n">item</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">ItemPage</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s1">'Q42'</span><span class="p">)</span> </pre></div> </td></tr></tbody></table></div> <div class="mw-heading mw-heading3"><h3 id="Example_2:_Get_interwiki_links" data-mw-thread-id="h-Example_2:_Get_interwiki_links-Pywikibot"><span data-mw-comment-start="" id="h-Example_2:_Get_interwiki_links-Pywikibot"></span>Example 2: Get interwiki links<span data-mw-comment-end="h-Example_2:_Get_interwiki_links-Pywikibot"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=9" title="Edit section: Example 2: Get interwiki links"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>After item.get(), for example the sitelinks can be accessed. These are links to all Wikipedias that have the article. </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="kn">import</span> <span class="nn">pywikibot</span> <span class="n">site</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">Site</span><span class="p">(</span><span class="s2">"wikidata"</span><span class="p">,</span> <span class="s2">"wikidata"</span><span class="p">)</span> <span class="n">repo</span> <span class="o">=</span> <span class="n">site</span><span class="o">.</span><span class="n">data_repository</span><span class="p">()</span> <span class="n">item</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">ItemPage</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s1">'Q42'</span><span class="p">)</span> <span class="n">item</span><span class="o">.</span><span class="n">get</span><span class="p">()</span> <span class="nb">print</span><span class="p">(</span><span class="s2">","</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">sitelinks</span><span class="p">))</span> </pre></div> </td></tr></tbody></table></div> <p>The output is: </p> <dl><dd><code>{'fiwiki': 'Douglas Adams', 'eowiki': 'Douglas Adams', 'dewiki': 'Douglas Adams', ...}</code></dd></dl> <p>With item.iterlinks(), an iterator over all these sitelinks is returned, where each article is given not as plain text as above but already as a Page object for further treatment (e.g., edit the text in the corresponding Wikipedia articles). </p> <div class="mw-heading mw-heading3"><h3 id="Example_4:_Set_a_description" data-mw-thread-id="h-Example_4:_Set_a_description-Pywikibot"><span data-mw-comment-start="" id="h-Example_4:_Set_a_description-Pywikibot"></span>Example 4: Set a description<span data-mw-comment-end="h-Example_4:_Set_a_description-Pywikibot"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=10" title="Edit section: Example 4: Set a description"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>This example sets an English and a German description for the item about Douglas Adams. </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="kn">import</span> <span class="nn">pywikibot</span> <span class="n">site</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">Site</span><span class="p">(</span><span class="s2">"wikidata"</span><span class="p">,</span> <span class="s2">"wikidata"</span><span class="p">)</span> <span class="n">repo</span> <span class="o">=</span> <span class="n">site</span><span class="o">.</span><span class="n">data_repository</span><span class="p">()</span> <span class="n">item</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">ItemPage</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s1">'Q42'</span><span class="p">)</span> <span class="n">item</span><span class="o">.</span><span class="n">get</span><span class="p">()</span> <span class="n">mydescriptions</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'en'</span><span class="p">:</span> <span class="s1">'English writer and humorist'</span><span class="p">,</span> <span class="s1">'de'</span><span class="p">:</span> <span class="s1">'Keine Panik!'</span><span class="p">}</span> <span class="n">item</span><span class="o">.</span><span class="n">editDescriptions</span><span class="p">(</span><span class="n">mydescriptions</span><span class="p">,</span> <span class="n">summary</span><span class="o">=</span><span class="s1">'Setting/updating descriptions.'</span><span class="p">)</span> </pre></div> </td></tr></tbody></table></div> <p>Setting labels and aliases works accordingly. </p> <div class="mw-heading mw-heading3"><h3 id="Example_6:_Set_a_sitelink" data-mw-thread-id="h-Example_6:_Set_a_sitelink-Pywikibot"><span data-mw-comment-start="" id="h-Example_6:_Set_a_sitelink-Pywikibot"></span>Example 6: Set a sitelink<span data-mw-comment-end="h-Example_6:_Set_a_sitelink-Pywikibot"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=11" title="Edit section: Example 6: Set a sitelink"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>To set a sitelink, we can either create a corresponding dict corresponding to Example 4 or use Page objects: </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="kn">import</span> <span class="nn">pywikibot</span> <span class="n">site</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">Site</span><span class="p">(</span><span class="s2">"en"</span><span class="p">,</span> <span class="s2">"wikipedia"</span><span class="p">)</span> <span class="n">repo</span> <span class="o">=</span> <span class="n">site</span><span class="o">.</span><span class="n">data_repository</span><span class="p">()</span> <span class="n">item</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">ItemPage</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s1">'Q42'</span><span class="p">)</span> <span class="n">page</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">Page</span><span class="p">(</span><span class="n">site</span><span class="p">,</span> <span class="s1">'Douglas Adams'</span><span class="p">)</span> <span class="n">item</span><span class="o">.</span><span class="n">setSitelink</span><span class="p">(</span><span class="n">page</span><span class="p">,</span> <span class="n">summary</span><span class="o">=</span><span class="s1">'Setting (/updating?) sitelink.'</span><span class="p">)</span> </pre></div> </td></tr></tbody></table></div> <div class="mw-heading mw-heading3"><h3 id="Example_7:_Set_a_statement" data-mw-thread-id="h-Example_7:_Set_a_statement-Pywikibot"><span data-mw-comment-start="" id="h-Example_7:_Set_a_statement-Pywikibot"></span>Example 7: Set a statement<span data-mw-comment-end="h-Example_7:_Set_a_statement-Pywikibot"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=12" title="Edit section: Example 7: Set a statement"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Statements are set using the Claim class. In the following, we set for Douglas Adams <a href="/wiki/Property:P19" title="Property:P19">place of birth <small dir="ltr">(P19)</small></a>: <a href="/wiki/Q350" title="Q350">Cambridge <small>(Q350)</small></a>. </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="kn">import</span> <span class="nn">pywikibot</span> <span class="n">site</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">Site</span><span class="p">(</span><span class="s2">"wikidata"</span><span class="p">,</span> <span class="s2">"wikidata"</span><span class="p">)</span> <span class="n">repo</span> <span class="o">=</span> <span class="n">site</span><span class="o">.</span><span class="n">data_repository</span><span class="p">()</span> <span class="n">item</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">ItemPage</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s1">'Q42'</span><span class="p">)</span> <span class="n">claim</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">Claim</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s1">'P19'</span><span class="p">)</span> <span class="n">target</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">ItemPage</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s1">'Q350'</span><span class="p">)</span> <span class="n">claim</span><span class="o">.</span><span class="n">setTarget</span><span class="p">(</span><span class="n">target</span><span class="p">)</span> <span class="n">item</span><span class="o">.</span><span class="n">addClaim</span><span class="p">(</span><span class="n">claim</span><span class="p">,</span> <span class="n">summary</span><span class="o">=</span><span class="s1">'Adding claim'</span><span class="p">)</span> </pre></div> </td></tr></tbody></table></div> <p>For other datatypes, this works similar. In the following, we add claims with string (<a href="/wiki/Property:P345" title="Property:P345">IMDb ID <small dir="ltr">(P345)</small></a>) and coordinate (<a href="/wiki/Property:P625" title="Property:P625">coordinate location <small dir="ltr">(P625)</small></a>) datatypes (URL is the same as string): </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="kn">import</span> <span class="nn">pywikibot</span> <span class="n">site</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">Site</span><span class="p">(</span><span class="s2">"wikidata"</span><span class="p">,</span> <span class="s2">"wikidata"</span><span class="p">)</span> <span class="n">repo</span> <span class="o">=</span> <span class="n">site</span><span class="o">.</span><span class="n">data_repository</span><span class="p">()</span> <span class="n">item</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">ItemPage</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s1">'Q42'</span><span class="p">)</span> <span class="n">stringclaim</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">Claim</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s1">'P345'</span><span class="p">)</span> <span class="n">stringclaim</span><span class="o">.</span><span class="n">setTarget</span><span class="p">(</span><span class="s1">'nm0010930'</span><span class="p">)</span> <span class="n">item</span><span class="o">.</span><span class="n">addClaim</span><span class="p">(</span><span class="n">stringclaim</span><span class="p">,</span> <span class="n">summary</span><span class="o">=</span><span class="s1">'Adding string claim'</span><span class="p">)</span> <span class="n">coordinateclaim</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">Claim</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s1">'P625'</span><span class="p">)</span> <span class="n">coordinate</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">Coordinate</span><span class="p">(</span><span class="n">lat</span><span class="o">=</span><span class="mf">52.208</span><span class="p">,</span> <span class="n">lon</span><span class="o">=</span><span class="mf">0.1225</span><span class="p">,</span> <span class="n">precision</span><span class="o">=</span><span class="mf">0.001</span><span class="p">,</span> <span class="n">site</span><span class="o">=</span><span class="n">site</span><span class="p">)</span> <span class="n">coordinateclaim</span><span class="o">.</span><span class="n">setTarget</span><span class="p">(</span><span class="n">coordinate</span><span class="p">)</span> <span class="n">item</span><span class="o">.</span><span class="n">addClaim</span><span class="p">(</span><span class="n">coordinateclaim</span><span class="p">,</span> <span class="n">summary</span><span class="o">=</span><span class="s1">'Adding coordinate claim'</span><span class="p">)</span> </pre></div> </td></tr></tbody></table></div> <div class="mw-heading mw-heading3"><h3 id="Example_8:_Add_a_qualifier" data-mw-thread-id="h-Example_8:_Add_a_qualifier-Pywikibot"><span data-mw-comment-start="" id="h-Example_8:_Add_a_qualifier-Pywikibot"></span>Example 8: Add a qualifier<span data-mw-comment-end="h-Example_8:_Add_a_qualifier-Pywikibot"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=13" title="Edit section: Example 8: Add a qualifier"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Qualifiers are also represented by the Claim class. In the following, we add the qualifier <a href="/wiki/Property:P678" title="Property:P678">incertae sedis <small dir="ltr">(P678)</small></a>: <a href="/wiki/Q35409" title="Q35409">family <small>(Q35409)</small></a> to the Claim "claim". Make sure you add the item before adding the qualifier. </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="n">qualifier</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">Claim</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s1">'P678'</span><span class="p">)</span> <span class="n">target</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">ItemPage</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s2">"Q35409"</span><span class="p">)</span> <span class="n">qualifier</span><span class="o">.</span><span class="n">setTarget</span><span class="p">(</span><span class="n">target</span><span class="p">)</span> <span class="n">claim</span><span class="o">.</span><span class="n">addQualifier</span><span class="p">(</span><span class="n">qualifier</span><span class="p">,</span> <span class="n">summary</span><span class="o">=</span><span class="s1">'Adding a qualifier.'</span><span class="p">)</span> </pre></div> </td></tr></tbody></table></div> <div class="mw-heading mw-heading3"><h3 id="Example_9:_Add_a_source" data-mw-thread-id="h-Example_9:_Add_a_source-Pywikibot"><span data-mw-comment-start="" id="h-Example_9:_Add_a_source-Pywikibot"></span>Example 9: Add a source<span data-mw-comment-end="h-Example_9:_Add_a_source-Pywikibot"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=14" title="Edit section: Example 9: Add a source"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Also, sources are represented by the Claim class. Unlike for qualifiers, a source may contain more than one Claim. In the following, we add <a href="/wiki/Property:P248" title="Property:P248">stated in <small dir="ltr">(P248)</small></a>: <a href="/wiki/Q82575" title="Q82575">Integrated Taxonomic Information System <small>(Q82575)</small></a> with <a href="/wiki/Property:P813" title="Property:P813">retrieved <small dir="ltr">(P813)</small></a> March 20, 2014 as source to the Claim "claim". The claim has to be either retrieved from Wikidata or added to an itempage beforehand. </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="n">statedin</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">Claim</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s1">'P248'</span><span class="p">)</span> <span class="n">itis</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">ItemPage</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s2">"Q82575"</span><span class="p">)</span> <span class="n">statedin</span><span class="o">.</span><span class="n">setTarget</span><span class="p">(</span><span class="n">itis</span><span class="p">)</span> <span class="n">retrieved</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">Claim</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s1">'P813'</span><span class="p">)</span> <span class="n">date</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">WbTime</span><span class="p">(</span><span class="n">year</span><span class="o">=</span><span class="mi">2014</span><span class="p">,</span> <span class="n">month</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">day</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span> <span class="n">retrieved</span><span class="o">.</span><span class="n">setTarget</span><span class="p">(</span><span class="n">date</span><span class="p">)</span> <span class="n">claim</span><span class="o">.</span><span class="n">addSources</span><span class="p">([</span><span class="n">statedin</span><span class="p">,</span> <span class="n">retrieved</span><span class="p">],</span> <span class="n">summary</span><span class="o">=</span><span class="s1">'Adding sources.'</span><span class="p">)</span> </pre></div> </td></tr></tbody></table></div> <div class="mw-heading mw-heading3"><h3 id="Example_10:_Page_generators" data-mw-thread-id="h-Example_10:_Page_generators-Pywikibot"><span data-mw-comment-start="" id="h-Example_10:_Page_generators-Pywikibot"></span>Example 10: Page generators<span data-mw-comment-end="h-Example_10:_Page_generators-Pywikibot"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=15" title="Edit section: Example 10: Page generators"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>TODO </p> <div class="mw-heading mw-heading3"><h3 id="Example_11:_Get_values_of_sub-properties" data-mw-thread-id="h-Example_11:_Get_values_of_sub-properties-Pywikibot"><span data-mw-comment-start="" id="h-Example_11:_Get_values_of_sub-properties-Pywikibot"></span>Example 11: Get values of sub-properties<span data-mw-comment-end="h-Example_11:_Get_values_of_sub-properties-Pywikibot"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=16" title="Edit section: Example 11: Get values of sub-properties"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In the following, we get values of sub-properties from branch <a href="/wiki/Property:P1343" title="Property:P1343">described by source <small dir="ltr">(P1343)</small></a> -> <a href="/wiki/Q17378135" title="Q17378135">Great Soviet Encyclopedia (1969–1978) <small>(Q17378135)</small></a> -> properties <a href="/wiki/Property:P854" title="Property:P854">reference URL <small dir="ltr">(P854)</small></a> and <a href="/wiki/Property:P1476" title="Property:P1476">title <small dir="ltr">(P1476)</small></a>. </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="kn">import</span> <span class="nn">pywikibot</span> <span class="n">site</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">Site</span><span class="p">(</span><span class="s2">"wikidata"</span><span class="p">,</span> <span class="s2">"wikidata"</span><span class="p">)</span> <span class="n">repo</span> <span class="o">=</span> <span class="n">site</span><span class="o">.</span><span class="n">data_repository</span><span class="p">()</span> <span class="n">item</span> <span class="o">=</span> <span class="n">pywikibot</span><span class="o">.</span><span class="n">ItemPage</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s1">'Q13515'</span><span class="p">)</span> <span class="n">item</span><span class="o">.</span><span class="n">get</span><span class="p">()</span> <span class="n">sourcesid</span> <span class="o">=</span> <span class="s1">'P1343'</span> <span class="n">sourceid</span> <span class="o">=</span> <span class="s1">'Q17378135'</span> <span class="n">urlid</span> <span class="o">=</span> <span class="s1">'P854'</span> <span class="n">nameid</span> <span class="o">=</span> <span class="s1">'P1476'</span> <span class="c1"># item.claims['P1343'][1].qualifiers.items(): # This are direct way to get list qualifiers. But '[1]' is hard link to index of list, it will break over time.</span> <span class="k">if</span> <span class="n">sourcesid</span> <span class="ow">in</span> <span class="n">item</span><span class="o">.</span><span class="n">claims</span><span class="p">:</span> <span class="k">for</span> <span class="n">source</span> <span class="ow">in</span> <span class="n">item</span><span class="o">.</span><span class="n">claims</span><span class="p">[</span><span class="n">sourcesid</span><span class="p">]:</span> <span class="k">if</span> <span class="n">source</span><span class="o">.</span><span class="n">target</span><span class="o">.</span><span class="n">id</span> <span class="o">==</span> <span class="n">sourceid</span><span class="p">:</span> <span class="n">s</span> <span class="o">=</span> <span class="n">source</span><span class="o">.</span><span class="n">qualifiers</span> <span class="k">if</span> <span class="n">urlid</span> <span class="ow">in</span> <span class="n">s</span><span class="p">:</span> <span class="n">url</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">urlid</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">target</span> <span class="k">if</span> <span class="n">nameid</span> <span class="ow">in</span> <span class="n">s</span><span class="p">:</span> <span class="n">name</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">nameid</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">target</span><span class="p">[</span><span class="s1">'text'</span><span class="p">]</span> <span class="nb">print</span> <span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span> </pre></div> </td></tr></tbody></table></div> <div class="mw-heading mw-heading3"><h3 id="More_examples" data-mw-thread-id="h-More_examples-Pywikibot"><span data-mw-comment-start="" id="h-More_examples-Pywikibot"></span>More examples<span data-mw-comment-end="h-More_examples-Pywikibot"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=17" title="Edit section: More examples"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Some users share their source codes. Learn more in the next links: </p> <ul><li><a href="/wiki/User:RobotMichiel1972/wikidata_lowercase.py" title="User:RobotMichiel1972/wikidata lowercase.py">User:RobotMichiel1972/wikidata lowercase.py</a> - pywikipedia example how you can correct the label to lowercase using the English label capitalization as 'reference' (here hard coded implemented for nlwiki only) running over selection of pages in own wikipedia.</li> <li><a href="/wiki/File:Bots_hackathon_2013.pdf" title="File:Bots hackathon 2013.pdf">File:Bots hackathon 2013.pdf</a> presenting "<a href="https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Pywikibot/claimit.py" class="extiw" title="mw:Special:MyLanguage/Manual:Pywikibot/claimit.py">claimit.py</a>" and "template_harvest.py" included in the core version (former re-write).</li></ul> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="Wikidata_Integrator" data-mw-thread-id="h-Wikidata_Integrator"><span data-mw-comment-start="" id="h-Wikidata_Integrator"></span>Wikidata Integrator<span data-mw-comment-end="h-Wikidata_Integrator"></span></h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=18" title="Edit section: Wikidata Integrator"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Wikidata_Integrator","replies":["h-Example_Notebook-Wikidata_Integrator"]}}--></div> <p>WikidataIntegrator is a library for reading and writing to Wikidata/Wikibase. <a href="/wiki/User:ProteinBoxBot" title="User:ProteinBoxBot">We</a> created it for populating Wikidata with content from authoritative resources on Genes, Proteins, Diseases, Drugs and others. Details on the different tasks can be found on the bot's Wikidata page. </p><p>Pywikibot is an existing framework for interacting with the MediaWiki API. The reason why we came up with our own solution is that we need a high integration with the Wikidata SPARQL endpoint in order to ensure data consistency (duplicate checks, consistency checks, correct item selection, etc.). Compared to Pywikibot, WikidataIntegrator currently is not a full Python wrapper for the MediaWiki API but is solely focused on providing an easy means to generate Python-based Wikidata bots. </p><p><b>For more information, documentation, download & installation instructions</b>, see here: <a rel="nofollow" class="external free" href="https://github.com/SuLab/WikidataIntegrator/">https://github.com/SuLab/WikidataIntegrator/</a> </p> <div class="mw-heading mw-heading3"><h3 id="Example_Notebook" data-mw-thread-id="h-Example_Notebook-Wikidata_Integrator"><span data-mw-comment-start="" id="h-Example_Notebook-Wikidata_Integrator"></span>Example Notebook<span data-mw-comment-end="h-Example_Notebook-Wikidata_Integrator"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=19" title="Edit section: Example Notebook"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>An example notebook demonstrating an example bot to add therapeutic areas to drug items, including using fastrun mode, checking references, and removing old statements: </p><p><a rel="nofollow" class="external free" href="http://public-paws.wmcloud.org/46883698/example%20ema%20bot.ipynb">http://public-paws.wmcloud.org/46883698/example%20ema%20bot.ipynb</a> </p> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="WikibaseIntegrator" data-mw-thread-id="h-WikibaseIntegrator"><span data-mw-comment-start="" id="h-WikibaseIntegrator"></span>WikibaseIntegrator<span data-mw-comment-end="h-WikibaseIntegrator"></span></h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=20" title="Edit section: WikibaseIntegrator"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-WikibaseIntegrator","replies":["h-Example_semi-automatic_script-WikibaseIntegrator"]}}--></div> <p>Forked from Wikidata Integrator by <a href="/wiki/User:Myst" title="User:Myst">User:Myst</a> in 2020 and has seen several improvements to the API that makes it even easier to create bots using the library. </p><p><b>For more information, documentation, download & installation instructions</b>, see here: <a rel="nofollow" class="external free" href="https://github.com/LeMyst/WikibaseIntegrator">https://github.com/LeMyst/WikibaseIntegrator</a> </p> <div class="mw-heading mw-heading3"><h3 id="Example_semi-automatic_script" data-mw-thread-id="h-Example_semi-automatic_script-WikibaseIntegrator"><span data-mw-comment-start="" id="h-Example_semi-automatic_script-WikibaseIntegrator"></span>Example semi-automatic script<span data-mw-comment-end="h-Example_semi-automatic_script-WikibaseIntegrator"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=21" title="Edit section: Example semi-automatic script"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>LexUse semi-automatic tool for finding and adding usage examples to lexemes. It's free software written using Python 3 in 2020 <a href="/wiki/Wikidata:LexUse" class="mw-redirect" title="Wikidata:LexUse">Wikidata:LexUse</a>. </p> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="Wikibase.NET_(Deprecated)" data-mw-thread-id="h-Wikibase.NET_(Deprecated)"><span id="Wikibase.NET_.28Deprecated.29"></span><span data-mw-comment-start="" id="h-Wikibase.NET_(Deprecated)"></span>Wikibase.NET (Deprecated)<span data-mw-comment-end="h-Wikibase.NET_(Deprecated)"></span></h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=22" title="Edit section: Wikibase.NET (Deprecated)"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Wikibase.NET_(Deprecated)","replies":["h-Download_&_Installation-Wikibase.NET_(Deprecated)","h-Known_issues-Wikibase.NET_(Deprecated)","h-Examples-Wikibase.NET_(Deprecated)"]}}--></div> <p>Wikibase.NET is the api that replaces the now deprecated DotNetDataBot. Api client for the MediaWiki extension Wikibase. They aren't compatible because Wikibase.NET does no longer need the DotNetWikiBot framework. </p> <div class="mw-heading mw-heading3"><h3 id="Download_&_Installation" data-mw-thread-id="h-Download_&_Installation-Wikibase.NET_(Deprecated)"><span id="Download_.26_Installation"></span><span data-mw-comment-start="" id="h-Download_&_Installation-Wikibase.NET_(Deprecated)"></span>Download & Installation<span data-mw-comment-end="h-Download_&_Installation-Wikibase.NET_(Deprecated)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=23" title="Edit section: Download & Installation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>You can <a rel="nofollow" class="external text" href="https://github.com/Benestar/wikibase.net">download Wikibase.NET from GitHub</a>. Just follow the instructions on that page. </p> <div class="mw-heading mw-heading3"><h3 id="Known_issues" data-mw-thread-id="h-Known_issues-Wikibase.NET_(Deprecated)"><span data-mw-comment-start="" id="h-Known_issues-Wikibase.NET_(Deprecated)"></span>Known issues<span data-mw-comment-end="h-Known_issues-Wikibase.NET_(Deprecated)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=24" title="Edit section: Known issues"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li><a rel="nofollow" class="external text" href="https://github.com/Benestar/wikibase.net/issues/3">Quantity type not supported</a> (<a rel="nofollow" class="external text" href="https://github.com/Ahoerstemeier/wikibase.net/tree/rework">fix</a>)</li> <li><a rel="nofollow" class="external text" href="https://github.com/Benestar/wikibase.net/issues/3">Monolingual text not supported</a></li></ul> <div class="mw-heading mw-heading3"><h3 id="Examples" data-mw-thread-id="h-Examples-Wikibase.NET_(Deprecated)"><span data-mw-comment-start="" id="h-Examples-Wikibase.NET_(Deprecated)"></span>Examples<span data-mw-comment-end="h-Examples-Wikibase.NET_(Deprecated)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=25" title="Edit section: Examples"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Coming <b>not</b> soon... </p> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="DotNetDataBot_(Deprecated)" data-mw-thread-id="h-DotNetDataBot_(Deprecated)"><span id="DotNetDataBot_.28Deprecated.29"></span><span data-mw-comment-start="" id="h-DotNetDataBot_(Deprecated)"></span>DotNetDataBot (Deprecated)<span data-mw-comment-end="h-DotNetDataBot_(Deprecated)"></span></h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=26" title="Edit section: DotNetDataBot (Deprecated)"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-DotNetDataBot_(Deprecated)","replies":["h-Installation_2-DotNetDataBot_(Deprecated)","h-Configuration_2-DotNetDataBot_(Deprecated)","h-Login_2-DotNetDataBot_(Deprecated)","h-Example_1:_Get_id_using_wiki_page-DotNetDataBot_(Deprecated)","h-Example_2:_Get_interwiki_links_2-DotNetDataBot_(Deprecated)","h-Example_3:_Set_a_description-DotNetDataBot_(Deprecated)","h-Example_4:_Set_a_label-DotNetDataBot_(Deprecated)","h-Example_5:_Get_interwiki_links_for_100_pages-DotNetDataBot_(Deprecated)"]}}--></div> <div class="mw-heading mw-heading3"><h3 id="Installation_2" data-mw-thread-id="h-Installation_2-DotNetDataBot_(Deprecated)"><span data-mw-comment-start="" id="h-Installation_2-DotNetDataBot_(Deprecated)"></span>Installation<span data-mw-comment-end="h-Installation_2-DotNetDataBot_(Deprecated)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=27" title="Edit section: Installation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li>Download: <a rel="nofollow" class="external text" href="https://benestar.github.com/DotNetDataBot/">DotNetDataBot</a></li></ul> <div class="mw-heading mw-heading3"><h3 id="Configuration_2" data-mw-thread-id="h-Configuration_2-DotNetDataBot_(Deprecated)"><span data-mw-comment-start="" id="h-Configuration_2-DotNetDataBot_(Deprecated)"></span>Configuration<span data-mw-comment-end="h-Configuration_2-DotNetDataBot_(Deprecated)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=28" title="Edit section: Configuration"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>After unpacking the package you can see a file called DotNetDataBot.dll and one called DotNetDataBot.xml. The xml document is only for documentation. To use it you have to create a new refer in your project. Then you can write <code>using DotNetDataBot;</code> to import the framework. </p> <div class="mw-heading mw-heading3"><h3 id="Login_2" data-mw-thread-id="h-Login_2-DotNetDataBot_(Deprecated)"><span data-mw-comment-start="" id="h-Login_2-DotNetDataBot_(Deprecated)"></span>Login<span data-mw-comment-end="h-Login_2-DotNetDataBot_(Deprecated)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=29" title="Edit section: Login"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>To login you have to create a new <code>Site</code> object with the url of the wiki, your bot's username and <a href="/wiki/Special:BotPasswords" title="Special:BotPasswords">its password</a>. </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <p>C# </p> <div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"><pre><span></span><span class="k">using</span><span class="w"> </span><span class="nn">DotNetDataBot</span><span class="p">;</span> <span class="k">public</span><span class="w"> </span><span class="k">static</span><span class="w"> </span><span class="k">void</span><span class="w"> </span><span class="nf">Main</span><span class="p">()</span> <span class="p">{</span> <span class="w"> </span><span class="n">Site</span><span class="w"> </span><span class="n">wikidata</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">Site</span><span class="p">(</span><span class="s">"http://www.wikidata.org"</span><span class="p">,</span><span class="w"> </span><span class="s">"User"</span><span class="p">,</span><span class="w"> </span><span class="s">"Password"</span><span class="p">);</span> <span class="p">}</span> </pre></div> </td></tr></tbody></table></div> <div class="mw-heading mw-heading3"><h3 id="Example_1:_Get_id_using_wiki_page" data-mw-thread-id="h-Example_1:_Get_id_using_wiki_page-DotNetDataBot_(Deprecated)"><span data-mw-comment-start="" id="h-Example_1:_Get_id_using_wiki_page-DotNetDataBot_(Deprecated)"></span>Example 1: Get id using wiki page<span data-mw-comment-end="h-Example_1:_Get_id_using_wiki_page-DotNetDataBot_(Deprecated)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=30" title="Edit section: Example 1: Get id using wiki page"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>You can access the id of an item by searching for using the site and the title of the connected page. </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <p>C# </p> <div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"><pre><span></span><span class="k">using</span><span class="w"> </span><span class="nn">DotNetDataBot</span><span class="p">;</span> <span class="k">public</span><span class="w"> </span><span class="k">static</span><span class="w"> </span><span class="k">void</span><span class="w"> </span><span class="nf">Main</span><span class="p">()</span> <span class="p">{</span> <span class="w"> </span><span class="n">Site</span><span class="w"> </span><span class="n">site</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">Site</span><span class="p">(</span><span class="s">"http://www.wikidata.org"</span><span class="p">,</span><span class="w"> </span><span class="s">"User"</span><span class="p">,</span><span class="w"> </span><span class="s">"Password"</span><span class="p">);</span> <span class="w"> </span><span class="n">Item</span><span class="w"> </span><span class="n">item</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">Item</span><span class="p">(</span><span class="n">site</span><span class="p">);</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">item</span><span class="p">.</span><span class="n">itemExists</span><span class="p">(</span><span class="s">"it"</span><span class="p">,</span><span class="w"> </span><span class="s">"George Lucas"</span><span class="p">))</span><span class="w"> </span><span class="c1">// Check if exist on Wikidata</span> <span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="s">"Q"</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">item</span><span class="p">.</span><span class="n">GetIdBySitelink</span><span class="p">(</span><span class="s">"it"</span><span class="p">,</span><span class="w"> </span><span class="s">"George Lucas"</span><span class="p">));</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="k">else</span> <span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="s">"Doesn't exist"</span><span class="p">);</span> <span class="w"> </span><span class="p">}</span> <span class="p">}</span> </pre></div> </td></tr></tbody></table></div> <div class="mw-heading mw-heading3"><h3 id="Example_2:_Get_interwiki_links_2" data-mw-thread-id="h-Example_2:_Get_interwiki_links_2-DotNetDataBot_(Deprecated)"><span data-mw-comment-start="" id="h-Example_2:_Get_interwiki_links_2-DotNetDataBot_(Deprecated)"></span>Example 2: Get interwiki links<span data-mw-comment-end="h-Example_2:_Get_interwiki_links_2-DotNetDataBot_(Deprecated)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=31" title="Edit section: Example 2: Get interwiki links"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>You can get the interwiki links of an item by loading the content and accessing the <code>links</code> field of the object. </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <p>C# </p> <div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"><pre><span></span><span class="k">using</span><span class="w"> </span><span class="nn">DotNetDataBot</span><span class="p">;</span> <span class="k">public</span><span class="w"> </span><span class="k">static</span><span class="w"> </span><span class="k">void</span><span class="w"> </span><span class="nf">Main</span><span class="p">()</span> <span class="p">{</span> <span class="w"> </span><span class="n">Site</span><span class="w"> </span><span class="n">site</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">Site</span><span class="p">(</span><span class="s">"http://www.wikidata.org"</span><span class="p">,</span><span class="w"> </span><span class="s">"User"</span><span class="p">,</span><span class="w"> </span><span class="s">"Password"</span><span class="p">);</span> <span class="w"> </span><span class="n">Item</span><span class="w"> </span><span class="n">item</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">Item</span><span class="p">(</span><span class="n">site</span><span class="p">);</span> <span class="w"> </span><span class="n">item</span><span class="p">.</span><span class="n">id</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">item</span><span class="p">.</span><span class="n">GetIdBySitelink</span><span class="p">(</span><span class="s">"it"</span><span class="p">,</span><span class="w"> </span><span class="s">"George Lucas"</span><span class="p">);</span> <span class="w"> </span><span class="n">item</span><span class="p">.</span><span class="n">Load</span><span class="p">();</span> <span class="w"> </span><span class="k">foreach</span><span class="p">(</span><span class="n">KeyValuePair</span><span class="o"><</span><span class="kt">string</span><span class="p">,</span><span class="w"> </span><span class="kt">string</span><span class="o">></span><span class="w"> </span><span class="n">link</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">item</span><span class="p">.</span><span class="n">links</span><span class="p">)</span><span class="w"> </span> <span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">link</span><span class="p">.</span><span class="n">Key</span><span class="p">);</span><span class="w"> </span><span class="c1">// lang (eg. en or it)</span> <span class="w"> </span><span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">link</span><span class="p">.</span><span class="n">Value</span><span class="p">);</span><span class="w"> </span><span class="c1">// page (eg. George_Lucas)</span> <span class="w"> </span><span class="p">}</span> <span class="p">}</span> </pre></div> </td></tr></tbody></table></div> <div class="mw-heading mw-heading3"><h3 id="Example_3:_Set_a_description" data-mw-thread-id="h-Example_3:_Set_a_description-DotNetDataBot_(Deprecated)"><span data-mw-comment-start="" id="h-Example_3:_Set_a_description-DotNetDataBot_(Deprecated)"></span>Example 3: Set a description<span data-mw-comment-end="h-Example_3:_Set_a_description-DotNetDataBot_(Deprecated)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=32" title="Edit section: Example 3: Set a description"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>To set a description, you must call the <code>setDescription</code> function. </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <p>C# </p> <div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"><pre><span></span><span class="k">using</span><span class="w"> </span><span class="nn">DotNetDataBot</span><span class="p">;</span> <span class="k">public</span><span class="w"> </span><span class="k">static</span><span class="w"> </span><span class="k">void</span><span class="w"> </span><span class="nf">Main</span><span class="p">()</span> <span class="p">{</span> <span class="w"> </span><span class="n">Site</span><span class="w"> </span><span class="n">site</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">Site</span><span class="p">(</span><span class="s">"http://www.wikidata.org"</span><span class="p">,</span><span class="w"> </span><span class="s">"User"</span><span class="p">,</span><span class="w"> </span><span class="s">"Password"</span><span class="p">);</span> <span class="w"> </span><span class="n">Item</span><span class="w"> </span><span class="n">item</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">Item</span><span class="p">(</span><span class="n">site</span><span class="p">,</span><span class="w"> </span><span class="s">"Q4115189"</span><span class="p">);</span> <span class="w"> </span><span class="n">item</span><span class="p">.</span><span class="n">Load</span><span class="p">();</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">item</span><span class="p">.</span><span class="n">descriptions</span><span class="p">.</span><span class="n">ContainsKey</span><span class="p">(</span><span class="s">"it"</span><span class="p">))</span><span class="w"> </span><span class="c1">// if alredy exist description in italian</span> <span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="c1">// Nothing to do</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="k">else</span> <span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">item</span><span class="p">.</span><span class="n">setDescription</span><span class="p">(</span><span class="s">"it"</span><span class="p">,</span><span class="w"> </span><span class="s">"description in italian"</span><span class="p">,</span><span class="w"> </span><span class="s">"Bot: Add italian description"</span><span class="p">);</span> <span class="w"> </span><span class="p">}</span> <span class="p">}</span> </pre></div> </td></tr></tbody></table></div> <div class="mw-heading mw-heading3"><h3 id="Example_4:_Set_a_label" data-mw-thread-id="h-Example_4:_Set_a_label-DotNetDataBot_(Deprecated)"><span data-mw-comment-start="" id="h-Example_4:_Set_a_label-DotNetDataBot_(Deprecated)"></span>Example 4: Set a label<span data-mw-comment-end="h-Example_4:_Set_a_label-DotNetDataBot_(Deprecated)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=33" title="Edit section: Example 4: Set a label"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>It works the same way for setting a label. Just call <code>setLabel</code>. </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <p>C# </p> <div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"><pre><span></span><span class="k">using</span><span class="w"> </span><span class="nn">DotNetDataBot</span><span class="p">;</span> <span class="k">public</span><span class="w"> </span><span class="k">static</span><span class="w"> </span><span class="k">void</span><span class="w"> </span><span class="nf">Main</span><span class="p">()</span> <span class="p">{</span> <span class="w"> </span><span class="n">Site</span><span class="w"> </span><span class="n">site</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">Site</span><span class="p">(</span><span class="s">"http://www.wikidata.org"</span><span class="p">,</span><span class="w"> </span><span class="s">"User"</span><span class="p">,</span><span class="w"> </span><span class="s">"Password"</span><span class="p">);</span> <span class="w"> </span><span class="n">Item</span><span class="w"> </span><span class="n">item</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">Item</span><span class="p">(</span><span class="n">site</span><span class="p">,</span><span class="w"> </span><span class="s">"Q4115189"</span><span class="p">);</span> <span class="w"> </span><span class="n">item</span><span class="p">.</span><span class="n">Load</span><span class="p">();</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">item</span><span class="p">.</span><span class="n">labels</span><span class="p">.</span><span class="n">ContainsKey</span><span class="p">(</span><span class="s">"it"</span><span class="p">))</span><span class="w"> </span><span class="c1">// if alredy exist label in italian</span> <span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="c1">// Nothing to do</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="k">else</span> <span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">item</span><span class="p">.</span><span class="n">setLabel</span><span class="p">(</span><span class="s">"it"</span><span class="p">,</span><span class="w"> </span><span class="s">"label in italian"</span><span class="p">,</span><span class="w"> </span><span class="s">"Bot: Add italian label"</span><span class="p">);</span> <span class="w"> </span><span class="p">}</span> <span class="p">}</span> </pre></div> </td></tr></tbody></table></div> <div class="mw-heading mw-heading3"><h3 id="Example_5:_Get_interwiki_links_for_100_pages" data-mw-thread-id="h-Example_5:_Get_interwiki_links_for_100_pages-DotNetDataBot_(Deprecated)"><span data-mw-comment-start="" id="h-Example_5:_Get_interwiki_links_for_100_pages-DotNetDataBot_(Deprecated)"></span>Example 5: Get interwiki links for 100 pages<span data-mw-comment-end="h-Example_5:_Get_interwiki_links_for_100_pages-DotNetDataBot_(Deprecated)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=34" title="Edit section: Example 5: Get interwiki links for 100 pages"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>This feature is not supported. Just iterate over the list. </p> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="Wikibase_api_for_PHP" data-mw-thread-id="h-Wikibase_api_for_PHP"><span data-mw-comment-start="" id="h-Wikibase_api_for_PHP"></span>Wikibase api for PHP<span data-mw-comment-end="h-Wikibase_api_for_PHP"></span></h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=35" title="Edit section: Wikibase api for PHP"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Wikibase_api_for_PHP","replies":["h-Example_1:_Basic_example-Wikibase_api_for_PHP","h-Example_2:_Creating_claims-Wikibase_api_for_PHP"]}}--></div> <p>This is an api client for Wikibase written in PHP. It can be downloaded from <a rel="nofollow" class="external text" href="https://github.com/addwiki/wikibase-api">here</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Example_1:_Basic_example" data-mw-thread-id="h-Example_1:_Basic_example-Wikibase_api_for_PHP"><span data-mw-comment-start="" id="h-Example_1:_Basic_example-Wikibase_api_for_PHP"></span>Example 1: Basic example<span data-mw-comment-end="h-Example_1:_Basic_example-Wikibase_api_for_PHP"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=36" title="Edit section: Example 1: Basic example"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Take a look at the source comments to understand how it works. </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-php mw-content-ltr" dir="ltr"><pre><span></span><span class="cp"><?php</span> <span class="sd">/**</span> <span class="sd"> * Basic example for the use of the libary with some small edits</span> <span class="sd"> */</span> <span class="k">require_once</span><span class="p">(</span> <span class="no">__DIR__</span> <span class="o">.</span> <span class="s2">"/vendor/autoload.php"</span> <span class="p">);</span> <span class="c1">// Creates some useful objects and logs into the api</span> <span class="nv">$api</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">\Mediawiki\Api\MediawikiApi</span><span class="p">(</span> <span class="s2">"http://www.wikidata.org/w/api.php"</span> <span class="p">);</span> <span class="nv">$api</span><span class="o">-></span><span class="na">login</span><span class="p">(</span> <span class="k">new</span> <span class="nx">\Mediawiki\Api\ApiUser</span><span class="p">(</span> <span class="s1">'username'</span><span class="p">,</span> <span class="s1">'password'</span> <span class="p">)</span> <span class="p">);</span> <span class="nv">$dataValueClasses</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> <span class="s1">'unknown'</span> <span class="o">=></span> <span class="s1">'DataValues\UnknownValue'</span><span class="p">,</span> <span class="s1">'string'</span> <span class="o">=></span> <span class="s1">'DataValues\StringValue'</span><span class="p">,</span> <span class="p">);</span> <span class="nv">$wikidata</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">\Wikibase\Api\WikibaseFactory</span><span class="p">(</span> <span class="nv">$api</span><span class="p">,</span> <span class="k">new</span> <span class="nx">DataValues\Deserializers\DataValueDeserializer</span><span class="p">(</span> <span class="nv">$dataValueClasses</span> <span class="p">),</span> <span class="k">new</span> <span class="nx">DataValues\Serializers\DataValueSerializer</span><span class="p">()</span> <span class="p">);</span> <span class="c1">// Gets the current revision for item Q777</span> <span class="nv">$revision</span> <span class="o">=</span> <span class="nv">$wikidata</span><span class="o">-></span><span class="na">newRevisionGetter</span><span class="p">()</span><span class="o">-></span><span class="na">getFromId</span><span class="p">(</span> <span class="s1">'Q777'</span> <span class="p">);</span> <span class="nv">$item</span> <span class="o">=</span> <span class="nv">$revision</span><span class="o">-></span><span class="na">getContent</span><span class="p">()</span><span class="o">-></span><span class="na">getData</span><span class="p">();</span> <span class="c1">// Outputs the current sitelink for enwiki</span> <span class="nb">var_dump</span><span class="p">(</span> <span class="nv">$item</span><span class="o">-></span><span class="na">getSiteLink</span><span class="p">(</span> <span class="s1">'enwiki'</span> <span class="p">)</span> <span class="p">);</span> <span class="c1">// Sets the de description to 'Foobar'</span> <span class="nv">$item</span><span class="o">-></span><span class="na">getFingerprint</span><span class="p">()</span><span class="o">-></span><span class="na">setDescription</span><span class="p">(</span> <span class="s1">'de'</span><span class="p">,</span> <span class="s1">'Foobar'</span> <span class="p">);</span> <span class="c1">// Saves the item</span> <span class="nv">$wikidata</span><span class="o">-></span><span class="na">newRevisionSaver</span><span class="p">()</span><span class="o">-></span><span class="na">save</span><span class="p">(</span> <span class="nv">$revision</span> <span class="p">);</span> <span class="c1">//Log out</span> <span class="nv">$api</span><span class="o">-></span><span class="na">logout</span><span class="p">();</span> </pre></div> </td></tr></tbody></table></div> <p><br/> </p> <div class="mw-heading mw-heading3"><h3 id="Example_2:_Creating_claims" data-mw-thread-id="h-Example_2:_Creating_claims-Wikibase_api_for_PHP"><span data-mw-comment-start="" id="h-Example_2:_Creating_claims-Wikibase_api_for_PHP"></span>Example 2: Creating claims<span data-mw-comment-end="h-Example_2:_Creating_claims-Wikibase_api_for_PHP"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=37" title="Edit section: Example 2: Creating claims"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Take a look at the source comments to understand how it works. </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-php mw-content-ltr" dir="ltr"><pre><span></span><span class="cp"><?php</span> <span class="sd">/**</span> <span class="sd"> * Basic example for the use of the library with some small edits.</span> <span class="sd"> */</span> <span class="k">require_once</span><span class="p">(</span> <span class="no">__DIR__</span> <span class="o">.</span> <span class="s2">"/vendor/autoload.php"</span> <span class="p">);</span> <span class="c1">// Creates some useful objects and logs into the api</span> <span class="nv">$api</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">\Mediawiki\Api\MediawikiApi</span><span class="p">(</span> <span class="s2">"https://www.wikidata.org/w/api.php"</span> <span class="p">);</span> <span class="nv">$api</span><span class="o">-></span><span class="na">login</span><span class="p">(</span> <span class="k">new</span> <span class="nx">\Mediawiki\Api\ApiUser</span><span class="p">(</span> <span class="s1">'username'</span><span class="p">,</span> <span class="s1">'password'</span> <span class="p">)</span> <span class="p">);</span> <span class="nv">$dataValueClasses</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> <span class="s1">'unknown'</span> <span class="o">=></span> <span class="s1">'DataValues\UnknownValue'</span><span class="p">,</span> <span class="s1">'string'</span> <span class="o">=></span> <span class="s1">'DataValues\StringValue'</span><span class="p">,</span> <span class="p">);</span> <span class="nv">$services</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">\Wikibase\Api\WikibaseFactory</span><span class="p">(</span> <span class="nv">$api</span><span class="p">,</span> <span class="k">new</span> <span class="nx">DataValues\Deserializers\DataValueDeserializer</span><span class="p">(</span> <span class="nv">$dataValueClasses</span> <span class="p">),</span> <span class="k">new</span> <span class="nx">DataValues\Serializers\DataValueSerializer</span><span class="p">()</span> <span class="p">);</span> <span class="nv">$revision</span> <span class="o">=</span> <span class="nv">$services</span><span class="o">-></span><span class="na">newRevisionGetter</span><span class="p">()</span><span class="o">-></span><span class="na">getFromId</span><span class="p">(</span> <span class="s1">'Q777'</span> <span class="p">);</span> <span class="nv">$item</span> <span class="o">=</span> <span class="nv">$revision</span><span class="o">-></span><span class="na">getContent</span><span class="p">()</span><span class="o">-></span><span class="na">getData</span><span class="p">();</span> <span class="nv">$statementList</span> <span class="o">=</span> <span class="nv">$item</span><span class="o">-></span><span class="na">getStatements</span><span class="p">();</span> <span class="k">if</span><span class="p">(</span> <span class="nv">$statementList</span><span class="o">-></span><span class="na">getByPropertyId</span><span class="p">(</span> <span class="nx">\Wikibase\DataModel\Entity\PropertyId</span><span class="o">::</span><span class="na">newFromNumber</span><span class="p">(</span> <span class="mi">1320</span> <span class="p">)</span> <span class="p">)</span><span class="o">-></span><span class="na">isEmpty</span><span class="p">()</span> <span class="p">)</span> <span class="p">{</span> <span class="nv">$services</span><span class="o">-></span><span class="na">newStatementCreator</span><span class="p">()</span><span class="o">-></span><span class="na">create</span><span class="p">(</span> <span class="k">new</span> <span class="nx">\Wikibase\DataModel\Snak\PropertyValueSnak</span><span class="p">(</span> <span class="nx">\Wikibase\DataModel\Entity\PropertyId</span><span class="o">::</span><span class="na">newFromNumber</span><span class="p">(</span> <span class="mi">1320</span> <span class="p">),</span> <span class="k">new</span> <span class="nx">\DataValues\StringValue</span><span class="p">(</span> <span class="s1">'New String Value'</span> <span class="p">)</span> <span class="p">),</span> <span class="s1">'Q777'</span> <span class="p">);</span> <span class="p">}</span> <span class="c1">// Log out</span> <span class="nv">$api</span><span class="o">-></span><span class="na">logout</span><span class="p">();</span> </pre></div> </td></tr></tbody></table></div> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="VBot_(no_updates_since_2017)" data-mw-thread-id="h-VBot_(no_updates_since_2017)"><span id="VBot_.28no_updates_since_2017.29"></span><span data-mw-comment-start="" id="h-VBot_(no_updates_since_2017)"></span>VBot (no updates since 2017)<span data-mw-comment-end="h-VBot_(no_updates_since_2017)"></span></h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=38" title="Edit section: VBot (no updates since 2017)"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-VBot_(no_updates_since_2017)","replies":["h-Overview-VBot_(no_updates_since_2017)","h-Download-VBot_(no_updates_since_2017)","h-Instruction-VBot_(no_updates_since_2017)","h-Example_1-VBot_(no_updates_since_2017)"]}}--></div> <p>Framework for Wikidata and Wikipedia. Read and write on Wikidata and other Wikimedia project and have a useful list generator to generate list of Wikipedia page and Wikidata entity. Can read also JSON dump of Wikidata. </p> <div class="mw-heading mw-heading3"><h3 id="Overview" data-mw-thread-id="h-Overview-VBot_(no_updates_since_2017)"><span data-mw-comment-start="" id="h-Overview-VBot_(no_updates_since_2017)"></span>Overview<span data-mw-comment-end="h-Overview-VBot_(no_updates_since_2017)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=39" title="Edit section: Overview"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Bot to read and edit Wikidata and Wikipedia. </p> <ul><li>License: CC0 1.0</li> <li>Language C#</li> <li>Can read and write entities with all datatype on Wikidata</li> <li>Can read and write pages on all Wiki project</li> <li>Can read parameter from template on wiki pages</li> <li>Can read <a class="external text" href="https://dumps.wikimedia.org/other/wikidata/">JSON dump</a></li> <li>Can create lists using: <ul><li><a rel="nofollow" class="external text" href="https://wdq.wmflabs.org/">Wikidata query</a></li> <li><a class="external text" href="http://tools.wmflabs.org/catscan2/catscan2.php">Catscan 2</a></li> <li><a class="external text" href="http://tools.wmflabs.org/quick-intersection/index.php">Quick intersection</a></li> <li><a href="/wiki/Special:WhatLinksHere/Q42" title="Special:WhatLinksHere/Q42">What Links Here</a> on Wikidata</li></ul></li> <li>Tested with Visual Studio Express 2013 for Windows Desktop. <ul><li>Is necessary to have Newtonsoft.Json. You can install it with NuGet inside Visual Studio</li> <li>Is necessary to add manually a reference to System.Web for "HttpUtility.UrlEncode"</li></ul></li></ul> <div class="mw-heading mw-heading3"><h3 id="Download" data-mw-thread-id="h-Download-VBot_(no_updates_since_2017)"><span data-mw-comment-start="" id="h-Download-VBot_(no_updates_since_2017)"></span>Download<span data-mw-comment-end="h-Download-VBot_(no_updates_since_2017)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=40" title="Edit section: Download"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The framework can be downloaded from GitHub <a rel="nofollow" class="external text" href="https://github.com/ValterVB/VBot">here</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Instruction" data-mw-thread-id="h-Instruction-VBot_(no_updates_since_2017)"><span data-mw-comment-start="" id="h-Instruction-VBot_(no_updates_since_2017)"></span>Instruction<span data-mw-comment-end="h-Instruction-VBot_(no_updates_since_2017)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=41" title="Edit section: Instruction"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li><a rel="nofollow" class="external text" href="https://github.com/ValterVB/VBot/wiki">Wiki</a> (partial)</li> <li><a href="/wiki/User_talk:ValterVB" title="User talk:ValterVB">User talk:ValterVB</a> :)</li></ul> <div class="mw-heading mw-heading3"><h3 id="Example_1" data-mw-thread-id="h-Example_1-VBot_(no_updates_since_2017)"><span data-mw-comment-start="" id="h-Example_1-VBot_(no_updates_since_2017)"></span>Example 1<span data-mw-comment-end="h-Example_1-VBot_(no_updates_since_2017)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=42" title="Edit section: Example 1"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Update en label for all items with <a href="/wiki/Property:P31" title="Property:P31">instance of <small dir="ltr">(P31)</small></a>: <a href="/wiki/Q24862" title="Q24862">short film <small>(Q24862)</small></a> that have <a href="/wiki/Property:P57" title="Property:P57">director <small dir="ltr">(P57)</small></a> and that have <a href="/wiki/Property:P577" title="Property:P577">publication date <small dir="ltr">(P577)</small></a> in 1908. (Use of Wikidata query) </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"><pre><span></span><span class="k">private</span><span class="w"> </span><span class="k">void</span><span class="w"> </span><span class="nf">CompleteExample</span><span class="p">()</span> <span class="p">{</span> <span class="w"> </span><span class="c1">//Wikidata query</span> <span class="w"> </span><span class="kt">string</span><span class="w"> </span><span class="n">strWDQ</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"CLAIM[31:24862] AND CLAIM[57] AND BETWEEN[577,+00000001908-00-00T00:00:00Z,+00000001908-12-31T00:00:00Z]"</span><span class="p">;</span> <span class="w"> </span><span class="n">ListGenerator</span><span class="w"> </span><span class="n">lg</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">ListGenerator</span><span class="p">();</span> <span class="w"> </span><span class="n">List</span><span class="o"><</span><span class="kt">string</span><span class="o">></span><span class="w"> </span><span class="n">chunks</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">lg</span><span class="p">.</span><span class="n">WDQ</span><span class="p">(</span><span class="n">strWDQ</span><span class="p">,</span><span class="w"> </span><span class="m">50</span><span class="p">);</span> <span class="w"> </span><span class="c1">//Connection to Wikipedia</span> <span class="w"> </span><span class="n">WikimediaAPI</span><span class="w"> </span><span class="n">WP</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">WikimediaAPI</span><span class="p">(</span><span class="s">"https://it.wikipedia.org"</span><span class="p">,</span><span class="w"> </span><span class="n">User</span><span class="p">,</span><span class="w"> </span><span class="n">Password</span><span class="p">);</span> <span class="w"> </span><span class="n">Pages</span><span class="w"> </span><span class="n">PageList</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">Pages</span><span class="p">();</span> <span class="w"> </span><span class="c1">//Connection to Wikidata</span> <span class="w"> </span><span class="n">WikimediaAPI</span><span class="w"> </span><span class="n">WD</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">WikimediaAPI</span><span class="p">(</span><span class="s">"https://www.wikidata.org"</span><span class="p">,</span><span class="w"> </span><span class="n">User</span><span class="p">,</span><span class="w"> </span><span class="n">Password</span><span class="p">);</span> <span class="w"> </span><span class="n">Entities</span><span class="w"> </span><span class="n">EntityList</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">Entities</span><span class="p">();</span> <span class="w"> </span><span class="n">Dictionary</span><span class="o"><</span><span class="kt">string</span><span class="p">,</span><span class="w"> </span><span class="kt">string</span><span class="o">></span><span class="w"> </span><span class="n">Labels</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">Dictionary</span><span class="o"><</span><span class="kt">string</span><span class="p">,</span><span class="w"> </span><span class="kt">string</span><span class="o">></span><span class="p">();</span> <span class="w"> </span><span class="k">foreach</span><span class="w"> </span><span class="p">(</span><span class="kt">string</span><span class="w"> </span><span class="n">list</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">chunks</span><span class="p">)</span> <span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="c1">// Load all entity of the chunk</span> <span class="w"> </span><span class="kt">string</span><span class="w"> </span><span class="n">strJson</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">WD</span><span class="p">.</span><span class="n">LoadWD</span><span class="p">(</span><span class="n">list</span><span class="p">);</span> <span class="w"> </span><span class="n">EntityList</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">Entities</span><span class="p">();</span> <span class="w"> </span><span class="n">EntityList</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">JsonConvert</span><span class="p">.</span><span class="n">DeserializeObject</span><span class="o"><</span><span class="n">Entities</span><span class="o">></span><span class="p">(</span><span class="n">strJson</span><span class="p">,</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">DatavalueConverter</span><span class="p">());</span> <span class="w"> </span><span class="k">foreach</span><span class="w"> </span><span class="p">(</span><span class="n">KeyValuePair</span><span class="o"><</span><span class="kt">string</span><span class="p">,</span><span class="w"> </span><span class="n">Entity</span><span class="o">></span><span class="w"> </span><span class="n">entity</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">EntityList</span><span class="p">.</span><span class="n">entities</span><span class="p">)</span> <span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">entity</span><span class="p">.</span><span class="n">Value</span><span class="p">.</span><span class="n">sitelinks</span><span class="p">.</span><span class="n">ContainsKey</span><span class="p">(</span><span class="s">"itwiki"</span><span class="p">))</span> <span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="c1">// Load Wikipage</span> <span class="w"> </span><span class="kt">string</span><span class="w"> </span><span class="n">Pages</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">WP</span><span class="p">.</span><span class="n">LoadWP</span><span class="p">(</span><span class="n">entity</span><span class="p">.</span><span class="n">Value</span><span class="p">.</span><span class="n">sitelinks</span><span class="p">[</span><span class="s">"itwiki"</span><span class="p">].</span><span class="n">title</span><span class="p">);</span> <span class="w"> </span><span class="n">PageList</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">JsonConvert</span><span class="p">.</span><span class="n">DeserializeObject</span><span class="o"><</span><span class="n">Pages</span><span class="o">></span><span class="p">(</span><span class="n">Pages</span><span class="p">,</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">DatavalueConverter</span><span class="p">());</span> <span class="w"> </span> <span class="w"> </span><span class="c1">//Director from template</span> <span class="w"> </span><span class="kt">string</span><span class="w"> </span><span class="n">director</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Utility</span><span class="p">.</span><span class="n">GetTemplateParameter</span><span class="p">(</span><span class="n">PageList</span><span class="p">.</span><span class="n">query</span><span class="p">.</span><span class="n">FirstPageText</span><span class="p">,</span><span class="w"> </span><span class="s">"film"</span><span class="p">,</span><span class="s">"Regista"</span><span class="p">).</span><span class="n">Replace</span><span class="p">(</span><span class="s">"["</span><span class="p">,</span><span class="s">""</span><span class="p">).</span><span class="n">Replace</span><span class="p">(</span><span class="s">"]"</span><span class="p">,</span><span class="w"> </span><span class="s">""</span><span class="p">);</span> <span class="w"> </span><span class="n">Labels</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">Dictionary</span><span class="o"><</span><span class="kt">string</span><span class="p">,</span><span class="w"> </span><span class="kt">string</span><span class="o">></span><span class="p">();</span> <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">director</span><span class="o">==</span><span class="s">""</span><span class="p">)</span> <span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">Labels</span><span class="p">.</span><span class="n">Add</span><span class="p">(</span><span class="s">"en"</span><span class="p">,</span><span class="w"> </span><span class="s">"1908 short movie"</span><span class="p">);</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="k">else</span> <span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="n">Labels</span><span class="p">.</span><span class="n">Add</span><span class="p">(</span><span class="s">"en"</span><span class="p">,</span><span class="w"> </span><span class="s">"1908 short movie directed by "</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">director</span><span class="p">);</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="c1">// Update Wikidata</span> <span class="w"> </span><span class="n">WD</span><span class="p">.</span><span class="n">EditEntity</span><span class="p">(</span><span class="n">entity</span><span class="p">.</span><span class="n">Value</span><span class="p">.</span><span class="n">id</span><span class="p">,</span><span class="w"> </span><span class="k">null</span><span class="p">,</span><span class="w"> </span><span class="n">Labels</span><span class="p">,</span><span class="w"> </span><span class="k">null</span><span class="p">,</span><span class="w"> </span><span class="k">null</span><span class="p">,</span><span class="w"> </span><span class="k">null</span><span class="p">,</span><span class="w"> </span><span class="s">"BOT: Update en label"</span><span class="p">);</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="p">}</span> <span class="w"> </span><span class="p">}</span> <span class="p">}</span> </pre></div> </td></tr></tbody></table></div> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="LexData_(Python;_for_Lexicographical_data)" data-mw-thread-id="h-LexData_(Python;_for_Lexicographical_data)"><span id="LexData_.28Python.3B_for_Lexicographical_data.29"></span><span data-mw-comment-start="" id="h-LexData_(Python;_for_Lexicographical_data)"></span>LexData (Python; for Lexicographical data)<span data-mw-comment-end="h-LexData_(Python;_for_Lexicographical_data)"></span></h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=43" title="Edit section: LexData (Python; for Lexicographical data)"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-LexData_(Python;_for_Lexicographical_data)","replies":["h-Tips-LexData_(Python;_for_Lexicographical_data)","h-Installation_3-LexData_(Python;_for_Lexicographical_data)","h-Login_3-LexData_(Python;_for_Lexicographical_data)","h-Retrieve_a_Lexeme-LexData_(Python;_for_Lexicographical_data)","h-Searching_and_creating_Lexemes-LexData_(Python;_for_Lexicographical_data)","h-Adding_information-LexData_(Python;_for_Lexicographical_data)"]}}--></div> <p><a rel="nofollow" class="external text" href="https://nudin.github.io/LexData/">LexData</a> is an easy to use python libary to create and edit Lexemes, Senses and Forms. </p> <div class="mw-heading mw-heading3"><h3 id="Tips" data-mw-thread-id="h-Tips-LexData_(Python;_for_Lexicographical_data)"><span data-mw-comment-start="" id="h-Tips-LexData_(Python;_for_Lexicographical_data)"></span>Tips<span data-mw-comment-end="h-Tips-LexData_(Python;_for_Lexicographical_data)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=44" title="Edit section: Tips"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The documentation of LexData is still a bit lacking so look at existing implementations in MachtSinn or Wikdata Lexeme Forms for ideas how to use it. </p><p>If you only want to add statements to Lexemes (not forms or senses) WikibaseIntegrator might be a better choice, as it is more versatile and support a lot of data types. </p> <div class="mw-heading mw-heading3"><h3 id="Installation_3" data-mw-thread-id="h-Installation_3-LexData_(Python;_for_Lexicographical_data)"><span data-mw-comment-start="" id="h-Installation_3-LexData_(Python;_for_Lexicographical_data)"></span>Installation<span data-mw-comment-end="h-Installation_3-LexData_(Python;_for_Lexicographical_data)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=45" title="Edit section: Installation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>You can install LexData via pip: </p> <div class="mw-highlight mw-highlight-lang-shell-session mw-content-ltr" dir="ltr"><pre><span></span><span class="gp">$ </span>pip<span class="w"> </span>install<span class="w"> </span>LexData </pre></div> <div class="mw-heading mw-heading3"><h3 id="Login_3" data-mw-thread-id="h-Login_3-LexData_(Python;_for_Lexicographical_data)"><span data-mw-comment-start="" id="h-Login_3-LexData_(Python;_for_Lexicographical_data)"></span>Login<span data-mw-comment-end="h-Login_3-LexData_(Python;_for_Lexicographical_data)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=46" title="Edit section: Login"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>For all operations you need a <code>WikidataSession</code>. You can create it with your credentials, a <a href="/wiki/Special:BotPasswords" title="Special:BotPasswords">bot password</a> or an Edit Token (for example to edit via OAUTH): </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="n">repo</span> <span class="o">=</span> <span class="n">LexData</span><span class="o">.</span><span class="n">WikidataSession</span><span class="p">(</span><span class="s2">"YourUsername"</span><span class="p">,</span> <span class="s2">"YourPassword"</span><span class="p">)</span> </pre></div> </td></tr></tbody></table></div> <p><br/> </p> <div class="mw-heading mw-heading3"><h3 id="Retrieve_a_Lexeme" data-mw-thread-id="h-Retrieve_a_Lexeme-LexData_(Python;_for_Lexicographical_data)"><span data-mw-comment-start="" id="h-Retrieve_a_Lexeme-LexData_(Python;_for_Lexicographical_data)"></span>Retrieve a Lexeme<span data-mw-comment-end="h-Retrieve_a_Lexeme-LexData_(Python;_for_Lexicographical_data)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=47" title="Edit section: Retrieve a Lexeme"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>You can open existing Lexemes and read their content. </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="n">L2</span> <span class="o">=</span> <span class="n">LexData</span><span class="o">.</span><span class="n">Lexeme</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s2">"L2"</span><span class="p">)</span> <span class="nb">print</span><span class="p">(</span><span class="n">L2</span><span class="o">.</span><span class="n">claims</span><span class="p">)</span> <span class="nb">print</span><span class="p">(</span><span class="n">L2</span><span class="o">.</span><span class="n">forms</span><span class="p">)</span> <span class="nb">print</span><span class="p">(</span><span class="n">L2</span><span class="o">.</span><span class="n">senses</span><span class="p">)</span> <span class="n">sense1</span> <span class="o">=</span> <span class="n">L2</span><span class="o">.</span><span class="n">senses</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="nb">print</span><span class="p">(</span><span class="n">sense1</span><span class="o">.</span><span class="n">claims</span><span class="p">)</span> </pre></div> </td></tr></tbody></table></div> <div class="mw-heading mw-heading3"><h3 id="Searching_and_creating_Lexemes" data-mw-thread-id="h-Searching_and_creating_Lexemes-LexData_(Python;_for_Lexicographical_data)"><span data-mw-comment-start="" id="h-Searching_and_creating_Lexemes-LexData_(Python;_for_Lexicographical_data)"></span>Searching and creating Lexemes<span data-mw-comment-end="h-Searching_and_creating_Lexemes-LexData_(Python;_for_Lexicographical_data)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=48" title="Edit section: Searching and creating Lexemes"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>If you don't know the L-Id of a lexeme you can search for it. And if it doesn't exist you can create it. </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="c1"># Find an existing Lexeme by lemma, language and grammatical form</span> <span class="n">L2</span> <span class="o">=</span> <span class="n">LexData</span><span class="o">.</span><span class="n">search_lexemes</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s2">"first"</span><span class="p">,</span> <span class="n">en</span><span class="p">,</span> <span class="s2">"Q1084"</span><span class="p">)</span> <span class="c1"># Create a new Lexeme</span> <span class="n">L2</span> <span class="o">=</span> <span class="n">LexData</span><span class="o">.</span><span class="n">create_lexeme</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s2">"first"</span><span class="p">,</span> <span class="n">en</span><span class="p">,</span> <span class="s2">"Q1084"</span><span class="p">)</span> <span class="c1"># Find or create a Lexeme</span> <span class="n">L2</span> <span class="o">=</span> <span class="n">LexData</span><span class="o">.</span><span class="n">get_or_create_lexeme</span><span class="p">(</span><span class="n">repo</span><span class="p">,</span> <span class="s2">"first"</span><span class="p">,</span> <span class="n">en</span><span class="p">,</span> <span class="s2">"Q1084"</span><span class="p">)</span> </pre></div> </td></tr></tbody></table></div> <div class="mw-heading mw-heading3"><h3 id="Adding_information" data-mw-thread-id="h-Adding_information-LexData_(Python;_for_Lexicographical_data)"><span data-mw-comment-start="" id="h-Adding_information-LexData_(Python;_for_Lexicographical_data)"></span>Adding information<span data-mw-comment-end="h-Adding_information-LexData_(Python;_for_Lexicographical_data)"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=49" title="Edit section: Adding information"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>You can easily create forms or senses, with or without additional claims: </p> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">L2</span><span class="o">.</span><span class="n">forms</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> <span class="n">L2</span><span class="o">.</span><span class="n">createForm</span><span class="p">(</span><span class="s2">"firsts"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Q146786"</span><span class="p">])</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">L2</span><span class="o">.</span><span class="n">senses</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> <span class="n">L2</span><span class="o">.</span><span class="n">createSense</span><span class="p">(</span> <span class="p">{</span> <span class="s2">"en"</span><span class="p">:</span> <span class="s2">"Element in an ordered list which comes before all others according to the ordering"</span><span class="p">,</span> <span class="s2">"de"</span><span class="p">:</span> <span class="s2">"einer Ordnung folgend das Element vor allen anderen"</span><span class="p">,</span> <span class="p">},</span> <span class="n">claims</span><span class="o">=</span><span class="p">{</span><span class="s2">"P5137"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"Q19269277"</span><span class="p">]},</span> <span class="p">)</span> </pre></div> </td></tr></tbody></table></div> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="Using_Wikidata's_API_directly" data-mw-thread-id="h-Using_Wikidata's_API_directly"><span id="Using_Wikidata.27s_API_directly"></span><span data-mw-comment-start="" id="h-Using_Wikidata's_API_directly"></span>Using Wikidata's API directly<span data-mw-comment-end="h-Using_Wikidata's_API_directly"></span></h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=50" title="Edit section: Using Wikidata's API directly"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Using_Wikidata's_API_directly","replies":["h-Example_1:_Get_Q_number-Using_Wikidata's_API_directly","h-Example_2:_Get_list_of_items_without_particular_interwiki-Using_Wikidata's_API_directly"]}}--></div> <p>The other sections describe how to use bot frameworks to access and update Wikidata information. You can also directly interact with the Wikibase API that Wikidata provides. You need to do this if you're developing your own framework or if you need to do something that a framework doesn't support. The documentation for the Wikibase API can be found at <a href="https://www.mediawiki.org/wiki/Extension:Wikibase/API" class="extiw" title="mw:Extension:Wikibase/API">mediawiki.org</a>. You can also play around with it at <a href="/wiki/Special:ApiSandbox" title="Special:ApiSandbox">Special:ApiSandbox</a>, try <code>action=wbgetentities</code>. </p><p>Wikibase provides its API as a set of modules for <a href="https://www.mediawiki.org/wiki/API:Action_API" class="extiw" title="mw:API:Action API">MediaWiki's "action" API</a>. You access this by making HTTP requests to <code>/w/api.php</code>. The default response format is JSON. So for your language of choice, you only need a library to perform HTTP requests and a JSON or XML library to parse the responses. </p> <div class="mw-heading mw-heading3"><h3 id="Example_1:_Get_Q_number" data-mw-thread-id="h-Example_1:_Get_Q_number-Using_Wikidata's_API_directly"><span data-mw-comment-start="" id="h-Example_1:_Get_Q_number-Using_Wikidata's_API_directly"></span>Example 1: Get Q number<span data-mw-comment-end="h-Example_1:_Get_Q_number-Using_Wikidata's_API_directly"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=51" title="Edit section: Example 1: Get Q number"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>This example gets the item <a href="/wiki/Q2469" title="Q2469">Q number</a> for the English Wikipedia article about <a href="https://en.wikipedia.org/wiki/Andromeda_Galaxy" class="extiw" title="en:Andromeda Galaxy">Andromeda Galaxy</a>. The Wikibase API's main "workhorse" module <code>action=wbgetentities</code> provides this information. The HTTP request (using <code>jsonfm</code> format for human-readable JSON output) is simply </p> <dl><dd><a class="external free" href="https://www.wikidata.org/w/api.php?action=wbgetentities&titles=Andromeda%20Galaxy&sites=enwiki&props=&format=jsonfm&formatversion=2">https://www.wikidata.org/w/api.php?action=wbgetentities&titles=Andromeda%20Galaxy&sites=enwiki&props=&format=jsonfm&formatversion=2</a></dd></dl> <p>Try following the link. This requests no additional information about the entity; remove <code>&props=</code> from the URL to see much more information about it. See the <a href="/wiki/Special:ApiHelp/wbgetentities" title="Special:ApiHelp/wbgetentities">generated help</a> for <code>wbgetentities</code> for more parameters you can specify. </p> <div class="mw-heading mw-heading4"><h4 id="Python" data-mw-thread-id="h-Python-Example_1:_Get_Q_number"><span data-mw-comment-start="" id="h-Python-Example_1:_Get_Q_number"></span>Python<span data-mw-comment-end="h-Python-Example_1:_Get_Q_number"></span></h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=52" title="Edit section: Python"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r2241526210"><div style="margin-left:0px"> <table class="navbox mw-collapsible mw-collapsed" style="background: transparent; text-align: left; border: 1px solid silver; margin-top: 0.2em;"> <tbody><tr> <th style="background-color: #CFC; text-align:center; font-size:112%;">Extended content </th></tr> <tr> <td style="border: solid 1px silver; padding: 8px; background-color: white"> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="ch">#!/usr/bin/python3</span> <span class="kn">from</span> <span class="nn">requests</span> <span class="kn">import</span> <span class="n">get</span> <span class="k">def</span> <span class="nf">get_qnumber</span><span class="p">(</span><span class="n">wikiarticle</span><span class="p">,</span> <span class="n">wikisite</span><span class="p">):</span> <span class="n">resp</span> <span class="o">=</span> <span class="n">get</span><span class="p">(</span><span class="s1">'https://www.wikidata.org/w/api.php'</span><span class="p">,</span> <span class="p">{</span> <span class="s1">'action'</span><span class="p">:</span> <span class="s1">'wbgetentities'</span><span class="p">,</span> <span class="s1">'titles'</span><span class="p">:</span> <span class="n">wikiarticle</span><span class="p">,</span> <span class="s1">'sites'</span><span class="p">:</span> <span class="n">wikisite</span><span class="p">,</span> <span class="s1">'props'</span><span class="p">:</span> <span class="s1">''</span><span class="p">,</span> <span class="s1">'format'</span><span class="p">:</span> <span class="s1">'json'</span> <span class="p">})</span><span class="o">.</span><span class="n">json</span><span class="p">()</span> <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="n">resp</span><span class="p">[</span><span class="s1">'entities'</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span> <span class="nb">print</span><span class="p">(</span><span class="n">get_qnumber</span><span class="p">(</span><span class="n">wikiarticle</span><span class="o">=</span><span class="s2">"Andromeda Galaxy"</span><span class="p">,</span> <span class="n">wikisite</span><span class="o">=</span><span class="s2">"enwiki"</span><span class="p">))</span> </pre></div> </td></tr></tbody></table></div> <p>The output is: </p> <dl><dd><code>Q2469</code></dd></dl> <div class="mw-heading mw-heading3"><h3 id="Example_2:_Get_list_of_items_without_particular_interwiki" data-mw-thread-id="h-Example_2:_Get_list_of_items_without_particular_interwiki-Using_Wikidata's_API_directly"><span data-mw-comment-start="" id="h-Example_2:_Get_list_of_items_without_particular_interwiki-Using_Wikidata's_API_directly"></span>Example 2: Get list of items without particular interwiki<span data-mw-comment-end="h-Example_2:_Get_list_of_items_without_particular_interwiki-Using_Wikidata's_API_directly"></span></h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=53" title="Edit section: Example 2: Get list of items without particular interwiki"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>...please contribute if you know how... </p> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="See_also" data-mw-thread-id="h-See_also"><span data-mw-comment-start="" id="h-See_also"></span>See also<span data-mw-comment-end="h-See_also"></span></h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=54" title="Edit section: See also"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-See_also","replies":[]}}--></div> <ul><li><a href="https://www.mediawiki.org/wiki/Wikidata_Toolkit" class="extiw" title="mw:Wikidata Toolkit">mw:Wikidata Toolkit</a> Java framework</li> <li><a href="/wiki/Special:MyLanguage/Wikidata:Bots" title="Special:MyLanguage/Wikidata:Bots">Wikidata:Bots</a></li> <li><a href="/wiki/Wikidata:Bots_by_function" title="Wikidata:Bots by function">Wikidata:Bots by function</a></li> <li><a href="/wiki/Wikidata:Pywikibot_-_Python_3_Tutorial" title="Wikidata:Pywikibot - Python 3 Tutorial">Wikidata:Pywikibot - Python 3 Tutorial</a></li> <li><a href="/wiki/Wikidata:Sandbox" title="Wikidata:Sandbox">Wikidata:Sandbox</a></li></ul> <div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 id="External_links" data-mw-thread-id="h-External_links"><span data-mw-comment-start="" id="h-External_links"></span>External links<span data-mw-comment-end="h-External_links"></span></h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit&section=55" title="Edit section: External links"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-External_links","replies":[]}}--></div> <ul><li><a href="https://www.mediawiki.org/wiki/Manual:Pywikibot/Wikidata" class="extiw" title="mw:Manual:Pywikibot/Wikidata">mw:Manual:Pywikibot/Wikidata</a></li></ul> <!-- NewPP limit report Parsed by mw‐web.eqiad.main‐7c479b968‐9wrj8 Cached time: 20241115210034 Cache expiry: 2592000 Reduced expiry: false Complications: [show‐toc] DiscussionTools time usage: 0.075 seconds CPU time usage: 0.367 seconds Real time usage: 0.685 seconds Preprocessor visited node count: 1669/1000000 Post‐expand include size: 15268/2097152 bytes Template argument size: 586/2097152 bytes Highest expansion depth: 7/100 Expensive parser function count: 28/500 Unstrip recursion depth: 0/20 Unstrip post‐expand size: 116894/5000000 bytes Lua time usage: 0.072/10.000 seconds Lua memory usage: 1514339/52428800 bytes Number of Wikibase entities loaded: 0/500 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 302.841 1 -total 29.14% 88.251 1 Template:Warning 27.55% 83.419 1 Template:Mbox 12.06% 36.534 12 Template:P 11.78% 35.686 17 Template:Label 5.92% 17.924 24 Template:Collapse_top 3.78% 11.461 2 Template:Ll 3.67% 11.113 5 Template:Q 2.96% 8.974 1 Template:PDT 2.23% 6.747 1 Translations:Wikidata:Bots/Page_display_title/en --> <!-- Saved in parser cache with key wikidatawiki:pcache:idhash:7399363-0!canonical and timestamp 20241115210034 and revision id 2033204669. Rendering was triggered because: page-view --> </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.wikidata.org/w/index.php?title=Wikidata:Creating_a_bot&oldid=2033204669">https://www.wikidata.org/w/index.php?title=Wikidata:Creating_a_bot&oldid=2033204669</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">Categories</a>: <ul><li><a href="/wiki/Category:Wikidata:Bots" title="Category:Wikidata:Bots">Wikidata:Bots</a></li><li><a href="/wiki/Category:Pywikibot_tutorial" title="Category:Pywikibot tutorial">Pywikibot tutorial</a></li><li><a href="/wiki/Category:Wikidata:Creating_a_bot" title="Category:Wikidata:Creating a bot">Wikidata:Creating a bot</a></li><li><a href="/wiki/Category:Wikidata-en" title="Category:Wikidata-en">Wikidata-en</a></li></ul></div></div> </div> </div> <div id="mw-navigation"> <h2>Navigation menu</h2> <div id="mw-head"> <nav id="p-personal" class="mw-portlet mw-portlet-personal vector-user-menu-legacy vector-menu" aria-labelledby="p-personal-label" > <h3 id="p-personal-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">Personal tools</span> </h3> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-uls" class="mw-list-item active"><a class="uls-trigger" href="#"><span>English</span></a></li><li id="pt-anonuserpage" class="mw-list-item"><span title="The user page for the IP address you are editing as">Not logged in</span></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><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-createaccount" class="mw-list-item"><a href="/w/index.php?title=Special:CreateAccount&returnto=Wikidata%3ACreating+a+bot" title="You are encouraged to create an account and log in; however, it is not mandatory"><span>Create account</span></a></li><li id="pt-login" class="mw-list-item"><a href="/w/index.php?title=Special:UserLogin&returnto=Wikidata%3ACreating+a+bot" title="You are encouraged to log in; however, it is not mandatory [o]" accesskey="o"><span>Log in</span></a></li> </ul> </div> </nav> <div id="left-navigation"> <nav id="p-namespaces" class="mw-portlet mw-portlet-namespaces vector-menu-tabs vector-menu-tabs-legacy vector-menu" aria-labelledby="p-namespaces-label" > <h3 id="p-namespaces-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">Namespaces</span> </h3> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-nstab-project" class="selected mw-list-item"><a href="/wiki/Wikidata:Creating_a_bot" title="View the project page [c]" accesskey="c"><span>Project page</span></a></li><li id="ca-talk" class="mw-list-item"><a href="/wiki/Wikidata_talk:Creating_a_bot" rel="discussion" title="Discussion about the content page [t]" accesskey="t"><span>Discussion</span></a></li> </ul> </div> </nav> <nav id="p-variants" class="mw-portlet mw-portlet-variants emptyPortlet vector-menu-dropdown vector-menu" aria-labelledby="p-variants-label" > <input type="checkbox" id="p-variants-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-variants" class="vector-menu-checkbox" aria-labelledby="p-variants-label" > <label id="p-variants-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">English</span> </label> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </nav> </div> <div id="right-navigation"> <nav id="p-views" class="mw-portlet mw-portlet-views vector-menu-tabs vector-menu-tabs-legacy vector-menu" aria-labelledby="p-views-label" > <h3 id="p-views-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">Views</span> </h3> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-view" class="selected mw-list-item"><a href="/wiki/Wikidata:Creating_a_bot"><span>Read</span></a></li><li id="ca-edit" class="mw-list-item"><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=edit" title="Edit this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-history" class="mw-list-item"><a href="/w/index.php?title=Wikidata:Creating_a_bot&action=history" title="Past revisions of this page [h]" accesskey="h"><span>View history</span></a></li> </ul> </div> </nav> <nav id="p-cactions" class="mw-portlet mw-portlet-cactions emptyPortlet vector-menu-dropdown vector-menu" aria-labelledby="p-cactions-label" title="More options" > <input type="checkbox" id="p-cactions-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-cactions" class="vector-menu-checkbox" aria-labelledby="p-cactions-label" > <label id="p-cactions-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">More</span> </label> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </nav> <div id="p-search" role="search" class="vector-search-box-vue vector-search-box"> <h3 >Search</h3> <form action="/w/index.php" id="searchform" class="vector-search-box-form"> <div id="simpleSearch" class="vector-search-box-inner" data-search-loc="header-navigation"> <input class="vector-search-box-input" type="search" name="search" placeholder="Search Wikidata" aria-label="Search Wikidata" autocapitalize="sentences" title="Search Wikidata [f]" accesskey="f" id="searchInput" > <input type="hidden" name="title" value="Special:Search"> <input id="mw-searchButton" class="searchButton mw-fallbackSearchButton" type="submit" name="fulltext" title="Search the pages for this text" value="Search"> <input id="searchButton" class="searchButton" type="submit" name="go" title="Go to a page with this exact name if it exists" value="Go"> </div> </form> </div> </div> </div> <div id="mw-panel" class="vector-legacy-sidebar"> <div id="p-logo" role="banner"> <a class="mw-wiki-logo" href="/wiki/Wikidata:Main_Page" title="Visit the main page"></a> </div> <nav id="p-navigation" class="mw-portlet mw-portlet-navigation vector-menu-portal portal vector-menu" aria-labelledby="p-navigation-label" > <h3 id="p-navigation-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">Navigation</span> </h3> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-mainpage-description" class="mw-list-item"><a href="/wiki/Wikidata:Main_Page" title="Visit the main page [z]" accesskey="z"><span>Main page</span></a></li><li id="n-portal" class="mw-list-item"><a href="/wiki/Special:MyLanguage/Project:Community_portal" title="About the project, what you can do, where to find things"><span>Community portal</span></a></li><li id="n-villagepump" class="mw-list-item"><a href="/wiki/Wikidata:Project_chat"><span>Project chat</span></a></li><li id="n-special-newitem" class="mw-list-item"><a href="/wiki/Special:NewItem"><span>Create a new Item</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-wikibase-randomitem" class="mw-list-item"><a href="/wiki/Special:Random/Main" title="[x]" accesskey="x"><span>Random Item</span></a></li><li id="n-wikibase-queryservice" class="mw-list-item"><a href="//query.wikidata.org/"><span>Query Service</span></a></li><li id="n-nearby-pages-title" class="mw-list-item"><a href="/wiki/Special:Nearby"><span>Nearby</span></a></li><li id="n-help" class="mw-list-item"><a href="/wiki/Special:MyLanguage/Help:Contents" title="The place to find out"><span>Help</span></a></li><li id="n-sitesupport" class="mw-list-item"><a href="//donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&utm_medium=sidebar&utm_campaign=C13_wikidata.org&uselang=en" title="Support us"><span>Donate</span></a></li> </ul> </div> </nav> <nav id="p-wikibase-lexeme-lexicographical-data" class="mw-portlet mw-portlet-wikibase-lexeme-lexicographical-data vector-menu-portal portal vector-menu" aria-labelledby="p-wikibase-lexeme-lexicographical-data-label" > <h3 id="p-wikibase-lexeme-lexicographical-data-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">Lexicographical data</span> </h3> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-special-newlexeme" class="mw-list-item"><a href="/wiki/Special:NewLexeme"><span>Create a new Lexeme</span></a></li><li id="n-recentchanges-lexemes" class="mw-list-item"><a href="https://www.wikidata.org/wiki/Special:RecentChanges?namespace=146%3B147"><span>Recent changes</span></a></li><li id="n-wikibase-lexeme-randomlexeme" class="mw-list-item"><a href="/wiki/Special:Random/Lexeme"><span>Random Lexeme</span></a></li> </ul> </div> </nav> <nav id="p-tb" class="mw-portlet mw-portlet-tb vector-menu-portal portal vector-menu" aria-labelledby="p-tb-label" > <h3 id="p-tb-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">Tools</span> </h3> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="t-whatlinkshere" class="mw-list-item"><a href="/wiki/Special:WhatLinksHere/Wikidata: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/Wikidata: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-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=Wikidata:Creating_a_bot&oldid=2033204669" 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=Wikidata:Creating_a_bot&action=info" title="More information about this page"><span>Page information</span></a></li><li id="t-urlshortener" class="mw-list-item"><a href="/w/index.php?title=Special:UrlShortener&url=https%3A%2F%2Fwww.wikidata.org%2Fwiki%2FWikidata%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.wikidata.org%2Fwiki%2FWikidata%3ACreating_a_bot"><span>Download QR code</span></a></li> </ul> </div> </nav> <nav id="p-coll-print_export" class="mw-portlet mw-portlet-coll-print_export vector-menu-portal portal vector-menu" aria-labelledby="p-coll-print_export-label" > <h3 id="p-coll-print_export-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">Print/export</span> </h3> <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=Wikidata%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=Wikidata%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=Wikidata:Creating_a_bot&printable=yes" title="Printable version of this page [p]" accesskey="p"><span>Printable version</span></a></li> </ul> </div> </nav> <nav id="p-wikibase-otherprojects" class="mw-portlet mw-portlet-wikibase-otherprojects vector-menu-portal portal vector-menu" aria-labelledby="p-wikibase-otherprojects-label" > <h3 id="p-wikibase-otherprojects-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">In other projects</span> </h3> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li class="wb-otherproject-link wb-otherproject-commons mw-list-item"><a href="https://commons.wikimedia.org/wiki/Help:Bots" hreflang="en"><span>Wikimedia Commons</span></a></li><li class="wb-otherproject-link wb-otherproject-mediawiki mw-list-item"><a href="https://www.mediawiki.org/wiki/Help:Bots" hreflang="en"><span>MediaWiki</span></a></li><li class="wb-otherproject-link wb-otherproject-wikipedia mw-list-item"><a href="https://en.wikipedia.org/wiki/Help:Creating_a_bot" hreflang="en"><span>Wikipedia</span></a></li><li id="t-wikibase" class="wb-otherproject-link wb-otherproject-wikibase-dataitem mw-list-item"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q9384748" title="Link to connected data repository item [g]" accesskey="g"><span>Wikidata item</span></a></li> </ul> </div> </nav> <nav id="p-lang" class="mw-portlet mw-portlet-lang vector-menu-portal portal vector-menu" aria-labelledby="p-lang-label" > <h3 id="p-lang-label" class="vector-menu-heading " > <span class="vector-menu-heading-label">In Wikipedia</span> </h3> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li class="interlanguage-link interwiki-ar mw-list-item"><a href="https://ar.wikipedia.org/wiki/%D9%88%D9%8A%D9%83%D9%8A%D8%A8%D9%8A%D8%AF%D9%8A%D8%A7:%D9%83%D9%8A%D9%81_%D8%AA%D8%B5%D9%86%D8%B9_%D8%A8%D9%88%D8%AA" title="ويكيبيديا:كيف تصنع بوت – Arabic" lang="ar" hreflang="ar" data-title="ويكيبيديا:كيف تصنع بوت" data-language-autonym="العربية" data-language-local-name="Arabic" class="interlanguage-link-target"><span>العربية</span></a></li><li class="interlanguage-link interwiki-az mw-list-item"><a href="https://az.wikipedia.org/wiki/Vikipediya:Botun_yarad%C4%B1lmas%C4%B1" title="Vikipediya:Botun yaradılması – Azerbaijani" lang="az" hreflang="az" data-title="Vikipediya:Botun yaradılması" data-language-autonym="Azərbaycanca" data-language-local-name="Azerbaijani" class="interlanguage-link-target"><span>Azərbaycanca</span></a></li><li class="interlanguage-link interwiki-cv mw-list-item"><a href="https://cv.wikipedia.org/wiki/%D0%92%D0%B8%D0%BA%D0%B8%D0%BF%D0%B5%D0%B4%D0%B8:%C3%87%D0%B0%D0%BC%D1%80%C4%83%D0%BA_%D0%B1%D0%BE%D1%82%C3%A7%C4%83_%D0%B2%D0%B0%D0%BB%D0%BB%D0%B8_%D1%81%C4%95%D0%BD%D3%B3%D1%81%D0%B5%D0%BC" title="Википеди:Çамрăк ботçă валли сĕнӳсем – Chuvash" lang="cv" hreflang="cv" data-title="Википеди:Çамрăк ботçă валли сĕнӳсем" data-language-autonym="Чӑвашла" data-language-local-name="Chuvash" class="interlanguage-link-target"><span>Чӑвашла</span></a></li><li class="interlanguage-link interwiki-en mw-list-item"><a href="https://en.wikipedia.org/wiki/Help:Creating_a_bot" title="Help:Creating a bot – English" lang="en" hreflang="en" data-title="Help:Creating a bot" data-language-autonym="English" data-language-local-name="English" class="interlanguage-link-target"><span>English</span></a></li><li class="interlanguage-link interwiki-es mw-list-item"><a href="https://es.wikipedia.org/wiki/Ayuda:C%C3%B3mo_crear_un_bot" title="Ayuda:Cómo crear un bot – Spanish" lang="es" hreflang="es" data-title="Ayuda:Cómo crear un bot" data-language-autonym="Español" data-language-local-name="Spanish" class="interlanguage-link-target"><span>Español</span></a></li><li class="interlanguage-link interwiki-fa mw-list-item"><a href="https://fa.wikipedia.org/wiki/%D9%88%DB%8C%DA%A9%DB%8C%E2%80%8C%D9%BE%D8%AF%DB%8C%D8%A7:%DA%86%DA%AF%D9%88%D9%86%D9%87_%DB%8C%DA%A9_%D8%B1%D8%A8%D8%A7%D8%AA_%D8%A8%D8%B3%D8%A7%D8%B2%DB%8C%D9%85" title="ویکیپدیا:چگونه یک ربات بسازیم – Persian" lang="fa" hreflang="fa" data-title="ویکیپدیا:چگونه یک ربات بسازیم" data-language-autonym="فارسی" data-language-local-name="Persian" class="interlanguage-link-target"><span>فارسی</span></a></li><li class="interlanguage-link interwiki-fr mw-list-item"><a href="https://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Cr%C3%A9er_un_bot" title="Wikipédia:Créer un bot – French" lang="fr" hreflang="fr" data-title="Wikipédia:Créer un bot" data-language-autonym="Français" data-language-local-name="French" class="interlanguage-link-target"><span>Français</span></a></li><li class="interlanguage-link interwiki-gl mw-list-item"><a href="https://gl.wikipedia.org/wiki/Axuda:Usar_bots" title="Axuda:Usar bots – Galician" lang="gl" hreflang="gl" data-title="Axuda:Usar bots" data-language-autonym="Galego" data-language-local-name="Galician" class="interlanguage-link-target"><span>Galego</span></a></li><li class="interlanguage-link interwiki-hi mw-list-item"><a href="https://hi.wikipedia.org/wiki/%E0%A4%B5%E0%A4%BF%E0%A4%95%E0%A4%BF%E0%A4%AA%E0%A5%80%E0%A4%A1%E0%A4%BF%E0%A4%AF%E0%A4%BE:%E0%A4%AC%E0%A5%89%E0%A4%9F_%E0%A4%AC%E0%A4%A8%E0%A4%BE%E0%A4%A8%E0%A5%87_%E0%A4%95%E0%A5%80_%E0%A4%AA%E0%A5%8D%E0%A4%B0%E0%A4%95%E0%A5%8D%E0%A4%B0%E0%A4%BF%E0%A4%AF%E0%A4%BE" title="विकिपीडिया:बॉट बनाने की प्रक्रिया – Hindi" lang="hi" hreflang="hi" data-title="विकिपीडिया:बॉट बनाने की प्रक्रिया" data-language-autonym="हिन्दी" data-language-local-name="Hindi" class="interlanguage-link-target"><span>हिन्दी</span></a></li><li class="interlanguage-link interwiki-hr mw-list-item"><a href="https://hr.wikipedia.org/wiki/Wikipedija:Botovi/Bot" title="Wikipedija:Botovi/Bot – Croatian" lang="hr" hreflang="hr" data-title="Wikipedija:Botovi/Bot" data-language-autonym="Hrvatski" data-language-local-name="Croatian" class="interlanguage-link-target"><span>Hrvatski</span></a></li><li class="interlanguage-link interwiki-id mw-list-item"><a href="https://id.wikipedia.org/wiki/Bantuan:Bot" title="Bantuan:Bot – Indonesian" lang="id" hreflang="id" data-title="Bantuan:Bot" data-language-autonym="Bahasa Indonesia" data-language-local-name="Indonesian" class="interlanguage-link-target"><span>Bahasa Indonesia</span></a></li><li class="interlanguage-link interwiki-ka mw-list-item"><a href="https://ka.wikipedia.org/wiki/%E1%83%95%E1%83%98%E1%83%99%E1%83%98%E1%83%9E%E1%83%94%E1%83%93%E1%83%98%E1%83%90:%E1%83%91%E1%83%9D%E1%83%A2%E1%83%98%E1%83%A1_%E1%83%A8%E1%83%94%E1%83%A5%E1%83%9B%E1%83%9C%E1%83%90" title="ვიკიპედია:ბოტის შექმნა – Georgian" lang="ka" hreflang="ka" data-title="ვიკიპედია:ბოტის შექმნა" data-language-autonym="ქართული" data-language-local-name="Georgian" class="interlanguage-link-target"><span>ქართული</span></a></li><li class="interlanguage-link interwiki-ko mw-list-item"><a href="https://ko.wikipedia.org/wiki/%EB%8F%84%EC%9B%80%EB%A7%90:%EB%B4%87_%EB%A7%8C%EB%93%A4%EA%B8%B0" title="도움말:봇 만들기 – Korean" lang="ko" hreflang="ko" data-title="도움말:봇 만들기" data-language-autonym="한국어" data-language-local-name="Korean" class="interlanguage-link-target"><span>한국어</span></a></li><li class="interlanguage-link interwiki-mk mw-list-item"><a href="https://mk.wikipedia.org/wiki/%D0%92%D0%B8%D0%BA%D0%B8%D0%BF%D0%B5%D0%B4%D0%B8%D1%98%D0%B0:%D0%A1%D0%BE%D0%B7%D0%B4%D0%B0%D0%B2%D0%B0%D1%9A%D0%B5_%D0%BD%D0%B0_%D0%B1%D0%BE%D1%82" title="Википедија:Создавање на бот – Macedonian" lang="mk" hreflang="mk" data-title="Википедија:Создавање на бот" data-language-autonym="Македонски" data-language-local-name="Macedonian" class="interlanguage-link-target"><span>Македонски</span></a></li><li class="interlanguage-link interwiki-ps mw-list-item"><a href="https://ps.wikipedia.org/wiki/%D9%88%D9%8A%DA%A9%D9%8A%D9%BE%DB%90%DA%89%D9%8A%D8%A7:%D9%88%D9%8A%DA%A9%D9%8A_%D8%B1%D9%88%D8%A8%D8%A7%D9%BC_%DA%85%D9%86%DA%AB%D9%87_%D8%AC%D9%88%DA%93_%DA%A9%DA%93%D9%88" title="ويکيپېډيا:ويکي روباټ څنګه جوړ کړو – Pashto" lang="ps" hreflang="ps" data-title="ويکيپېډيا:ويکي روباټ څنګه جوړ کړو" data-language-autonym="پښتو" data-language-local-name="Pashto" class="interlanguage-link-target"><span>پښتو</span></a></li><li class="interlanguage-link interwiki-pt mw-list-item"><a href="https://pt.wikipedia.org/wiki/Wikip%C3%A9dia:Como_criar_um_rob%C3%B4" title="Wikipédia:Como criar um robô – Portuguese" lang="pt" hreflang="pt" data-title="Wikipédia:Como criar um robô" data-language-autonym="Português" data-language-local-name="Portuguese" class="interlanguage-link-target"><span>Português</span></a></li><li class="interlanguage-link interwiki-ru mw-list-item"><a href="https://ru.wikipedia.org/wiki/%D0%92%D0%B8%D0%BA%D0%B8%D0%BF%D0%B5%D0%B4%D0%B8%D1%8F:%D0%A0%D0%B5%D0%BA%D0%BE%D0%BC%D0%B5%D0%BD%D0%B4%D0%B0%D1%86%D0%B8%D0%B8_%D1%8E%D0%BD%D0%BE%D0%BC%D1%83_%D0%B1%D0%BE%D1%82%D0%BE%D0%B2%D0%BE%D0%B4%D1%83" title="Википедия:Рекомендации юному ботоводу – Russian" lang="ru" hreflang="ru" data-title="Википедия:Рекомендации юному ботоводу" data-language-autonym="Русский" data-language-local-name="Russian" class="interlanguage-link-target"><span>Русский</span></a></li><li class="interlanguage-link interwiki-sr mw-list-item"><a href="https://sr.wikipedia.org/wiki/%D0%92%D0%B8%D0%BA%D0%B8%D0%BF%D0%B5%D0%B4%D0%B8%D1%98%D0%B0:%D0%9F%D1%80%D0%B0%D0%B2%D1%99%D0%B5%D1%9A%D0%B5_%D0%B1%D0%BE%D1%82%D0%B0" title="Википедија:Прављење бота – Serbian" lang="sr" hreflang="sr" data-title="Википедија:Прављење бота" data-language-autonym="Српски / srpski" data-language-local-name="Serbian" class="interlanguage-link-target"><span>Српски / srpski</span></a></li><li class="interlanguage-link interwiki-sv badge-Q70894304 mw-list-item" title=""><a href="https://sv.wikipedia.org/wiki/Wikipedia:Skaffa_bot" title="Wikipedia:Skaffa bot – Swedish" lang="sv" hreflang="sv" data-title="Wikipedia:Skaffa bot" data-language-autonym="Svenska" data-language-local-name="Swedish" class="interlanguage-link-target"><span>Svenska</span></a></li><li class="interlanguage-link interwiki-te mw-list-item"><a href="https://te.wikipedia.org/wiki/%E0%B0%B5%E0%B0%BF%E0%B0%95%E0%B1%80%E0%B0%AA%E0%B1%80%E0%B0%A1%E0%B0%BF%E0%B0%AF%E0%B0%BE:%E0%B0%AC%E0%B0%BE%E0%B0%9F%E0%B1%81_%E0%B0%B8%E0%B1%83%E0%B0%B7%E0%B1%8D%E0%B0%9F%E0%B0%BF%E0%B0%82%E0%B0%9A%E0%B0%A1%E0%B0%82_%E0%B0%8E%E0%B0%B2%E0%B0%BE%3F" title="వికీపీడియా:బాటు సృష్టించడం ఎలా? – Telugu" lang="te" hreflang="te" data-title="వికీపీడియా:బాటు సృష్టించడం ఎలా?" data-language-autonym="తెలుగు" data-language-local-name="Telugu" class="interlanguage-link-target"><span>తెలుగు</span></a></li><li class="interlanguage-link interwiki-tr mw-list-item"><a href="https://tr.wikipedia.org/wiki/Yard%C4%B1m:Bot_olu%C5%9Fturma" title="Yardım:Bot oluşturma – Turkish" lang="tr" hreflang="tr" data-title="Yardım:Bot oluşturma" data-language-autonym="Türkçe" data-language-local-name="Turkish" class="interlanguage-link-target"><span>Türkçe</span></a></li><li class="interlanguage-link interwiki-tt mw-list-item"><a href="https://tt.wikipedia.org/wiki/%D0%92%D0%B8%D0%BA%D0%B8%D0%BF%D0%B5%D0%B4%D0%B8%D1%8F:%D0%91%D0%BE%D1%82_%D1%83%D1%80%D0%BD%D0%B0%D1%88%D1%82%D1%8B%D1%80%D1%83_%D2%BB%D3%99%D0%BC_%D0%BA%D1%83%D0%BB%D0%BB%D0%B0%D0%BD%D1%83" title="Википедия:Бот урнаштыру һәм куллану – Tatar" lang="tt" hreflang="tt" data-title="Википедия:Бот урнаштыру һәм куллану" data-language-autonym="Татарча / tatarça" data-language-local-name="Tatar" class="interlanguage-link-target"><span>Татарча / tatarça</span></a></li><li class="interlanguage-link interwiki-ur mw-list-item"><a href="https://ur.wikipedia.org/wiki/%D9%88%DB%8C%DA%A9%DB%8C%D9%BE%DB%8C%DA%88%DB%8C%D8%A7:%D8%AA%D8%AE%D9%84%DB%8C%D9%82_%D8%B1%D9%88%D8%A8%DB%81" title="ویکیپیڈیا:تخلیق روبہ – Urdu" lang="ur" hreflang="ur" data-title="ویکیپیڈیا:تخلیق روبہ" data-language-autonym="اردو" data-language-local-name="Urdu" class="interlanguage-link-target"><span>اردو</span></a></li><li class="interlanguage-link interwiki-vi mw-list-item"><a href="https://vi.wikipedia.org/wiki/Wikipedia:T%E1%BA%A1o_bot" title="Wikipedia:Tạo bot – Vietnamese" lang="vi" hreflang="vi" data-title="Wikipedia:Tạo bot" data-language-autonym="Tiếng Việt" data-language-local-name="Vietnamese" class="interlanguage-link-target"><span>Tiếng Việt</span></a></li><li class="interlanguage-link interwiki-zh mw-list-item"><a href="https://zh.wikipedia.org/wiki/Wikipedia:%E8%A3%BD%E4%BD%9C%E6%A9%9F%E5%99%A8%E4%BA%BA" title="Wikipedia:製作機器人 – Chinese" lang="zh" hreflang="zh" data-title="Wikipedia:製作機器人" data-language-autonym="中文" data-language-local-name="Chinese" class="interlanguage-link-target"><span>中文</span></a></li><li class="interlanguage-link interwiki-zh-yue mw-list-item"><a href="https://zh-yue.wikipedia.org/wiki/Help:%E6%A9%9F%E6%A2%B0%E4%BA%BA" title="Help:機械人 – Cantonese" lang="yue" hreflang="yue" data-title="Help:機械人" data-language-autonym="粵語" data-language-local-name="Cantonese" class="interlanguage-link-target"><span>粵語</span></a></li> </ul> <div class="after-portlet after-portlet-lang"><span class="wb-langlinks-edit wb-langlinks-link"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q9384748#sitelinks-wikipedia" title="Edit interlanguage links" class="wbc-editpage">Edit links</a></span></div> </div> </nav> </div> </div> <footer id="footer" class="mw-footer" > <ul id="footer-info"> <li id="footer-info-lastmod"> This page was last edited on 20 December 2023, at 14:07.</li> <li id="footer-info-copyright">All structured data from the main, Property, Lexeme, and EntitySchema namespaces is available under the <a rel="nofollow" class="external text" href="//creativecommons.org/publicdomain/zero/1.0/">Creative Commons CC0 License</a>; text in the other namespaces is available under the <a rel="nofollow" class="external text" href="//creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike License</a>; additional terms may apply. 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/Special:MyLanguage/Project:Introduction">About Wikidata</a></li> <li id="footer-places-disclaimers"><a href="/wiki/Special:MyLanguage/Project:General_disclaimer">Disclaimers</a></li> <li id="footer-places-wm-codeofconduct"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Universal_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.wikidata.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.wikidata.org/w/index.php?title=Wikidata:Creating_a_bot&mobileaction=toggle_view_mobile" class="noprint stopMobileRedirectToggle">Mobile view</a></li> <li id="footer-places-data-access"><a href="/wiki/Special:MyLanguage/Wikidata:Data_access">Data access</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> <script>(RLQ=window.RLQ||[]).push(function(){mw.log.warn("This page is using the deprecated ResourceLoader module \"codex-search-styles\".\n[1.43] Use a CodexModule with codexComponents to set your specific components used: https://www.mediawiki.org/wiki/Codex#Using_a_limited_subset_of_components");mw.config.set({"wgHostname":"mw-web.codfw.main-84d8f4b96-4bcnq","wgBackendResponseTime":188,"wgDiscussionToolsPageThreads":[{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Requirements","replies":[]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Recommendation","replies":[]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Pywikibot","replies":[{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Installation-Pywikibot","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Configuration-Pywikibot","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Login-Pywikibot","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_1:_Get_data-Pywikibot","replies":[{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-Alternatives-Example_1:_Get_data","replies":[]}]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_2:_Get_interwiki_links-Pywikibot","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_4:_Set_a_description-Pywikibot","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_6:_Set_a_sitelink-Pywikibot","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_7:_Set_a_statement-Pywikibot","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_8:_Add_a_qualifier-Pywikibot","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_9:_Add_a_source-Pywikibot","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_10:_Page_generators-Pywikibot","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_11:_Get_values_of_sub-properties-Pywikibot","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-More_examples-Pywikibot","replies":[]}]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Wikidata_Integrator","replies":[{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_Notebook-Wikidata_Integrator","replies":[]}]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-WikibaseIntegrator","replies":[{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_semi-automatic_script-WikibaseIntegrator","replies":[]}]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Wikibase.NET_(Deprecated)","replies":[{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Download_\u0026_Installation-Wikibase.NET_(Deprecated)","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Known_issues-Wikibase.NET_(Deprecated)","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Examples-Wikibase.NET_(Deprecated)","replies":[]}]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-DotNetDataBot_(Deprecated)","replies":[{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Installation_2-DotNetDataBot_(Deprecated)","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Configuration_2-DotNetDataBot_(Deprecated)","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Login_2-DotNetDataBot_(Deprecated)","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_1:_Get_id_using_wiki_page-DotNetDataBot_(Deprecated)","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_2:_Get_interwiki_links_2-DotNetDataBot_(Deprecated)","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_3:_Set_a_description-DotNetDataBot_(Deprecated)","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_4:_Set_a_label-DotNetDataBot_(Deprecated)","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_5:_Get_interwiki_links_for_100_pages-DotNetDataBot_(Deprecated)","replies":[]}]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Wikibase_api_for_PHP","replies":[{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_1:_Basic_example-Wikibase_api_for_PHP","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_2:_Creating_claims-Wikibase_api_for_PHP","replies":[]}]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-VBot_(no_updates_since_2017)","replies":[{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Overview-VBot_(no_updates_since_2017)","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Download-VBot_(no_updates_since_2017)","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Instruction-VBot_(no_updates_since_2017)","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_1-VBot_(no_updates_since_2017)","replies":[]}]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-LexData_(Python;_for_Lexicographical_data)","replies":[{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Tips-LexData_(Python;_for_Lexicographical_data)","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Installation_3-LexData_(Python;_for_Lexicographical_data)","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Login_3-LexData_(Python;_for_Lexicographical_data)","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Retrieve_a_Lexeme-LexData_(Python;_for_Lexicographical_data)","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Searching_and_creating_Lexemes-LexData_(Python;_for_Lexicographical_data)","replies":[]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Adding_information-LexData_(Python;_for_Lexicographical_data)","replies":[]}]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-Using_Wikidata's_API_directly","replies":[{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_1:_Get_Q_number-Using_Wikidata's_API_directly","replies":[{"headingLevel":4,"name":"h-","type":"heading","level":0,"id":"h-Python-Example_1:_Get_Q_number","replies":[]}]},{"headingLevel":3,"name":"h-","type":"heading","level":0,"id":"h-Example_2:_Get_list_of_items_without_particular_interwiki-Using_Wikidata's_API_directly","replies":[]}]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-See_also","replies":[]},{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-External_links","replies":[]}],"wgPageParseReport":{"discussiontools":{"limitreport-timeusage":"0.075"},"limitreport":{"cputime":"0.367","walltime":"0.685","ppvisitednodes":{"value":1669,"limit":1000000},"postexpandincludesize":{"value":15268,"limit":2097152},"templateargumentsize":{"value":586,"limit":2097152},"expansiondepth":{"value":7,"limit":100},"expensivefunctioncount":{"value":28,"limit":500},"unstrip-depth":{"value":0,"limit":20},"unstrip-size":{"value":116894,"limit":5000000},"entityaccesscount":{"value":0,"limit":500},"timingprofile":["100.00% 302.841 1 -total"," 29.14% 88.251 1 Template:Warning"," 27.55% 83.419 1 Template:Mbox"," 12.06% 36.534 12 Template:P"," 11.78% 35.686 17 Template:Label"," 5.92% 17.924 24 Template:Collapse_top"," 3.78% 11.461 2 Template:Ll"," 3.67% 11.113 5 Template:Q"," 2.96% 8.974 1 Template:PDT"," 2.23% 6.747 1 Translations:Wikidata:Bots/Page_display_title/en"]},"scribunto":{"limitreport-timeusage":{"value":"0.072","limit":"10.000"},"limitreport-memusage":{"value":1514339,"limit":52428800}},"cachereport":{"origin":"mw-web.eqiad.main-7c479b968-9wrj8","timestamp":"20241115210034","ttl":2592000,"transientcontent":false}}});});</script> </body> </html>