{"id":13585815,"url":"https://github.com/siznax/wptools","last_synced_at":"2025-05-15T23:03:45.108Z","repository":{"id":2397465,"uuid":"3364155","full_name":"siznax/wptools","owner":"siznax","description":"Wikipedia tools (for Humans): easily extract data from Wikipedia, Wikidata, and other MediaWikis","archived":false,"fork":false,"pushed_at":"2023-08-05T19:06:41.000Z","size":1191,"stargazers_count":586,"open_issues_count":39,"forks_count":78,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-05-15T23:03:18.622Z","etag":null,"topics":["api-client","commons","data-science","glam","linked-open-data","mediawiki","mediawiki-api","open-data","python","restbase","wikidata","wikimedia-commons","wikipedia","wikipedia-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/siznax.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2012-02-06T04:10:27.000Z","updated_at":"2025-05-07T10:02:16.000Z","dependencies_parsed_at":"2022-08-06T12:15:17.623Z","dependency_job_id":"079c03f5-0106-4e2b-99ca-87f2747871f2","html_url":"https://github.com/siznax/wptools","commit_stats":{"total_commits":775,"total_committers":12,"mean_commits":64.58333333333333,"dds":0.04387096774193544,"last_synced_commit":"a98a544f206a62c9f04fd34c0805825a8d531936"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siznax%2Fwptools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siznax%2Fwptools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siznax%2Fwptools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siznax%2Fwptools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/siznax","download_url":"https://codeload.github.com/siznax/wptools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254436944,"owners_count":22070946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","commons","data-science","glam","linked-open-data","mediawiki","mediawiki-api","open-data","python","restbase","wikidata","wikimedia-commons","wikipedia","wikipedia-api"],"created_at":"2024-08-01T15:05:09.620Z","updated_at":"2025-05-15T23:03:45.064Z","avatar_url":"https://github.com/siznax.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"Wikipedia tools (for Humans)\n============================\n\n.. image:: https://img.shields.io/pypi/v/wptools.svg\n        :target: https://pypi.python.org/pypi/wptools/\n\n.. image:: https://travis-ci.org/siznax/wptools.svg?branch=master\n        :target: https://travis-ci.org/siznax/wptools\n\n.. image:: https://coveralls.io/repos/github/siznax/wptools/badge.svg?branch=master\n        :target: https://coveralls.io/github/siznax/wptools\n\nPython and command-line MediaWiki access for Humans\n\n- get page extracts, image, Infobox data, Wikidata, and more\n- get a random page, category, or site\n- get page statistics\n- get category members\n- get site info and stats\n- get data in any language\n\nThis package is intended to make it as easy as possible to get data\nfrom MediaWiki instances, expose more Wikidata, and extend Wikimedia\nAPIs just for kicks. We say \"(for Humans)\" because that is a goal_.\nQuestions, feedback, and especially contributions_ are welcome!\n\n\nInstall\n-------\n\n.. code-block:: bash\n\n    $ pip install wptools\n    ✨🦄✨\n\n\nExample\n-------\n\n.. code-block:: python\n\n    \u003e\u003e\u003e import wptools\n\n\nGet a page object:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e page = wptools.page('Gandhi')\n\n\nGet `API:Query`_ data:\n\n.. _`API:Query`: https://www.mediawiki.org/wiki/API:Query\n\n.. code-block:: python\n\n    \u003e\u003e\u003e page.get_query()\n    en.wikipedia.org (query) Gandhi\n    en.wikipedia.org (imageinfo) File:Portrait Gandhi.jpg\n    Mahatma Gandhi (en) data\n    {\n      aliases: \u003clist(10)\u003e M K Gandhi, Mohandas Gandhi, Bapu, Gandhi, M...\n      assessments: \u003cdict(10)\u003e Pakistan, Alternative Views, South Afric...\n      description: \u003cstr(67)\u003e pre-eminent leader of Indian nationalism ...\n      extext: \u003cstr(3077)\u003e Mahātmā **Mohandas Karamchand Gandhi** ( ; H...\n      extract: \u003cstr(3372)\u003e \u003cp\u003eMahātmā \u003cb\u003eMohandas Karamchand Gandhi\u003c/b...\n      image: \u003clist(2)\u003e {u'size': 2951123, 'kind': 'query-pageimage', u...\n      label: Mahatma Gandhi\n      length: 262,790\n      links: \u003clist(500)\u003e 10 Janpath, 14th Dalai Lama, 1915 Singapore M...\n      modified: \u003cdict(1)\u003e page\n      pageid: 19379\n      random: Salt\n      redirected: \u003clist(1)\u003e {u'to': u'Mahatma Gandhi', u'from': u'Gandhi'}\n      redirects: \u003clist(53)\u003e {u'ns': 0, u'pageid': 55342, u'title': u'M...\n      requests: \u003clist(2)\u003e query, imageinfo\n      title: Mahatma Gandhi\n      url: https://en.wikipedia.org/wiki/Mahatma_Gandhi\n      url_raw: https://en.wikipedia.org/wiki/Mahatma_Gandhi?action=raw\n      watchers: 1,811\n      wikibase: Q1001\n      wikidata_url: https://www.wikidata.org/wiki/Q1001\n    }\n\n\nGet `API:Parse`_ data:\n\n.. _`API:Parse`: https://www.mediawiki.org/wiki/API:Parse\n\n.. code-block:: python\n\n    \u003e\u003e\u003e page.get_parse()\n    en.wikipedia.org (parse) Gandhi\n    en.wikipedia.org (imageinfo) File:MKGandhi.jpg\n    Mahatma Gandhi (en) data\n    {\n      image: \u003clist(1)\u003e {u'size': 2951123, 'kind': 'parse-image', u'des...\n      infobox: \u003cdict(25)\u003e known_for, other_names, image, signature, bi...\n      iwlinks: \u003clist(10)\u003e https://biblio.wiki/wiki/Mohandas_K._Gandhi,...\n      pageid: 19379\n      parsetree: \u003cstr(331808)\u003e \u003croot\u003e\u003ctemplate\u003e\u003ctitle\u003eRedirect\u003c/title\u003e...\n      requests: \u003clist(2)\u003e parse, imageinfo\n      title: Mahatma Gandhi\n      wikibase: Q1001\n      wikidata_url: https://www.wikidata.org/wiki/Q1001\n      wikitext: \u003cstr(261349)\u003e {{Redirect|Gandhi}}{{pp-move-indef}}{{pp...\n    }\n\n\nGet Wikidata_:\n\n.. _Wikidata: https://www.wikidata.org/w/api.php\n\n.. code-block:: python\n\n    \u003e\u003e\u003e page = wptools.page(wikibase='Q1001')\n    \u003e\u003e\u003e page.get_wikidata()\n    www.wikidata.org (wikidata) Q1001\n    www.wikidata.org (labels) Q1280678|P535|P434|Q1860|P3762|Q668|P12...\n    www.wikidata.org (labels) P119|Q1930187|P691|P18|P19|P1066|P509|P...\n    www.wikidata.org (labels) Q6512732|Q1568|P972|Q84|P1430|P31|Q2140...\n    www.wikidata.org (labels) P1576|Q4964182|P1368|P140|Q22336956|P12...\n    en.wikipedia.org (imageinfo) File:Portrait Gandhi.jpg\n    Mahatma Gandhi (en) data\n    {\n      aliases: \u003clist(10)\u003e M K Gandhi, Mohandas Gandhi, Bapu, Gandhi, M...\n      claims: \u003cdict(113)\u003e P646, P535, P906, P434, P648, P3762, P1711, ...\n      description: \u003cstr(67)\u003e pre-eminent leader of Indian nationalism ...\n      image: \u003clist(1)\u003e {u'size': 2951123, 'kind': 'wikidata-image', u'...\n      label: Mahatma Gandhi\n      labels: \u003cdict(171)\u003e Q1280678, P535, Q131149, P434, Q1860, P3762,...\n      modified: \u003cdict(1)\u003e wikidata\n      requests: \u003clist(6)\u003e wikidata, labels, labels, labels, labels, im...\n      title: Mahatma_Gandhi\n      what: human\n      wikibase: Q1001\n      wikidata: \u003cdict(112)\u003e Geni.com profile ID (P2600), National Libr...\n      wikidata_pageid: 1330\n      wikidata_url: https://www.wikidata.org/wiki/Q1001\n    }\n\n\nGet RESTBase_ data:\n\n.. _RESTBase: https://www.mediawiki.org/wiki/RESTBase\n\n.. code-block:: python\n\n    \u003e\u003e\u003e page.get_restbase('/page/summary/')\n    en.wikipedia.org (restbase) /page/summary/Gandhi\n    Mahatma Gandhi (en) data\n    {\n      description: \u003cstr(67)\u003e pre-eminent leader of Indian nationalism ...\n      exhtml: \u003cstr(1168)\u003e \u003cp\u003eMahātmā \u003cb\u003eMohandas Karamchand Gandhi\u003c/b\u003e...\n      exrest: \u003cstr(931)\u003e Mahātmā Mohandas Karamchand Gandhi (; Hindust...\n      image: \u003clist(2)\u003e {'kind': 'restbase-original', u'width': 2024, '...\n      pageid: 19379\n      requests: \u003clist(1)\u003e restbase\n      title: Mahatma_Gandhi\n      url: https://en.wikipedia.org/wiki/Gandhi\n      url_raw: https://en.wikipedia.org/wiki/Gandhi?action=raw\n    }\n\n\nGet all the things (at once):\n\n.. code-block:: python\n\n    \u003e\u003e\u003e page.get()\n    en.wikipedia.org (query) Gandhi\n    en.wikipedia.org (parse) 19379\n    www.wikidata.org (wikidata) Q1001\n    www.wikidata.org (labels) Q1280678|P535|P434|Q1860|P3762|Q668|P12...\n    www.wikidata.org (labels) P119|Q1930187|P691|P18|P19|P1066|P509|P...\n    www.wikidata.org (labels) Q6512732|Q1568|P972|Q84|P1430|P31|Q2140...\n    www.wikidata.org (labels) P1576|Q4964182|P1368|P140|Q22336956|P12...\n    en.wikipedia.org (restbase) /page/summary/Mahatma_Gandhi\n    en.wikipedia.org (imageinfo) File:MKGandhi.jpg|File:Portrait Gandhi.jpg\n    Mahatma Gandhi (en) data\n    {\n      aliases: \u003clist(10)\u003e M K Gandhi, Mohandas Gandhi, Bapu, Gandhi, M...\n      assessments: \u003cdict(10)\u003e Pakistan, Alternative Views, South Afric...\n      claims: \u003cdict(113)\u003e P646, P535, P906, P434, P648, P3762, P1711, ...\n      description: \u003cstr(67)\u003e pre-eminent leader of Indian nationalism ...\n      exhtml: \u003cstr(1168)\u003e \u003cp\u003eMahātmā \u003cb\u003eMohandas Karamchand Gandhi\u003c/b\u003e...\n      exrest: \u003cstr(931)\u003e Mahātmā Mohandas Karamchand Gandhi (; Hindust...\n      extext: \u003cstr(3077)\u003e Mahātmā **Mohandas Karamchand Gandhi** ( ; H...\n      extract: \u003cstr(3372)\u003e \u003cp\u003eMahātmā \u003cb\u003eMohandas Karamchand Gandhi\u003c/b...\n      image: \u003clist(6)\u003e {u'size': 2951123, 'kind': 'query-pageimage', u...\n      infobox: \u003cdict(25)\u003e known_for, other_names, image, signature, bi...\n      iwlinks: \u003clist(10)\u003e https://biblio.wiki/wiki/Mohandas_K._Gandhi,...\n      label: Mahatma Gandhi\n      labels: \u003cdict(171)\u003e Q1280678, P535, Q131149, P434, Q1860, P3762,...\n      length: 262,790\n      links: \u003clist(500)\u003e 10 Janpath, 14th Dalai Lama, 1915 Singapore M...\n      modified: \u003cdict(2)\u003e wikidata, page\n      pageid: 19379\n      parsetree: \u003cstr(331808)\u003e \u003croot\u003e\u003ctemplate\u003e\u003ctitle\u003eRedirect\u003c/title\u003e...\n      random: Salt\n      redirected: \u003clist(1)\u003e {u'to': u'Mahatma Gandhi', u'from': u'Gandhi'}\n      redirects: \u003clist(53)\u003e {u'ns': 0, u'pageid': 55342, u'title': u'M...\n      requests: \u003clist(9)\u003e query, parse, wikidata, labels, labels, labe...\n      title: Mahatma_Gandhi\n      url: https://en.wikipedia.org/wiki/Mahatma_Gandhi\n      url_raw: https://en.wikipedia.org/wiki/Mahatma_Gandhi?action=raw\n      watchers: 1,811\n      what: human\n      wikibase: Q1001\n      wikidata: \u003cdict(112)\u003e Geni.com profile ID (P2600), National Libr...\n      wikidata_pageid: 1330\n      wikidata_url: https://www.wikidata.org/wiki/Q1001\n      wikitext: \u003cstr(261349)\u003e {{Redirect|Gandhi}}{{pp-move-indef}}{{pp...\n    }\n\n\nGet more (expensive) data:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e page.get_more()\n    en.wikipedia.org (querymore) Gandhi\n    Mahatma Gandhi (en) data\n    {\n      categories: \u003clist(68)\u003e Category:1869 births, Category:1948 death...\n      contributors: 2,606\n      files: \u003clist(53)\u003e File:Aum Om red.svg, File:Commons-logo.svg, Fi...\n      languages: \u003clist(168)\u003e {u'lang': u'af', u'title': u'Mahatma Gand...\n      pageid: 19379\n      redirected: \u003clist(1)\u003e {u'to': u'Mahatma Gandhi', u'from': u'Gandhi'}\n      requests: \u003clist(1)\u003e querymore\n      title: Mahatma Gandhi\n      views: 19,242\n    }\n\n\nGet data in `another language`_:\n\n.. _`another language`: https://github.com/siznax/wptools/wiki/Language-Codes\n\n.. code-block:: python\n\n    \u003e\u003e\u003e page = wptools.page(lang='zh')\n    zh.wikipedia.org (random) 🍰\n    哈莉特·塔布曼 (zh) data\n    {\n      pageid: 211070\n      title: 哈莉特·塔布曼\n    }\n\n\nGet data from `another wiki`_:\n\n.. _`another wiki`: https://meta.wikimedia.org/wiki/List_of_Wikipedias\n\n.. code-block:: python\n\n    \u003e\u003e\u003e page = wptools.page(wiki='en.wikiquote.org')\n    en.wikiquote.org (random) 🍪\n    Malala_Yousafzai (en)\n    {\n      pageid: 146817\n      title: Malala_Yousafzai\n    }\n\n\nDocumentation\n-------------\n\nSee our wiki_.\n\n\nPlease enjoy!\n\n\n@siznax 👹\n\n\n.. _contributions: https://github.com/siznax/wptools/blob/master/CONTRIBUTING.md\n.. _goal: http://docs.python-requests.org/en/master/user/intro/\n.. _wiki: https://github.com/siznax/wptools/wiki\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiznax%2Fwptools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiznax%2Fwptools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiznax%2Fwptools/lists"}