├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── apps ├── account-creator │ ├── README.md │ ├── app.py │ ├── requirements.txt │ ├── screenshot.png │ ├── static │ │ └── account_form.css │ └── templates │ │ └── create_account_form.html ├── article-ideas-generator │ ├── README.md │ ├── app.py │ ├── requirements.txt │ ├── static │ │ └── style.css │ └── templates │ │ └── articles.html ├── client-login │ ├── README.md │ ├── clientlogin.py │ ├── screenshot.png │ ├── static │ │ └── login_form.css │ └── templates │ │ └── clientlogin_form.html ├── holidays-viewer │ ├── README.md │ ├── app.py │ ├── requirements.txt │ ├── screenshots │ │ ├── add.png │ │ ├── list-holidays.png │ │ ├── login.png │ │ └── search.png │ ├── static │ │ ├── style.css │ │ └── update-links.js │ └── templates │ │ ├── add.html │ │ ├── index.html │ │ ├── layout.html │ │ ├── login.html │ │ └── search.html ├── nearby-places-viewer │ ├── README.md │ ├── app.py │ ├── requirements.txt │ ├── screenshot.png │ ├── static │ │ ├── places.js │ │ └── style.css │ └── templates │ │ └── places.html ├── picture-of-the-day-viewer │ ├── README.md │ ├── app.py │ ├── requirements.txt │ ├── screenshot.png │ ├── static │ │ └── style.css │ └── templates │ │ └── index.html ├── qrcode-generator │ ├── README.md │ ├── app.py │ ├── config.yaml │ ├── requirements.txt │ ├── screenshot.png │ ├── static │ │ ├── qrcode-generator.js │ │ ├── qrcodes │ │ │ └── .gitkeep │ │ └── style.css │ └── templates │ │ ├── base.html │ │ ├── index.html │ │ └── upload.html └── user-contributions-feed │ ├── README.md │ ├── app.py │ ├── screenshot.png │ ├── static │ └── style.css │ └── templates │ └── user_contributions.html ├── autogenerator.py ├── contributing.md ├── gallery ├── README.md ├── apps.json ├── contributing.md ├── gallery.py ├── static │ ├── addlingue.png │ ├── afd-stats.png │ ├── article_ideas_generator.png │ ├── create_account_with_captcha.png │ ├── create_login.png │ ├── holidays-viewer.png │ ├── logo.png │ ├── mass-mailer.png │ ├── mediawiki-benchmarker.png │ ├── nearby_places_viewer.png │ ├── oauth-hello-world.png │ ├── parliament-diagram-generator.png │ ├── picture_of_the_day_viewer.png │ ├── ptable.png │ ├── qrcode-generator.png │ ├── quote-mashup.png │ ├── reccat.png │ ├── recent-deaths.png │ ├── sightseer-map.png │ ├── speed-patrolling.png │ ├── style.css │ ├── user_contributions_feed.png │ ├── vizquery.png │ ├── wiki-search.png │ ├── wikidata-skim.png │ ├── wikidata-translate.png │ ├── wikifeedia.png │ ├── wikipedia-viewer.png │ └── wikipedia_search_starter.png └── templates │ └── apps.html ├── javascript ├── README.md ├── all_messages.js ├── block_user.js ├── change_user_options.js ├── check_token.js ├── clear_has_msg.js ├── compare.js ├── create_account.js ├── delete.js ├── deleted_revisions.js ├── duplicate_files.js ├── edit.js ├── expand_templates.js ├── file_archive.js ├── file_repo_info.js ├── filearchive.js ├── general_site_info.js ├── geocoordinates.js ├── geoimagesearch.js ├── geosearch.js ├── get_allcategories.js ├── get_alldeletedrevs.js ├── get_allfileusages.js ├── get_allimages_by_date.js ├── get_allimages_by_name.js ├── get_alllinks.js ├── get_allpages.js ├── get_allredirects.js ├── get_allrevisions.js ├── get_alltransclusions.js ├── get_allusers.js ├── get_backlinks.js ├── get_blocked_users.js ├── get_categories.js ├── get_category_info.js ├── get_category_items.js ├── get_contributors.js ├── get_deleted_revisions.js ├── get_deleted_revs.js ├── get_embedded_pages.js ├── get_extlinks.js ├── get_exturlusage.js ├── get_feed_recent_changes.js ├── get_file_usage.js ├── get_filtered_page_revisions.js ├── get_help.js ├── get_imageinfo.js ├── get_imageusage.js ├── get_info.js ├── get_iwlinks.js ├── get_links.js ├── get_logevents.js ├── get_my_watchlist_feed.js ├── get_page_images.js ├── get_pagepropnames.js ├── get_pages_revisions.js ├── get_pageswithprop.js ├── get_protectedtitles.js ├── get_querypage_list.js ├── get_random.js ├── get_recent_category_items.js ├── get_recent_changes.js ├── get_red_links.js ├── get_redirects.js ├── get_subcategories.js ├── get_tags.js ├── get_transcluded_in.js ├── get_user_contributions_feed.js ├── get_user_watchlist_feed.js ├── get_usercontribs.js ├── get_users.js ├── get_watchlist.js ├── get_watchlistraw.js ├── import_interwiki.js ├── import_xml.js ├── iwbacklinks.js ├── langbacklinks.js ├── langlinks.js ├── languagesearch.js ├── linkshere.js ├── login.js ├── logout.js ├── main_module.js ├── mergehistory.js ├── move.js ├── opensearch.js ├── pageprops.js ├── paraminfo.js ├── parse.js ├── patrol.js ├── prefixsearch.js ├── protect.js ├── purge_namespace_pages.js ├── purge_two_pages.js ├── reset_password.js ├── revision_delete.js ├── rollback.js ├── rsd.js ├── search.js ├── send_email.js ├── set_notification_timestamp.js ├── set_page_language.js ├── stash_image_info.js ├── stashedit.js ├── tag.js ├── templates.js ├── tokens.js ├── undelete.js ├── upload_file_directly.js ├── upload_file_from_url.js ├── upload_file_in_chunks.js ├── userinfo.js ├── userrights.js ├── validatepassword.js └── watch.js ├── mediawikijs ├── README.md ├── all_messages.js ├── block_user.js ├── change_user_options.js ├── check_token.js ├── clear_has_msg.js ├── compare.js ├── create_account.js ├── delete.js ├── deleted_revisions.js ├── duplicate_files.js ├── edit.js ├── expand_templates.js ├── file_archive.js ├── file_repo_info.js ├── filearchive.js ├── general_site_info.js ├── geocoordinates.js ├── geoimagesearch.js ├── geosearch.js ├── get_allcategories.js ├── get_alldeletedrevs.js ├── get_allfileusages.js ├── get_allimages_by_date.js ├── get_allimages_by_name.js ├── get_alllinks.js ├── get_allpages.js ├── get_allredirects.js ├── get_allrevisions.js ├── get_alltransclusions.js ├── get_allusers.js ├── get_backlinks.js ├── get_blocked_users.js ├── get_categories.js ├── get_category_info.js ├── get_category_items.js ├── get_contributors.js ├── get_deleted_revisions.js ├── get_deleted_revs.js ├── get_embedded_pages.js ├── get_extlinks.js ├── get_exturlusage.js ├── get_feed_recent_changes.js ├── get_file_usage.js ├── get_filtered_page_revisions.js ├── get_help.js ├── get_imageinfo.js ├── get_imageusage.js ├── get_info.js ├── get_iwlinks.js ├── get_links.js ├── get_logevents.js ├── get_page_images.js ├── get_pagepropnames.js ├── get_pages_revisions.js ├── get_pageswithprop.js ├── get_protectedtitles.js ├── get_querypage_list.js ├── get_random.js ├── get_recent_category_items.js ├── get_recent_changes.js ├── get_red_links.js ├── get_redirects.js ├── get_subcategories.js ├── get_tags.js ├── get_transcluded_in.js ├── get_user_contributions_feed.js ├── get_user_watchlist_feed.js ├── get_usercontribs.js ├── get_users.js ├── get_watchlist.js ├── get_watchlistraw.js ├── import_interwiki.js ├── iwbacklinks.js ├── langbacklinks.js ├── langlinks.js ├── languagesearch.js ├── linkshere.js ├── login.js ├── logout.js ├── main_module.js ├── move.js ├── opensearch.js ├── pageprops.js ├── paraminfo.js ├── parse.js ├── patrol.js ├── prefixsearch.js ├── protect.js ├── purge_namespace_pages.js ├── purge_two_pages.js ├── reset_password.js ├── revision_delete.js ├── rollback.js ├── rsd.js ├── search.js ├── send_email.js ├── set_notification_timestamp.js ├── set_page_language.js ├── stash_image_info.js ├── tag.js ├── templates.js ├── tokens.js ├── undelete.js ├── upload_file_directly.js ├── upload_file_from_url.js ├── upload_file_in_chunks.js ├── userinfo.js ├── userrights.js ├── validatepassword.js └── watch.js ├── modules.json ├── php ├── README.md ├── all_messages.php ├── block_user.php ├── change_user_options.php ├── check_token.php ├── clear_has_msg.php ├── compare.php ├── create_account.php ├── delete.php ├── deleted_revisions.php ├── duplicate_files.php ├── edit.php ├── expand_templates.php ├── file_archive.php ├── file_repo_info.php ├── filearchive.php ├── general_site_info.php ├── geocoordinates.php ├── geoimagesearch.php ├── geosearch.php ├── get_allcategories.php ├── get_alldeletedrevs.php ├── get_allfileusages.php ├── get_allimages_by_date.php ├── get_allimages_by_name.php ├── get_alllinks.php ├── get_allpages.php ├── get_allredirects.php ├── get_allrevisions.php ├── get_alltransclusions.php ├── get_allusers.php ├── get_backlinks.php ├── get_blocked_users.php ├── get_categories.php ├── get_category_info.php ├── get_category_items.php ├── get_contributors.php ├── get_deleted_revisions.php ├── get_deleted_revs.php ├── get_embedded_pages.php ├── get_extlinks.php ├── get_exturlusage.php ├── get_feed_recent_changes.php ├── get_file_usage.php ├── get_filtered_page_revisions.php ├── get_help.php ├── get_imageinfo.php ├── get_imageusage.php ├── get_info.php ├── get_iwlinks.php ├── get_links.php ├── get_logevents.php ├── get_my_watchlist_feed.php ├── get_page_images.php ├── get_pagepropnames.php ├── get_pages_revisions.php ├── get_pageswithprop.php ├── get_protectedtitles.php ├── get_querypage_list.php ├── get_random.php ├── get_recent_category_items.php ├── get_recent_changes.php ├── get_red_links.php ├── get_redirects.php ├── get_subcategories.php ├── get_tags.php ├── get_transcluded_in.php ├── get_user_contributions_feed.php ├── get_user_watchlist_feed.php ├── get_usercontribs.php ├── get_users.php ├── get_watchlist.php ├── get_watchlistraw.php ├── import_interwiki.php ├── iwbacklinks.php ├── langbacklinks.php ├── langlinks.php ├── languagesearch.php ├── linkshere.php ├── login.php ├── logout.php ├── main_module.php ├── mergehistory.php ├── move.php ├── opensearch.php ├── pageprops.php ├── paraminfo.php ├── parse.php ├── patrol.php ├── prefixsearch.php ├── protect.php ├── purge_namespace_pages.php ├── purge_two_pages.php ├── reset_password.php ├── revision_delete.php ├── rollback.php ├── rsd.php ├── search.php ├── send_email.php ├── set_notification_timestamp.php ├── set_page_language.php ├── stash_image_info.php ├── stashedit.php ├── tag.php ├── templates.php ├── tokens.php ├── undelete.php ├── upload_file_from_url.php ├── userinfo.php ├── userrights.php ├── validatepassword.php └── watch.php └── python ├── README.md ├── all_messages.py ├── block_user.py ├── change_user_options.py ├── check_token.py ├── clear_has_msg.py ├── compare.py ├── create_account.py ├── delete.py ├── deleted_revisions.py ├── duplicate_files.py ├── edit.py ├── expand_templates.py ├── file_archive.py ├── file_repo_info.py ├── filearchive.py ├── general_site_info.py ├── geocoordinates.py ├── geoimagesearch.py ├── geosearch.py ├── get_allcategories.py ├── get_alldeletedrevs.py ├── get_allfileusages.py ├── get_allimages_by_date.py ├── get_allimages_by_name.py ├── get_alllinks.py ├── get_allpages.py ├── get_allredirects.py ├── get_allrevisions.py ├── get_alltransclusions.py ├── get_allusers.py ├── get_backlinks.py ├── get_blocked_users.py ├── get_categories.py ├── get_category_info.py ├── get_category_items.py ├── get_contributors.py ├── get_deleted_revisions.py ├── get_deleted_revs.py ├── get_embedded_pages.py ├── get_extlinks.py ├── get_exturlusage.py ├── get_feed_recent_changes.py ├── get_file_usage.py ├── get_filtered_page_revisions.py ├── get_help.py ├── get_imageinfo.py ├── get_imageusage.py ├── get_info.py ├── get_iwlinks.py ├── get_links.py ├── get_logevents.py ├── get_my_watchlist_feed.py ├── get_page_images.py ├── get_pagepropnames.py ├── get_pages_revisions.py ├── get_pageswithprop.py ├── get_protectedtitles.py ├── get_querypage_list.py ├── get_random.py ├── get_recent_category_items.py ├── get_recent_changes.py ├── get_red_links.py ├── get_redirects.py ├── get_subcategories.py ├── get_tags.py ├── get_transcluded_in.py ├── get_user_contributions_feed.py ├── get_user_watchlist_feed.py ├── get_usercontribs.py ├── get_users.py ├── get_watchlist.py ├── get_watchlistraw.py ├── import_interwiki.py ├── import_xml.py ├── iwbacklinks.py ├── langbacklinks.py ├── langlinks.py ├── languagesearch.py ├── linkshere.py ├── login.py ├── logout.py ├── main_module.py ├── mergehistory.py ├── move.py ├── opensearch.py ├── pageprops.py ├── paraminfo.py ├── parse.py ├── parse_wikitable.py ├── patrol.py ├── prefixsearch.py ├── protect.py ├── purge_namespace_pages.py ├── purge_two_pages.py ├── reset_password.py ├── revision_delete.py ├── rollback.py ├── rsd.py ├── search.py ├── send_email.py ├── set_notification_timestamp.py ├── set_page_language.py ├── stash_image_info.py ├── stashedit.py ├── tag.py ├── templates.py ├── tokens.py ├── undelete.py ├── upload_file_directly.py ├── upload_file_from_url.py ├── upload_file_in_chunks.py ├── userinfo.py ├── userrights.py ├── validatepassword.py └── watch.py /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | cookie.txt 4 | -------------------------------------------------------------------------------- /apps/account-creator/README.md: -------------------------------------------------------------------------------- 1 | # Account creator 2 | Demo of creating an account on a wiki with a special authentication extension installed. This app considers a case of a wiki where captcha is enabled through extensions like [ConfirmEdit](https://www.mediawiki.org/wiki/Extension:ConfirmEdit). [Browse the app here](https://tools.wmflabs.org/account-creator/). 3 | 4 | 5 | Install 6 | ------- 7 | 8 | ``` 9 | $ git clone https://github.com/wikimedia/mediawiki-api-demos 10 | $ cd mediawiki-api-demos/apps/account-creator 11 | $ pip install -r requirements.txt 12 | Install the necessary python modules with pip 13 | $ python3 app.py 14 | ``` 15 | 16 | Screenshots 17 | ----------- 18 |
19 | 20 |
-------------------------------------------------------------------------------- /apps/account-creator/requirements.txt: -------------------------------------------------------------------------------- 1 | flask 2 | requests -------------------------------------------------------------------------------- /apps/account-creator/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/apps/account-creator/screenshot.png -------------------------------------------------------------------------------- /apps/account-creator/static/account_form.css: -------------------------------------------------------------------------------- 1 | .form-container { 2 | margin-top: 20px; 3 | } 4 | 5 | .form-field 6 | { 7 | margin-top: 5px; 8 | } 9 | 10 | label 11 | { 12 | font-weight: 400; 13 | } 14 | 15 | input 16 | { 17 | width: 30%; 18 | } -------------------------------------------------------------------------------- /apps/article-ideas-generator/requirements.txt: -------------------------------------------------------------------------------- 1 | flask 2 | requests -------------------------------------------------------------------------------- /apps/client-login/README.md: -------------------------------------------------------------------------------- 1 | # Client login 2 | Demo of logging-in on a wiki 3 | 4 | Install 5 | ------- 6 | 7 | ``` 8 | $ git clone https://github.com/wikimedia/mediawiki-api-demos 9 | $ cd mediawiki-api-demos/apps/client-login 10 | $ pip install flask 11 | Install the necessary python modules with pip 12 | $ python3 clientlogin.py 13 | ``` 14 | 15 | Screenshots 16 | ----------- 17 |
18 | 19 |
-------------------------------------------------------------------------------- /apps/client-login/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/apps/client-login/screenshot.png -------------------------------------------------------------------------------- /apps/client-login/static/login_form.css: -------------------------------------------------------------------------------- 1 | .form-container { 2 | margin-top: 20px; 3 | } 4 | 5 | .form-field 6 | { 7 | margin-top: 5px; 8 | } 9 | 10 | input 11 | { 12 | width: 30%; 13 | } -------------------------------------------------------------------------------- /apps/holidays-viewer/requirements.txt: -------------------------------------------------------------------------------- 1 | flask 2 | requests -------------------------------------------------------------------------------- /apps/holidays-viewer/screenshots/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/apps/holidays-viewer/screenshots/add.png -------------------------------------------------------------------------------- /apps/holidays-viewer/screenshots/list-holidays.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/apps/holidays-viewer/screenshots/list-holidays.png -------------------------------------------------------------------------------- /apps/holidays-viewer/screenshots/login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/apps/holidays-viewer/screenshots/login.png -------------------------------------------------------------------------------- /apps/holidays-viewer/screenshots/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/apps/holidays-viewer/screenshots/search.png -------------------------------------------------------------------------------- /apps/holidays-viewer/static/update-links.js: -------------------------------------------------------------------------------- 1 | $( document ).ready( function() { 2 | $( ".holidays-html a" ).attr( "target", "_blank" ); 3 | 4 | $( ".holidays-html a" ).attr( "href", function( i, href ) { 5 | return "//en.wikipedia.org" + href; 6 | }); 7 | }); -------------------------------------------------------------------------------- /apps/holidays-viewer/templates/index.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% block content %} 3 |
4 | {{holidays_html|safe}} 5 |
6 | {% endblock %} 7 | -------------------------------------------------------------------------------- /apps/nearby-places-viewer/requirements.txt: -------------------------------------------------------------------------------- 1 | flask 2 | haversine 3 | requests -------------------------------------------------------------------------------- /apps/nearby-places-viewer/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/apps/nearby-places-viewer/screenshot.png -------------------------------------------------------------------------------- /apps/picture-of-the-day-viewer/README.md: -------------------------------------------------------------------------------- 1 | # Picture Of The Day Viewer 2 | A sample app that uses MediaWiki Action API's [Image](https://www.mediawiki.org/wiki/API:Image) and [Imageinfo](https://www.mediawiki.org/wiki/API:Imageinfo) modules to display the [Wikipedia](en.wikipedia.org) Picture of the Day. This app uses [Flask](http://flask.pocoo.org/). [Browse the app here](https://tools.wmflabs.org/potd-viewer/). 3 | 4 | ## Install 5 | 6 | ``` 7 | $ git clone https://github.com/wikimedia/mediawiki-api-demos 8 | $ cd mediawiki-api-demos/apps/picture-of-the-day-viewer 9 | $ pip install -r requirements.txt 10 | Install the necessary python modules with pip 11 | $ python3 app.py 12 | ``` 13 | 14 | ## Screenshot 15 |
16 | 17 |
-------------------------------------------------------------------------------- /apps/picture-of-the-day-viewer/requirements.txt: -------------------------------------------------------------------------------- 1 | flask 2 | requests -------------------------------------------------------------------------------- /apps/picture-of-the-day-viewer/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/apps/picture-of-the-day-viewer/screenshot.png -------------------------------------------------------------------------------- /apps/qrcode-generator/README.md: -------------------------------------------------------------------------------- 1 | # QR Code Generator 2 | This is a QRCode generator for Wikimedia Sites. This app uses the MediaWiki OAuth Python library [flask-mwoauth](https://github.com/valhallasw/flask-mwoauth) for authentication and [Action API](https://www.mediawiki.org/wiki/API:Main_page) [Upload](https://www.mediawiki.org/wiki/API:Upload) for uploading the generated QR codes to Wikimedia Commons. 3 | 4 | Install 5 | ------- 6 | 7 | ``` 8 | $ git clone https://github.com/wikimedia/mediawiki-api-demos.git 9 | $ cd mediawiki-api-demos/apps/qrcode-generator 10 | $ pip3 install -r requirements.txt 11 | $ python3 app.py 12 | ``` 13 | 14 | Screenshot 15 | ---------- 16 | 17 |
18 | 19 |
-------------------------------------------------------------------------------- /apps/qrcode-generator/config.yaml: -------------------------------------------------------------------------------- 1 | CONSUMER_KEY: 2 | CONSUMER_SECRET: 3 | OAUTH_MWURI: http://dev.wiki.local.wmftest.net:8080/w -------------------------------------------------------------------------------- /apps/qrcode-generator/requirements.txt: -------------------------------------------------------------------------------- 1 | flask==1.0.3 2 | flask_mwoauth 3 | requests_oauthlib 4 | requests 5 | qrcode 6 | pyyaml 7 | -------------------------------------------------------------------------------- /apps/qrcode-generator/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/apps/qrcode-generator/screenshot.png -------------------------------------------------------------------------------- /apps/qrcode-generator/static/qrcode-generator.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function () { 2 | 3 | $('#upload-btn').on('click', function () { 4 | $('#upload-to-commons').show(); 5 | }); 6 | }); -------------------------------------------------------------------------------- /apps/qrcode-generator/static/qrcodes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/apps/qrcode-generator/static/qrcodes/.gitkeep -------------------------------------------------------------------------------- /apps/qrcode-generator/static/style.css: -------------------------------------------------------------------------------- 1 | #download, #url-para { 2 | margin-left: 0.8em; 3 | } 4 | 5 | #upload-to-commons { 6 | display: none 7 | } 8 | 9 | #upload-to-commons-legend { 10 | font-weight: bold; 11 | font-size: large 12 | } -------------------------------------------------------------------------------- /apps/qrcode-generator/templates/upload.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block main %} 4 | 5 | {% if error is not none %} 6 | 9 | {% else %} 10 | 14 |
15 | 16 |
17 |
18 | 19 | Go back to home page 20 | 21 |
22 | {% endif %} 23 | 24 | {% endblock %} -------------------------------------------------------------------------------- /apps/user-contributions-feed/README.md: -------------------------------------------------------------------------------- 1 | # User Contributions Feed 2 | Demp app that uses [list=usercontribs](https://www.mediawiki.org/wiki/API:Usercontribs) module to fetch the top 50 edits made by a user. 3 | 4 | Install 5 | ------- 6 | 7 | ``` 8 | $ git clone https://github.com/wikimedia/mediawiki-api-demos.git 9 | $ cd mediawiki-api-demos/apps/user-contributions-feed 10 | $ pip install flask requests 11 | $ python3 app.py 12 | ``` 13 | 14 | Screenshot 15 | ---------- 16 | 17 |
18 | 19 |
20 | -------------------------------------------------------------------------------- /apps/user-contributions-feed/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/apps/user-contributions-feed/screenshot.png -------------------------------------------------------------------------------- /gallery/README.md: -------------------------------------------------------------------------------- 1 | MediaWiki Apps Gallery 2 | --- 3 | A showcase of interactive demo apps built using the MediaWiki Action API. Browse the gallery here on Wikimedia Toolforge: https://tools.wmflabs.org/apps-gallery/. 4 | -------------------------------------------------------------------------------- /gallery/gallery.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | """ 4 | gallery.py 5 | 6 | MediaWiki apps gallery: a collection of demo apps built using the 7 | MediaWiki Action APIs. 8 | 9 | MIT license 10 | """ 11 | 12 | import json 13 | from flask import Flask, render_template 14 | import requests 15 | 16 | 17 | APP = Flask(__name__) 18 | SESSION = requests.Session() 19 | 20 | 21 | @APP.route('/') 22 | def index(): 23 | """ Displays the index page accessible at '/' 24 | """ 25 | 26 | with open('apps.json', 'r') as file: 27 | data = file.read() 28 | apps = json.loads(data) 29 | 30 | return render_template('apps.html', apps=apps) 31 | 32 | 33 | if __name__ == '__main__': 34 | APP.run(debug=True) 35 | -------------------------------------------------------------------------------- /gallery/static/addlingue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/addlingue.png -------------------------------------------------------------------------------- /gallery/static/afd-stats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/afd-stats.png -------------------------------------------------------------------------------- /gallery/static/article_ideas_generator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/article_ideas_generator.png -------------------------------------------------------------------------------- /gallery/static/create_account_with_captcha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/create_account_with_captcha.png -------------------------------------------------------------------------------- /gallery/static/create_login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/create_login.png -------------------------------------------------------------------------------- /gallery/static/holidays-viewer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/holidays-viewer.png -------------------------------------------------------------------------------- /gallery/static/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/logo.png -------------------------------------------------------------------------------- /gallery/static/mass-mailer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/mass-mailer.png -------------------------------------------------------------------------------- /gallery/static/mediawiki-benchmarker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/mediawiki-benchmarker.png -------------------------------------------------------------------------------- /gallery/static/nearby_places_viewer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/nearby_places_viewer.png -------------------------------------------------------------------------------- /gallery/static/oauth-hello-world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/oauth-hello-world.png -------------------------------------------------------------------------------- /gallery/static/parliament-diagram-generator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/parliament-diagram-generator.png -------------------------------------------------------------------------------- /gallery/static/picture_of_the_day_viewer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/picture_of_the_day_viewer.png -------------------------------------------------------------------------------- /gallery/static/ptable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/ptable.png -------------------------------------------------------------------------------- /gallery/static/qrcode-generator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/qrcode-generator.png -------------------------------------------------------------------------------- /gallery/static/quote-mashup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/quote-mashup.png -------------------------------------------------------------------------------- /gallery/static/reccat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/reccat.png -------------------------------------------------------------------------------- /gallery/static/recent-deaths.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/recent-deaths.png -------------------------------------------------------------------------------- /gallery/static/sightseer-map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/sightseer-map.png -------------------------------------------------------------------------------- /gallery/static/speed-patrolling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/speed-patrolling.png -------------------------------------------------------------------------------- /gallery/static/user_contributions_feed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/user_contributions_feed.png -------------------------------------------------------------------------------- /gallery/static/vizquery.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/vizquery.png -------------------------------------------------------------------------------- /gallery/static/wiki-search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/wiki-search.png -------------------------------------------------------------------------------- /gallery/static/wikidata-skim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/wikidata-skim.png -------------------------------------------------------------------------------- /gallery/static/wikidata-translate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/wikidata-translate.png -------------------------------------------------------------------------------- /gallery/static/wikifeedia.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/wikifeedia.png -------------------------------------------------------------------------------- /gallery/static/wikipedia-viewer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/wikipedia-viewer.png -------------------------------------------------------------------------------- /gallery/static/wikipedia_search_starter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wikimedia/mediawiki-api-demos/b68422480e16292c8d09e1b5b31b6b35bddcf9bb/gallery/static/wikipedia_search_starter.png -------------------------------------------------------------------------------- /javascript/all_messages.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | all_messages.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Allmessages` module: Get the Dutch translations of some messages 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "query", 16 | meta: "allmessages", 17 | ammessages: "august|mainpage|edit|rollback-success", 18 | amlang: "nl", 19 | format: "json" 20 | }; 21 | 22 | url = url + "?origin=*"; 23 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 24 | 25 | fetch(url) 26 | .then(function(response){return response.json();}) 27 | .then(function(response) {console.log(response);}) 28 | .catch(function(error){console.log(error);}); 29 | -------------------------------------------------------------------------------- /javascript/check_token.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | check_token.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Checktoken` module: Check a CSRF token. 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "checktoken", 16 | token: "123ABC", 17 | type: "csrf", 18 | format: "json" 19 | }; 20 | 21 | url = url + "?origin=*"; 22 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 23 | 24 | fetch(url) 25 | .then(function(response){return response.json();}) 26 | .then(function(response) {console.log(response);}) 27 | .catch(function(error){console.log(error);}); 28 | -------------------------------------------------------------------------------- /javascript/clear_has_msg.js: -------------------------------------------------------------------------------- 1 | /* 2 | clear_has_msg.js 3 | 4 | MediaWiki API Demos 5 | Demo of `ClearHasMsg` module: Clear the hasmsg flag for the current user. 6 | 7 | MIT License 8 | */ 9 | 10 | var url = "https://en.wikipedia.org/w/api.php"; 11 | 12 | var params = { 13 | action: "clearhasmsg", 14 | format: "json" 15 | }; 16 | request.post({ url: url, form: params }, function(error, res, body) { 17 | if (error) { 18 | return; 19 | } 20 | console.log(body); 21 | }); 22 | -------------------------------------------------------------------------------- /javascript/compare.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | compare.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Compare` module: Compare the current revisions of two different pages. 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "compare", 16 | fromtitle: "Template:Unsigned", 17 | totitle: "Template:UnsignedIP", 18 | format: "json" 19 | }; 20 | 21 | url = url + "?origin=*"; 22 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 23 | 24 | fetch(url) 25 | .then(function(response){return response.json();}) 26 | .then(function(response) {console.log(response);}) 27 | .catch(function(error){console.log(error);}); 28 | -------------------------------------------------------------------------------- /javascript/duplicate_files.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | duplicate_files.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Duplicatefiles` module: List duplicates of the given files. 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "query", 16 | titles: "Image:1995.jpg|Image:Welcome.gif", 17 | prop: "duplicatefiles", 18 | format: "json" 19 | }; 20 | 21 | url = url + "?origin=*"; 22 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 23 | 24 | fetch(url) 25 | .then(function(response){return response.json();}) 26 | .then(function(response) {console.log(response);}) 27 | .catch(function(error){console.log(error);}); 28 | -------------------------------------------------------------------------------- /javascript/expand_templates.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | expand_templates.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Expandtemplates` module: Obtain general site info. 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "expandtemplates", 16 | text: "{{Project:Sandbox}}", 17 | prop: "wikitext", 18 | format: "json" 19 | }; 20 | 21 | url = url + "?origin=*"; 22 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 23 | 24 | fetch(url) 25 | .then(function(response){return response.json();}) 26 | .then(function(response) {console.log(response);}) 27 | .catch(function(error){console.log(error);}); 28 | -------------------------------------------------------------------------------- /javascript/file_archive.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | file_archive.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Filearchive` module: Get a list of all deleted files. 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "query", 16 | list: "filearchive", 17 | format: "json" 18 | }; 19 | 20 | url = url + "?origin=*"; 21 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 22 | 23 | fetch(url) 24 | .then(function(response){return response.json();}) 25 | .then(function(response) {console.log(response);}) 26 | .catch(function(error){console.log(error);}); 27 | -------------------------------------------------------------------------------- /javascript/file_repo_info.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | file_repo_info.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Filerepoinfo` module: Get information about file repositories. 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "query", 16 | meta: "filerepoinfo", 17 | friprop: "url|name|displayname", 18 | format: "json" 19 | }; 20 | 21 | url = url + "?origin=*"; 22 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 23 | 24 | fetch(url) 25 | .then(function(response){return response.json();}) 26 | .then(function(response) {console.log(response);}) 27 | .catch(function(error){console.log(error);}); 28 | -------------------------------------------------------------------------------- /javascript/filearchive.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | filearchive.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Filearchive` module: Enumerate 3 deleted files from filearchive table in descending order. 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "query", 16 | falimit: "3", 17 | list: "filearchive", 18 | fadir: "descending", 19 | format: "json" 20 | }; 21 | 22 | url = url + "?origin=*"; 23 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 24 | 25 | fetch(url) 26 | .then(function(response){return response.json();}) 27 | .then(function(response) {console.log(response);}) 28 | .catch(function(error){console.log(error);}); 29 | -------------------------------------------------------------------------------- /javascript/general_site_info.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | general_site_info.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Siteinfo` module: Obtain general site info. 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "query", 16 | meta: "siteinfo", 17 | formatversion: "2", 18 | format: "json" 19 | }; 20 | 21 | url = url + "?origin=*"; 22 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 23 | 24 | fetch(url) 25 | .then(function(response){return response.json();}) 26 | .then(function(response) {console.log(response);}) 27 | .catch(function(error){console.log(error);}); 28 | -------------------------------------------------------------------------------- /javascript/get_alldeletedrevs.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_alldeletedrevs.js 5 | 6 | MediaWiki API Demos 7 | Demo of `alldeletedrevisions` module: List the all deleted revisions from User 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "query", 16 | list: "alldeletedrevisions", 17 | adruser: "Mahesh", 18 | adrprop: "ids|user|comment", 19 | format: "json" 20 | }; 21 | 22 | url = url + "?origin=*"; 23 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 24 | 25 | fetch(url) 26 | .then(function(response){return response.json();}) 27 | .then(function(response) {console.log(response);}) 28 | .catch(function(error){console.log(error);}); 29 | -------------------------------------------------------------------------------- /javascript/get_extlinks.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_extlinks.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Extlinks` module: Get a list of external links on a page 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "query", 16 | titles: "Albert Einstein", 17 | prop: "extlinks", 18 | format: "json" 19 | }; 20 | 21 | url = url + "?origin=*"; 22 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 23 | 24 | fetch(url) 25 | .then(function(response){return response.json();}) 26 | .then(function(response) {console.log(response);}) 27 | .catch(function(error){console.log(error);}); 28 | -------------------------------------------------------------------------------- /javascript/get_feed_recent_changes.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_feed_recent_changes.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Feedrecentchanges` module: Show recent changes as an RSS feed. 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "feedrecentchanges", 16 | format: "json" 17 | }; 18 | 19 | url = url + "?origin=*"; 20 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 21 | 22 | fetch(url) 23 | .then(function(response){return response.json();}) 24 | .then(function(response) {console.log(response);}) 25 | .catch(function(error){console.log(error);}); 26 | -------------------------------------------------------------------------------- /javascript/get_file_usage.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_file_usage.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Fileusage` module: Get a list of pages using a given file. 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "query", 16 | titles: "File:Example.jpg", 17 | prop: "fileusage", 18 | format: "json" 19 | }; 20 | 21 | url = url + "?origin=*"; 22 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 23 | 24 | fetch(url) 25 | .then(function(response){return response.json();}) 26 | .then(function(response) {console.log(response);}) 27 | .catch(function(error){console.log(error);}); 28 | -------------------------------------------------------------------------------- /javascript/get_help.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_help.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Help` module: Get help for a specified module. 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "help", 16 | modules: "query+tokens", 17 | wrap: "", 18 | format: "json" 19 | }; 20 | 21 | url = url + "?origin=*"; 22 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 23 | 24 | fetch(url) 25 | .then(function(response){return response.json();}) 26 | .then(function(response) {console.log(response);}) 27 | .catch(function(error){console.log(error);}); 28 | -------------------------------------------------------------------------------- /javascript/get_transcluded_in.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_transcluded_in.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Transcludedin` module: Get a list of pages which transclude a given page 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "query", 16 | titles: "Main Page", 17 | prop: "transcludedin", 18 | format: "json" 19 | }; 20 | 21 | url = url + "?origin=*"; 22 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 23 | 24 | fetch(url) 25 | .then(function(response){return response.json();}) 26 | .then(function(response) {console.log(response);}) 27 | .catch(function(error){console.log(error);}); 28 | -------------------------------------------------------------------------------- /javascript/get_user_contributions_feed.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_user_contributions_feed.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Feedcontributions` module: Show contributions of a user as an RSS feed. 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "feedcontributions", 16 | user: "Jimbo Wales", 17 | format: "json" 18 | }; 19 | 20 | url = url + "?origin=*"; 21 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 22 | 23 | fetch(url) 24 | .then(function(response){return response.json();}) 25 | .then(function(response) {console.log(response);}) 26 | .catch(function(error){console.log(error);}); 27 | -------------------------------------------------------------------------------- /javascript/get_user_watchlist_feed.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_user_watchlist_feed.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Feedwatchlist` module: Get a watchlist feed from another user. 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "feedwatchlist", 16 | wlowner: "sample_user", 17 | wltoken: "sample_watchlist_token" 18 | }; 19 | 20 | url = url + "?origin=*"; 21 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 22 | 23 | fetch(url) 24 | .then(function(response){return response.json();}) 25 | .then(function(response) {console.log(response);}) 26 | .catch(function(error){console.log(error);}); 27 | -------------------------------------------------------------------------------- /javascript/iwbacklinks.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | iwbacklinks.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Iwbacklinks` module: Get pages that link to a given interwiki link. 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "query", 16 | list: "iwbacklinks", 17 | iwblprefix: "wikibooks", 18 | iwbltitle: "Main_Page", 19 | format: "json" 20 | }; 21 | 22 | url = url + "?origin=*"; 23 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 24 | 25 | fetch(url) 26 | .then(function(response){return response.json();}) 27 | .then(function(response) {console.log(response);}) 28 | .catch(function(error){console.log(error);}); 29 | -------------------------------------------------------------------------------- /javascript/langbacklinks.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | langbacklinks.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Langbacklinks` module: Get pages linking to a given language link 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "query", 16 | list: "langbacklinks", 17 | lbltitle: "Test", 18 | lbllang: "fr", 19 | format: "json" 20 | }; 21 | 22 | url = url + "?origin=*"; 23 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 24 | 25 | fetch(url) 26 | .then(function(response){return response.json();}) 27 | .then(function(response) {console.log(response);}) 28 | .catch(function(error){console.log(error);}); 29 | -------------------------------------------------------------------------------- /javascript/langlinks.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | langlinks.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Langlinks` module: Get a list of language links that a given page has 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "query", 16 | titles: "Albert Einstein", 17 | prop: "langlinks", 18 | format: "json" 19 | }; 20 | 21 | url = url + "?origin=*"; 22 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 23 | 24 | fetch(url) 25 | .then(function(response){return response.json();}) 26 | .then(function(response) {console.log(response);}) 27 | .catch(function(error){console.log(error);}); 28 | -------------------------------------------------------------------------------- /javascript/linkshere.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | linkshere.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Linkshere` module: Get a list of pages linking to a given page 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "query", 16 | titles: "Main Page", 17 | prop: "linkshere", 18 | format: "json" 19 | }; 20 | 21 | url = url + "?origin=*"; 22 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 23 | 24 | fetch(url) 25 | .then(function(response){return response.json();}) 26 | .then(function(response) {console.log(response);}) 27 | .catch(function(error){console.log(error);}); 28 | -------------------------------------------------------------------------------- /javascript/main_module.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | main_module.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Main module` module: Get help for the main module. 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "help", 16 | wrap: "", 17 | format: "json" 18 | }; 19 | 20 | url = url + "?origin=*"; 21 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 22 | 23 | fetch(url) 24 | .then(function(response){return response.json();}) 25 | .then(function(response) {console.log(response);}) 26 | .catch(function(error){console.log(error);}); 27 | -------------------------------------------------------------------------------- /javascript/opensearch.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | opensearch.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Opensearch` module: Search the wiki and obtain 8 | results in an OpenSearch (http://www.opensearch.org) format 9 | 10 | MIT License 11 | */ 12 | 13 | var url = "https://en.wikipedia.org/w/api.php"; 14 | 15 | var params = { 16 | action: "opensearch", 17 | search: "Hampi", 18 | limit: "5", 19 | namespace: "0", 20 | format: "json" 21 | }; 22 | 23 | url = url + "?origin=*"; 24 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 25 | 26 | fetch(url) 27 | .then(function(response){return response.json();}) 28 | .then(function(response) {console.log(response);}) 29 | .catch(function(error){console.log(error);}); 30 | -------------------------------------------------------------------------------- /javascript/pageprops.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | pageprops.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Pageprops` module: Get various properties defined in the page content 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "query", 16 | titles: "Albert Einstein", 17 | prop: "pageprops", 18 | format: "json" 19 | }; 20 | 21 | url = url + "?origin=*"; 22 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 23 | 24 | fetch(url) 25 | .then(function(response){return response.json();}) 26 | .then(function(response) {console.log(response);}) 27 | .catch(function(error){console.log(error);}); 28 | -------------------------------------------------------------------------------- /javascript/paraminfo.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | paraminfo.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Paraminfo` module: Get information about other action API modules and their parameters. 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "paraminfo", 16 | format: "json", 17 | modules: "parse|query+info|query" 18 | }; 19 | 20 | url = url + "?origin=*"; 21 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 22 | 23 | fetch(url) 24 | .then(function(response){return response.json();}) 25 | .then(function(response) {console.log(response);}) 26 | .catch(function(error){console.log(error);}); 27 | -------------------------------------------------------------------------------- /javascript/parse.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | parse.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Parse` module: Parse content of a page 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "parse", 16 | page: "Pet door", 17 | format: "json" 18 | }; 19 | 20 | url = url + "?origin=*"; 21 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 22 | 23 | fetch(url) 24 | .then(function(response){return response.json();}) 25 | .then(function(response) { 26 | console.log(response.parse.text["*"]); 27 | }) 28 | .catch(function(error){console.log(error);}); 29 | -------------------------------------------------------------------------------- /javascript/purge_namespace_pages.js: -------------------------------------------------------------------------------- 1 | /* 2 | purge_namespace_pages.js 3 | 4 | MediaWiki API Demos 5 | Demo of `purge` module: Sending post request to purge first 10 pages in the main namespace 6 | 7 | MIT license 8 | */ 9 | 10 | var request = require('request').defaults({jar: true}), 11 | url = "https://test.wikipedia.org/w/api.php"; 12 | 13 | function purge() { 14 | var params = { 15 | action: "purge", 16 | generator: "allpages", 17 | gapnamespace: "0", 18 | gaplimit: "10", 19 | format: "json" 20 | }; 21 | 22 | request.post({ url: url, form: params }, function (error, res, body) { 23 | if (error) { 24 | return; 25 | } 26 | console.log(body); 27 | }); 28 | } 29 | 30 | // Start the function 31 | purge(); -------------------------------------------------------------------------------- /javascript/purge_two_pages.js: -------------------------------------------------------------------------------- 1 | /* 2 | purge_two_pages.js 3 | 4 | MediaWiki API Demos 5 | Demo of `purge` module: Sending post request to purge two or more pages 6 | 7 | MIT license 8 | */ 9 | 10 | var request = require('request').defaults({jar: true}), 11 | url = "https://en.wikipedia.org/w/api.php"; 12 | 13 | function purge() { 14 | var params = { 15 | action: "purge", 16 | titles: "Main_Page|Nonexistent", 17 | format: "json" 18 | }; 19 | 20 | request.post({ url: url, form: params }, function (error, res, body) { 21 | if (error) { 22 | return; 23 | } 24 | console.log(body); 25 | }); 26 | } 27 | 28 | // Start the function 29 | purge(); -------------------------------------------------------------------------------- /javascript/rsd.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | rsd.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Rsd` module: Get request to export an RSD schema. 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "rsd", 16 | format: "json" 17 | }; 18 | 19 | url = url + "?origin=*"; 20 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 21 | 22 | fetch(url) 23 | .then(function(response){return response.json();}) 24 | .then(function(response) {console.log(response);}) 25 | .catch(function(error){console.log(error);}); 26 | -------------------------------------------------------------------------------- /javascript/templates.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | templates.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Templates` module: Get a list of templates used on a page 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "query", 16 | titles: "Albert Einstein", 17 | prop: "templates", 18 | format: "json" 19 | }; 20 | 21 | url = url + "?origin=*"; 22 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 23 | 24 | fetch(url) 25 | .then(function(response){return response.json();}) 26 | .then(function(response) {console.log(response);}) 27 | .catch(function(error){console.log(error);}); 28 | -------------------------------------------------------------------------------- /javascript/tokens.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | tokens.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Token` module: Fetch token of type `login` 8 | 9 | MIT License 10 | */ 11 | 12 | var request = require('request'), 13 | url = "https://www.mediawiki.org/w/api.php"; 14 | 15 | var params = { 16 | action: "query", 17 | meta: "tokens", 18 | type: "login", 19 | format: "json" 20 | }; 21 | 22 | request.get( { url: url, qs: params }, function( error, response, body ){ 23 | body = JSON.parse( body ); 24 | console.log( body.query.tokens.logintoken ); 25 | }); 26 | -------------------------------------------------------------------------------- /javascript/userinfo.js: -------------------------------------------------------------------------------- 1 | //This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | userinfo.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Userinfo` module: Get general user info and user rights 8 | 9 | MIT License 10 | */ 11 | 12 | var url = "https://en.wikipedia.org/w/api.php"; 13 | 14 | var params = { 15 | action: "query", 16 | meta: "userinfo", 17 | uiprop: "rights", 18 | format: "json" 19 | }; 20 | 21 | url = url + "?origin=*"; 22 | Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); 23 | 24 | fetch(url) 25 | .then(function(response){return response.json();}) 26 | .then(function(response) {console.log(response);}) 27 | .catch(function(error){console.log(error);}); 28 | -------------------------------------------------------------------------------- /javascript/validatepassword.js: -------------------------------------------------------------------------------- 1 | /* 2 | validatepassword.js 3 | 4 | MediaWiki Action API Code Samples 5 | Demo of `Validatepassword` module: Validate a password against the wiki's password policies. 6 | MIT license 7 | */ 8 | 9 | 10 | var request = require("request").defaults({jar: true}), 11 | url = 'https://en.wikipedia.org/w/api.php'; 12 | 13 | function validatePassword() { 14 | var params = { 15 | action: "validatepassword", 16 | password: "your_password", 17 | format: "json" 18 | }; 19 | 20 | request.post({ url: url, form: params }, function (error, res, body) { 21 | if (error) { 22 | return; 23 | } 24 | console.log(body); 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /mediawikijs/all_messages.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | all_messages.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Allmessages` module: Get the Dutch translations of some messages 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | meta: 'allmessages', 15 | ammessages: 'august|mainpage|edit|rollback-success', 16 | amlang: 'nl', 17 | format: 'json' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | console.log( data ); 23 | } ); 24 | -------------------------------------------------------------------------------- /mediawikijs/block_user.js: -------------------------------------------------------------------------------- 1 | /* 2 | block_user.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Block` module: sending POST request to block user 6 | 7 | MIT License 8 | */ 9 | 10 | var params = { 11 | action: 'block', 12 | user: 'ABCD', 13 | expiry: '2020-02-25T07:27:50Z', 14 | reason: 'API Test', 15 | format: 'json' 16 | }, 17 | api = new mw.Api(); 18 | 19 | api.postWithToken( 'csrf', params ).done( function ( data ) { 20 | console.log( data ); 21 | } ); 22 | -------------------------------------------------------------------------------- /mediawikijs/change_user_options.js: -------------------------------------------------------------------------------- 1 | /* 2 | change_user_options.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Options` module: POST request to change three options 6 | for current user 7 | 8 | MIT License 9 | */ 10 | 11 | var params = { 12 | action: 'options', 13 | change: 'language=en|skin=monobook', 14 | optionname: 'nickname', 15 | optionvalue: 'custom-signa|ture', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.postWithToken( 'csrf', params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/check_token.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | check_token.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Checktoken` module: Check a CSRF token. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'checktoken', 14 | token: '123ABC', 15 | type: 'csrf', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/clear_has_msg.js: -------------------------------------------------------------------------------- 1 | /* 2 | clear_has_msg.js 3 | 4 | MediaWiki API Demos 5 | Demo of `ClearHasMsg` module: Clear the hasmsg flag for the current user. 6 | 7 | MIT License 8 | */ 9 | 10 | var params = { 11 | action: "clearhasmsg", 12 | format: "json" 13 | }, 14 | api = new mw.Api(); 15 | 16 | api.post( params ).done( function ( data ) { 17 | console.log( data ); 18 | } ); 19 | -------------------------------------------------------------------------------- /mediawikijs/compare.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | compare.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Compare` module: Compare the current revisions of two different pages. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'compare', 14 | fromtitle: 'Template:Unsigned', 15 | totitle: 'Template:UnsignedIP', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/delete.js: -------------------------------------------------------------------------------- 1 | /* 2 | delete.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Delete` module: post request to delete a page 6 | 7 | MIT License 8 | */ 9 | 10 | var params = { 11 | action: 'delete', 12 | title: 'enter_a_page_title', 13 | format: 'json' 14 | }, 15 | api = new mw.Api(); 16 | 17 | api.postWithToken( 'csrf', params ).done( function ( data ) { 18 | console.log( data ); 19 | } ); 20 | -------------------------------------------------------------------------------- /mediawikijs/deleted_revisions.js: -------------------------------------------------------------------------------- 1 | /* 2 | deleted_revisions.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Deletedrevisions` module: Get a list of deleted revisions for Talk:Main Page. 6 | 7 | MIT License 8 | */ 9 | 10 | var params = { 11 | action: 'query', 12 | titles: 'Talk:Main_Page', 13 | prop: 'deletedrevisions', 14 | drvprop: 'user|comment|content', 15 | drvslots: '*', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/duplicate_files.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | duplicate_files.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Duplicatefiles` module: List duplicates of the given files. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | titles: 'Image:1995.jpg|Image:Welcome.gif', 15 | prop: 'duplicatefiles', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/edit.js: -------------------------------------------------------------------------------- 1 | /* 2 | edit.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Edit` module: POST request to edit a page 6 | 7 | MIT License 8 | */ 9 | 10 | var params = { 11 | action: 'edit', 12 | title: 'Sandbox', 13 | appendtext: 'Hello', 14 | format: 'json' 15 | }, 16 | api = new mw.Api(); 17 | 18 | api.postWithToken( 'csrf', params ).done( function ( data ) { 19 | console.log( data ); 20 | } ); 21 | -------------------------------------------------------------------------------- /mediawikijs/expand_templates.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | expand_templates.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Expandtemplates` module: Obtain general site info. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'expandtemplates', 14 | text: '{{Project:Sandbox}}', 15 | prop: 'wikitext', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/file_archive.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | file_archive.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Filearchive` module: Get a list of all deleted files. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | list: 'filearchive', 15 | format: 'json' 16 | }, 17 | api = new mw.Api(); 18 | 19 | api.get( params ).done( function ( data ) { 20 | console.log( data ); 21 | } ); 22 | -------------------------------------------------------------------------------- /mediawikijs/file_repo_info.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | file_repo_info.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Filerepoinfo` module: Get information about file repositories. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | meta: 'filerepoinfo', 15 | friprop: 'url|name|displayname', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/filearchive.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | filearchive.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Filearchive` module: Enumerate 3 deleted files from filearchive table in descending order. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | falimit: '3', 15 | list: 'filearchive', 16 | fadir: 'descending', 17 | format: 'json' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | console.log( data ); 23 | } ); 24 | -------------------------------------------------------------------------------- /mediawikijs/general_site_info.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | general_site_info.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Siteinfo` module: Obtain general site info. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | meta: 'siteinfo', 15 | formatversion: '2', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/geocoordinates.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | geocoordinates.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Geosearch` module: Obtain coordinates for wiki pages nearby 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | prop: 'coordinates', 15 | titles: 'Wikimedia Foundation', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | var pages = data.query.pages, 22 | page; 23 | for ( page in pages ) { 24 | console.log( 'Latitute: ' + pages[ page ].coordinates[ 0 ].lat ); 25 | console.log( 'Longitude: ' + pages[ page ].coordinates[ 0 ].lon ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/geoimagesearch.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | geoimagesearch.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Geosearch` module: Use generator module 8 | to get search results for pages near Wikimedia HQ 9 | with images 10 | 11 | MIT License 12 | */ 13 | 14 | var params = { 15 | action: 'query', 16 | generator: 'geosearch', 17 | prop: 'coordinates|pageimages', 18 | ggscoord: '37.7891838|-122.4033522', 19 | format: 'json' 20 | }, 21 | api = new mw.Api(); 22 | 23 | api.get( params ).done( function ( data ) { 24 | var pages = data.query.pages, 25 | page; 26 | for ( page in pages ) { 27 | console.log( pages[ page ].title + ': ' + pages[ page ].thumbnail.source ); 28 | } 29 | } ); 30 | -------------------------------------------------------------------------------- /mediawikijs/geosearch.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | geosearch.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Geosearch` module: Search for wiki pages nearby 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | list: 'geosearch', 15 | gscoord: '37.7891838|-122.4033522', 16 | gsradius: '10000', 17 | gslimit: '10', 18 | format: 'json' 19 | }, 20 | api = new mw.Api(); 21 | 22 | api.get( params ).done( function ( data ) { 23 | var pages = data.query.geosearch, 24 | place; 25 | for ( place in pages ) { 26 | console.log( pages[ place ].title ); 27 | } 28 | } ); 29 | -------------------------------------------------------------------------------- /mediawikijs/get_allcategories.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_allcategories.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Allcategories` module: Get all categories, 8 | starting from a certian point, as ordered by category title. 9 | 10 | MIT License 11 | */ 12 | 13 | var params = { 14 | action: 'query', 15 | format: 'json', 16 | list: 'allcategories', 17 | acfrom: '15th-century caliphs' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var categories = data.query.allcategories, 23 | cat; 24 | for ( cat in categories ) { 25 | console.log( categories[ cat ][ '*' ] ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_alldeletedrevs.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_alldeletedrevs.js 5 | 6 | MediaWiki API Demos 7 | Demo of `alldeletedrevisions` module: List the all deleted revisions from User 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | list: 'alldeletedrevisions', 15 | adruser: 'Mahesh', 16 | adrprop: 'ids|user|comment', 17 | format: 'json' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | console.log( data ); 23 | } ); 24 | -------------------------------------------------------------------------------- /mediawikijs/get_allfileusages.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_allfileusages.js 5 | 6 | MediaWiki API Demos 7 | Demo of `allfileusage` module: List all file usages, including non-existing. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | list: 'allfileusages', 16 | afprefix: 'Icon', 17 | afprop: 'ids|title' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var usages = data.query.allfileusages, 23 | img; 24 | for ( img in usages ) { 25 | console.log( usages[ img ].title ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_allimages_by_date.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_allimages_by_date.js 5 | 6 | MediaWiki API Demos 7 | List all images in the namespace, starting from January 1, 2010, at 18:05:46 UTC. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | list: 'allimages', 16 | aisort: 'timestamp', 17 | aistart: '2010-01-01T18:05:46Z' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var images = data.query.allimages, 23 | img; 24 | for ( img in images ) { 25 | console.log( images[ img ].title ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_allimages_by_name.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_allimages_by_name.js 5 | 6 | MediaWiki API Demos 7 | List all images in the namespace, starting from files that begin with 'Graffiti_000'. 8 | Limit the initial response to just the first three images. 9 | 10 | MIT License 11 | */ 12 | 13 | var params = { 14 | action: 'query', 15 | format: 'json', 16 | list: 'allimages', 17 | aifrom: 'Graffiti_000', 18 | ailimit: '3' 19 | }, 20 | api = new mw.Api(); 21 | 22 | api.get( params ).done( function ( data ) { 23 | var images = data.query.allimages, 24 | img; 25 | for ( img in images ) { 26 | console.log( images[ img ].title ); 27 | } 28 | } ); 29 | -------------------------------------------------------------------------------- /mediawikijs/get_alllinks.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_alllinks.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Alllinks` module: List links pointing to the given namespace. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | list: 'alllinks', 16 | alnamespace: '0', 17 | alunique: '1' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var links = data.query.alllinks, 23 | l; 24 | for ( l in links ) { 25 | console.log( links[ l ].title ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_allpages.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_allpages.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Allpages` module: Get all pages whose title contains the text "Jungle," 8 | in whole or part. 9 | 10 | MIT License 11 | */ 12 | 13 | var params = { 14 | action: 'query', 15 | format: 'json', 16 | list: 'allpages', 17 | apfrom: 'jungle' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var pages = data.query.allpages, 23 | p; 24 | for ( p in pages ) { 25 | console.log( pages[ p ].title ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_allredirects.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_allredirects.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Allredirects` module: Get the first three unique 8 | pages containing redirects to the main namespace. 9 | 10 | MIT License 11 | */ 12 | 13 | var params = { 14 | action: 'query', 15 | format: 'json', 16 | list: 'allredirects', 17 | arunique: '1', 18 | arnamespace: '0', 19 | arlimit: '3' 20 | }, 21 | api = new mw.Api(); 22 | 23 | api.get( params ).done( function ( data ) { 24 | var redirects = data.query.allredirects, 25 | r; 26 | for ( r in redirects ) { 27 | console.log( redirects[ r ].title ); 28 | } 29 | } ); 30 | -------------------------------------------------------------------------------- /mediawikijs/get_allrevisions.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_allrevisions.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Allrevisions` module: get revision data of multiple pages and users 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | list: 'allrevisions', 16 | arvprop: 'ids|flags|timestamp', 17 | arvuser: 'Place holder' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var revs = data.query.allrevisions, 23 | r; 24 | for ( r in revs ) { 25 | console.log( revs[ r ] ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_alltransclusions.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_alltransclusions.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Alltransclusions` module: Get three unique pages 8 | in the main namespace which contain transclusions. 9 | 10 | MIT License 11 | */ 12 | 13 | var params = { 14 | action: 'query', 15 | format: 'json', 16 | list: 'alltransclusions', 17 | atunique: '1', 18 | atnamespace: '0', 19 | atlimit: '3' 20 | }, 21 | api = new mw.Api(); 22 | 23 | api.get( params ).done( function ( data ) { 24 | var transclusions = data.query.alltransclusions, 25 | t; 26 | for ( t in transclusions ) { 27 | console.log( transclusions[ t ].title ); 28 | } 29 | } ); 30 | -------------------------------------------------------------------------------- /mediawikijs/get_allusers.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_allusers.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Allusers` module: Get all users, starting from those 8 | whose name begins with the string, 'Drov'. 9 | 10 | MIT License 11 | */ 12 | 13 | var params = { 14 | action: 'query', 15 | format: 'json', 16 | list: 'allusers', 17 | auprefix: 'Drov' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var users = data.query.allusers, 23 | u; 24 | for ( u in users ) { 25 | console.log( users[ u ].name ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_backlinks.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_backlinks.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Backlinks` module: Get request to list pages which link to a certain page. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | list: 'backlinks', 16 | bltitle: 'philosophy' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | var backlinks = data.query.backlinks, 22 | b; 23 | for ( b in backlinks ) { 24 | console.log( backlinks[ b ].title ); 25 | } 26 | } ); 27 | -------------------------------------------------------------------------------- /mediawikijs/get_blocked_users.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_blocked_users.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Blocks` module: GET request to list recent blocked users. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | list: 'blocks', 15 | bklimit: '3', 16 | bkprop: 'id|user|by|timestamp|expiry|reason|range|flags', 17 | format: 'json' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | console.log( data.query.blocks ); 23 | } ); 24 | -------------------------------------------------------------------------------- /mediawikijs/get_categories.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_categories.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Categories` module: Get categories associated with a page. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | prop: 'categories', 16 | titles: 'Janelle Monáe' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | var pages = data.query.pages, 22 | p; 23 | for ( p in pages ) { 24 | pages[ p ].categories.forEach( function ( cat ) { 25 | console.log( cat.title ); 26 | } ); 27 | } 28 | } ); 29 | -------------------------------------------------------------------------------- /mediawikijs/get_category_info.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_category_info.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Categoryinfo` module: Get information about a few categories 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | titles: 'Category:Foo|Category:Infobox templates', 16 | prop: 'categoryinfo' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | var pages = data.query.pages, 22 | page; 23 | for ( page in pages ) { 24 | console.log( pages[ page ].title + ' has ' + pages[ page ].categoryinfo.pages + ' pages.' ); 25 | } 26 | } ); 27 | -------------------------------------------------------------------------------- /mediawikijs/get_category_items.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_category_items.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Categorymembers` module : List twenty items in a category 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | list: 'categorymembers', 15 | cmtitle: 'Category:Physics', 16 | cmlimit: '20', 17 | format: 'json' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var pages = data.query.categorymembers, 23 | page; 24 | for ( page in pages ) { 25 | console.log( pages[ page ].title ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_contributors.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_contributors.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Contributors` module: Get request to list all logged-in contributors and count of anonymous contributors to a page. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | titles: 'MediaWiki', 15 | prop: 'contributors', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/get_deleted_revisions.js: -------------------------------------------------------------------------------- 1 | /* 2 | get_deleted_revisions.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Deletedrevs` module: List the six most recent deleted revisions from User:Catrope 6 | 7 | MIT License 8 | */ 9 | 10 | var params = { 11 | action: 'query', 12 | list: 'deletedrevs', 13 | druser: 'Catrope', 14 | drprop: 'revid|user|minor|len|token', 15 | drlimit: '6', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | var pages = data.query.deletedrevs, 22 | p, 23 | drev; 24 | for ( p in pages ) { 25 | console.log( 'Revision for Page ' + pages[ p ].title ); 26 | for ( drev in pages[ p ].revisions ) { 27 | console.log( pages[ p ].revisions[ drev ] ); 28 | } 29 | } 30 | } ); 31 | -------------------------------------------------------------------------------- /mediawikijs/get_deleted_revs.js: -------------------------------------------------------------------------------- 1 | /* 2 | get_deleted_revs.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Deleted Revisions module:Get a list of deleted revision for a page` module 6 | 7 | MIT License 8 | */ 9 | 10 | var api = new mw.Api(); 11 | 12 | api.login( 'your_bot_username', 'your_bot_password' ).done( function ( data ) { 13 | console.log( 'You are logged in as ' + data.login.lgusername ); 14 | } ); 15 | 16 | 17 | var params = { 18 | action: "query", 19 | format: "json", 20 | titles: "Talk:MainPage", 21 | prop: "deletedrevisions", 22 | drprop: "user|comment|content" 23 | }, 24 | api = new mw.Api(); 25 | 26 | api.get( params ).done( function ( data ) { 27 | console.log( data ); 28 | } ); -------------------------------------------------------------------------------- /mediawikijs/get_embedded_pages.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_embedded_pages.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Embeddedin` module: Get all page(s) that embed a given page 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | list: 'embeddedin', 16 | eititle: 'Computer', 17 | eilimit: '20' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var pages = data.query.embeddedin, 23 | p; 24 | for ( p in pages ) { 25 | console.log( pages[ p ].title ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_extlinks.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_extlinks.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Extlinks` module: Get a list of external links on a page 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | titles: 'Albert Einstein', 15 | prop: 'extlinks', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/get_exturlusage.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_exturlusage.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Exturlusage` module: Enumerate pages that contain a given URL. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | list: 'exturlusage', 16 | euquery: 'slashdot.org' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | var exturls = data.query.exturlusage, 22 | exturl; 23 | for ( exturl in exturls ) { 24 | console.log( 'Page ' + exturls[ exturl ].title + ' has ' + exturls[ exturl ].url + ' url.' ); 25 | } 26 | } ); 27 | -------------------------------------------------------------------------------- /mediawikijs/get_feed_recent_changes.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_feed_recent_changes.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Feedrecentchanges` module: Show recent changes as an RSS feed. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'feedrecentchanges', 14 | format: 'json' 15 | }, 16 | api = new mw.Api(); 17 | 18 | api.get( params ).done( function ( data ) { 19 | console.log( data ); 20 | } ); 21 | -------------------------------------------------------------------------------- /mediawikijs/get_file_usage.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_file_usage.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Fileusage` module: Get a list of pages using a given file. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | titles: 'File:Example.jpg', 15 | prop: 'fileusage', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/get_help.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_help.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Help` module: Get help for a specified module. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'help', 14 | modules: 'query+tokens', 15 | wrap: '', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/get_imageinfo.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_imageinfo.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Imageinfo` module: Get information about an image file. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | prop: 'imageinfo', 16 | titles: 'File:Billy Tipton.jpg' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | var pages = data.query.pages, 22 | p; 23 | for ( p in pages ) { 24 | console.log( pages[ p ].title + ' is uploaded by User:' + pages[ p ].imageinfo[ 0 ].user ); 25 | } 26 | } ); 27 | -------------------------------------------------------------------------------- /mediawikijs/get_imageusage.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_imageusage.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Imageusage` module: List the first 3 pages that use a given image title 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | list: 'imageusage', 16 | iutitle: 'File:Wiki_logo_Nupedia.jpg', 17 | iulimit: '3' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var pages = data.query.imageusage, 23 | p; 24 | for ( p in pages ) { 25 | console.log( pages[ p ].title ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_info.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_info.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Info` module: Send a GET request to display information about a page. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | titles: 'Albert Einstein', 16 | prop: 'info', 17 | inprop: 'url|talkid' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var pages = data.query.pages, 23 | p; 24 | for ( p in pages ) { 25 | console.log( pages[ p ].title + ' has ' + pages[ p ].length + ' bytes.' ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_iwlinks.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_iwlinks.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Iwlinks` module: Get the interwiki links from a given page. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | prop: 'iwlinks', 16 | titles: 'Albert Einstein' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | var pages = data.query.pages, 22 | p; 23 | for ( p in pages ) { 24 | console.log( pages[ p ].iwlinks ); 25 | } 26 | } ); 27 | -------------------------------------------------------------------------------- /mediawikijs/get_links.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_links.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Links` module: Get all links on the given page(s) 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | titles: 'Albert Einstein', 16 | prop: 'links' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | var pages = data.query.pages, 22 | p; 23 | for ( p in pages ) { 24 | pages[ p ].links.forEach( function ( l ) { 25 | console.log( l.title ); 26 | } ); 27 | } 28 | } ); 29 | -------------------------------------------------------------------------------- /mediawikijs/get_logevents.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_logevents.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Logevents` module: Get the three most recent logevents. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | list: 'logevents', 16 | lelimit: '3' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | var logs = data.query.logevents, 22 | l; 23 | for ( l in logs ) { 24 | console.log( 'There is ' + logs[ l ].type + ' log for page ' + logs[ l ].title ); 25 | } 26 | } ); 27 | -------------------------------------------------------------------------------- /mediawikijs/get_page_images.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_page_images.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Images` module: Send a GET request to obtain a JSON 8 | object listing all of the image files embedded on a single page 9 | 10 | MIT License 11 | */ 12 | 13 | var params = { 14 | action: 'query', 15 | prop: 'images', 16 | titles: 'Albert Einstein', 17 | format: 'json' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var pages = data.query.pages, 23 | page; 24 | for ( page in pages ) { 25 | pages[ page ].images.forEach( function ( img ) { 26 | console.log( img.title ); 27 | } ); 28 | } 29 | } ); 30 | -------------------------------------------------------------------------------- /mediawikijs/get_pagepropnames.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_pagepropnames.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Pagepropnames` module: List page property names on the given wiki. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | list: 'pagepropnames', 15 | format: 'json' 16 | }, 17 | api = new mw.Api(); 18 | 19 | api.get( params ).done( function ( data ) { 20 | var pageprops = data.query.pagepropnames, 21 | p; 22 | for ( p in pageprops ) { 23 | console.log( pageprops[ p ].propname ); 24 | } 25 | } ); 26 | -------------------------------------------------------------------------------- /mediawikijs/get_pages_revisions.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_pages_revisions.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Revisions` module: Get revision data with content for pages with 8 | titles [[API]] and [[Main Page]] 9 | 10 | MIT License 11 | */ 12 | 13 | var params = { 14 | action: 'query', 15 | prop: 'revisions', 16 | titles: 'API|Main Page', 17 | rvprop: 'timestamp|user|comment|content', 18 | rvslots: 'main', 19 | formatversion: '2', 20 | format: 'json' 21 | }, 22 | api = new mw.Api(); 23 | 24 | api.get( params ).done( function ( data ) { 25 | var pages = data.query.pages, 26 | p; 27 | for ( p in pages ) { 28 | console.log( pages[ p ].revisions ); 29 | } 30 | } ); 31 | -------------------------------------------------------------------------------- /mediawikijs/get_pageswithprop.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_pageswithprop.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Pageswithprop` module: List all pages using a given page property. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | list: 'pageswithprop', 15 | pwppropname: "displaytitle", 16 | format: 'json' 17 | }, 18 | 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var pageswithprops = data.query.pageswithprop, 23 | p; 24 | for ( p in pageswithprops ) { 25 | console.log( pageswithprops[ p ].title ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_protectedtitles.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_protectedtitles.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Protectedtitles` module: Get the first 2 titles which only sysops can create 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | list: 'protectedtitles', 16 | ptlevel: 'sysop', 17 | ptlimit: '2' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var pages = data.query.protectedtitles, 23 | p; 24 | for ( p in pages ) { 25 | console.log( pages[ p ].title ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_querypage_list.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_querypage_list.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Querypage` module: List first 10 pages which are uncategorized 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | list: 'querypage', 15 | qppage: 'Uncategorizedpages', 16 | qplimit: '10', 17 | format: 'json' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var querypage = data.query.querypage.results, 23 | p; 24 | for ( p in querypage ) { 25 | console.log( querypage[ p ].title ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_random.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_random.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Random` module: Get request to list 5 random pages. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | list: 'random', 16 | rnlimit: '5' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | var randoms = data.query.random, 22 | r; 23 | for ( r in randoms ) { 24 | console.log( randoms[ r ].title ); 25 | } 26 | } ); 27 | -------------------------------------------------------------------------------- /mediawikijs/get_recent_category_items.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_recent_category_items.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Categorymembers` module : Get the ten articles most recently added to a category 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | list: 'categorymembers', 15 | cmtitle: 'Category:Physics', 16 | cmsort: 'timestamp', 17 | cmdir: 'desc', 18 | format: 'json' 19 | }, 20 | api = new mw.Api(); 21 | 22 | api.get( params ).done( function ( data ) { 23 | var pages = data.query.categorymembers, 24 | page; 25 | for ( page in pages ) { 26 | console.log( pages[ page ].title ); 27 | } 28 | } ); 29 | -------------------------------------------------------------------------------- /mediawikijs/get_recent_changes.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_recent_changes.js 5 | 6 | MediaWiki API Demos 7 | Demo of `RecentChanges` module: Get the three most recent changes with sizes and flags 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | list: 'recentchanges', 15 | rcprop: 'title|ids|sizes|flags|user', 16 | rclimit: '3', 17 | format: 'json' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var recentchanges = data.query.recentchanges, 23 | rc; 24 | for ( rc in recentchanges ) { 25 | console.log( recentchanges[ rc ].title ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_red_links.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_red_links.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Links` module to identify red or missing links on a page. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | generator: 'links', 15 | titles: 'Wikipedia:Most-wanted_articles', 16 | gpllimit: '20', 17 | format: 'json' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var pages = data.query.pages, 23 | p; 24 | for ( p in pages ) { 25 | if( pages[ p ].hasOwnProperty('missing') ){ 26 | console.log( pages[ p ].title ); 27 | } 28 | } 29 | } ); 30 | -------------------------------------------------------------------------------- /mediawikijs/get_redirects.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_redirects.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Redirects` module: Get all redirects to the given page(s) 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | titles: 'Jacques Kallis', 15 | prop: 'redirects', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | var pages = data.query.pages, 22 | p; 23 | 24 | function result( p ) { 25 | pages[ p ].redirects.forEach( function ( re ) { 26 | console.log( re.title + ' redirect to ' + pages[ p ].title ); 27 | } ); 28 | } 29 | for ( p in pages ) { 30 | result( p ); 31 | } 32 | } ); 33 | -------------------------------------------------------------------------------- /mediawikijs/get_subcategories.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_subcategories.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Categorymembers` module : Get ten subcategories of a category 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | list: 'categorymembers', 15 | cmtitle: 'Category:Wikipedia', 16 | cmtype: 'subcat', 17 | format: 'json' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var category = data.query.categorymembers, 23 | cat; 24 | for ( cat in category ) { 25 | console.log( category[ cat ].title ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_tags.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_tags.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Tags` module: Get the first three change tags and their hitcounts. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | list: 'tags', 16 | tgprop: 'hitcount', 17 | tglimit: '3' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var tags = data.query.tags, 23 | t; 24 | for ( t in tags ) { 25 | console.log( tags[ t ].name ); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_transcluded_in.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_transcluded_in.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Transcludedin` module: Get a list of pages which transclude a given page 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | titles: 'Main Page', 15 | prop: 'transcludedin', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/get_user_contributions_feed.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_user_contributions_feed.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Feedcontributions` module: Show contributions of a user as an RSS feed. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'feedcontributions', 14 | user: 'Jimbo Wales', 15 | format: 'json' 16 | }, 17 | api = new mw.Api(); 18 | 19 | api.get( params ).done( function ( data ) { 20 | console.log( data ); 21 | } ); 22 | -------------------------------------------------------------------------------- /mediawikijs/get_user_watchlist_feed.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_user_watchlist_feed.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Feedwatchlist` module: Get a watchlist feed from another user. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'feedwatchlist', 14 | wlowner: 'sample_user', 15 | wltoken: 'sample_watchlist_token' 16 | }, 17 | api = new mw.Api(); 18 | 19 | api.get( params ).done( function ( data ) { 20 | console.log( data ); 21 | } ); 22 | -------------------------------------------------------------------------------- /mediawikijs/get_usercontribs.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_usercontribs.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Usercontribs` module: List user contributions. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | format: 'json', 15 | list: 'usercontribs', 16 | ucuser: 'Jimbo Wales' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | var usercontrib = data.query.usercontribs, 22 | uc; 23 | for ( uc in usercontrib ) { 24 | console.log( usercontrib[ uc ].title ); 25 | } 26 | } ); 27 | -------------------------------------------------------------------------------- /mediawikijs/get_users.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | get_users.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Users` module: Get information about several users: [[1.2.3.4]], [[Catrope]], [[Vandal01]], and [[Bob]] 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | list: 'users', 15 | ususers: 'Catrope|Bob', 16 | usprop: 'blockinfo|groups|editcount|registration|emailable|gender', 17 | format: 'json' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | var users = data.query.users, 23 | u; 24 | for ( u in users ) { 25 | console.log( users[ u ].name + " has " + users[ u ].editcount + " edits."); 26 | } 27 | } ); 28 | -------------------------------------------------------------------------------- /mediawikijs/get_watchlist.js: -------------------------------------------------------------------------------- 1 | /* 2 | get_watchlist.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Watchlist` module: Get the currently logged-in user's watchlist. 6 | 7 | MIT License 8 | */ 9 | 10 | var params = { 11 | action: 'query', 12 | list: 'watchlist', 13 | format: 'json' 14 | }, 15 | api = new mw.Api(); 16 | 17 | api.get( params ).done( function ( data ) { 18 | console.log( data ); 19 | } ); 20 | -------------------------------------------------------------------------------- /mediawikijs/get_watchlistraw.js: -------------------------------------------------------------------------------- 1 | /* 2 | get_watchlistraw.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Watchlistraw` module: Get three pages on the logged-in user's 6 | watchlist from the main namespace. 7 | 8 | MIT License 9 | */ 10 | 11 | var params = { 12 | action: 'query', 13 | list: 'watchlistraw', 14 | wrnamespace: '0', 15 | wrlimit: '3', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/import_interwiki.js: -------------------------------------------------------------------------------- 1 | /* 2 | import_interwiki.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Import` module: Import a page from another wiki by 6 | specifying its title 7 | 8 | MIT License 9 | */ 10 | 11 | var params = { 12 | action: 'import', 13 | interwikisource: 'en:w', 14 | interwikipage: 'Template:!-', 15 | fullhistory: 'true', 16 | namespace: '100', 17 | format: 'json' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.postWithToken( 'csrf', params ).done( function ( data ) { 22 | console.log( data ); 23 | } ); 24 | -------------------------------------------------------------------------------- /mediawikijs/iwbacklinks.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | iwbacklinks.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Iwbacklinks` module: Get pages that link to a given interwiki link. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | list: 'iwbacklinks', 15 | iwblprefix: 'wikibooks', 16 | iwbltitle: 'Main_Page', 17 | format: 'json' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | console.log( data ); 23 | } ); 24 | -------------------------------------------------------------------------------- /mediawikijs/langbacklinks.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | langbacklinks.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Langbacklinks` module: Get pages linking to a given language link 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | list: 'langbacklinks', 15 | lbltitle: 'Test', 16 | lbllang: 'fr', 17 | format: 'json' 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.get( params ).done( function ( data ) { 22 | console.log( data ); 23 | } ); 24 | -------------------------------------------------------------------------------- /mediawikijs/langlinks.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | langlinks.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Langlinks` module: Get a list of language links that a given page has 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | titles: 'Albert Einstein', 15 | prop: 'langlinks', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/languagesearch.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | languagesearch.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Languagesearch` module: Search for a language in any language 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'languagesearch', 14 | search: 'Gu', 15 | format: 'json' 16 | }, 17 | api = new mw.Api(); 18 | 19 | api.get( params ).done( function ( data ) { 20 | var langs = data.languagesearch, 21 | lang; 22 | for ( lang in langs ) { 23 | console.log( lang + ': ' + langs[ lang ] ); 24 | } 25 | } ); 26 | -------------------------------------------------------------------------------- /mediawikijs/linkshere.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | linkshere.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Linkshere` module: Get a list of pages linking to a given page 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | titles: 'Main Page', 15 | prop: 'linkshere', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/login.js: -------------------------------------------------------------------------------- 1 | /* 2 | login.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Login` module: Sending request to login 6 | 7 | MIT License 8 | */ 9 | 10 | var api = new mw.Api(); 11 | 12 | api.login( 'your_bot_username', 'your_bot_password' ).done( function ( data ) { 13 | console.log( 'You are logged in as ' + data.login.lgusername ); 14 | } ); 15 | -------------------------------------------------------------------------------- /mediawikijs/logout.js: -------------------------------------------------------------------------------- 1 | /* 2 | logout.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Logout` module: Log out and clear session data. 6 | 7 | MIT License 8 | */ 9 | 10 | var params = { 11 | action: 'logout', 12 | format: 'json' 13 | }, 14 | api = new mw.Api(); 15 | 16 | api.postWithToken( 'csrf', params ).done( function ( data ) { 17 | console.log( data ); 18 | } ); 19 | -------------------------------------------------------------------------------- /mediawikijs/main_module.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | main_module.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Main module` module: Get help for the main module. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'help', 14 | wrap: '', 15 | format: 'json' 16 | }, 17 | api = new mw.Api(); 18 | 19 | api.get( params ).done( function ( data ) { 20 | console.log( data ); 21 | } ); 22 | -------------------------------------------------------------------------------- /mediawikijs/move.js: -------------------------------------------------------------------------------- 1 | /* 2 | move.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Move` module: Move a page with its talk page, 6 | leaving a redirect behind. 7 | 8 | MIT License 9 | */ 10 | 11 | var params = { 12 | action: 'move', 13 | from: 'Current title', 14 | to: 'Page with new title', 15 | reason: 'API Test', 16 | movetalk: '1', 17 | noredirect: '1', 18 | format: 'json' 19 | }, 20 | api = new mw.Api(); 21 | 22 | api.postWithToken( 'csrf', params ).done( function ( data ) { 23 | console.log( data ); 24 | } ); 25 | -------------------------------------------------------------------------------- /mediawikijs/opensearch.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | opensearch.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Opensearch` module: Search the wiki and obtain 8 | results in an OpenSearch (http://www.opensearch.org) format 9 | 10 | MIT License 11 | */ 12 | 13 | var params = { 14 | action: 'opensearch', 15 | search: 'Hampi', 16 | limit: '5', 17 | namespace: '0', 18 | format: 'json' 19 | }, 20 | api = new mw.Api(); 21 | 22 | api.get( params ).done( function ( data ) { 23 | console.log( data ); 24 | } ); 25 | -------------------------------------------------------------------------------- /mediawikijs/pageprops.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | pageprops.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Pageprops` module: Get various properties defined in the page content 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | titles: 'Albert Einstein', 15 | prop: 'pageprops', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/paraminfo.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | paraminfo.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Paraminfo` module: Get information about other action API modules and their parameters. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'paraminfo', 14 | format: 'json', 15 | modules: 'parse|query+info|query' 16 | }, 17 | api = new mw.Api(); 18 | 19 | api.get( params ).done( function ( data ) { 20 | console.log( data ); 21 | } ); 22 | -------------------------------------------------------------------------------- /mediawikijs/parse.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | parse.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Parse` module: Parse content of a page 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'parse', 14 | page: 'Pet door', 15 | format: 'json' 16 | }, 17 | api = new mw.Api(); 18 | 19 | api.get( params ).done( function ( data ) { 20 | console.log( data.parse.text[ '*' ] ); 21 | } ); 22 | -------------------------------------------------------------------------------- /mediawikijs/patrol.js: -------------------------------------------------------------------------------- 1 | /* 2 | patrol.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Patrol` module: Patrol a recent change 6 | 7 | MIT License 8 | */ 9 | 10 | var params = { 11 | action: 'patrol', 12 | revid: '77', 13 | format: 'json' 14 | }, 15 | api = new mw.Api(); 16 | 17 | api.postWithToken( 'patrol', params ).done( function ( data ) { 18 | console.log( data ); 19 | } ); 20 | -------------------------------------------------------------------------------- /mediawikijs/prefixsearch.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | prefixsearch.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Prefixsearch` module: Perform a prefix search for page titles 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | list: 'prefixsearch', 15 | pssearch: 'Star Wars', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | var pages = data.query.prefixsearch, 22 | page; 23 | for ( page in pages ) { 24 | console.log( pages[ page ].title ); 25 | } 26 | } ); 27 | -------------------------------------------------------------------------------- /mediawikijs/protect.js: -------------------------------------------------------------------------------- 1 | /* 2 | protect.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Protect` module: Demo to change the edit protection 6 | level of a given page. 7 | 8 | MIT License 9 | */ 10 | 11 | var params = { 12 | action: 'protect', 13 | title: 'Sandbo2', 14 | protections: 'edit=autoconfirmed|move=sysop', 15 | expiry: 'infinite', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.postWithToken( 'csrf', params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/purge_namespace_pages.js: -------------------------------------------------------------------------------- 1 | /* 2 | purge_namespace_pages.js 3 | 4 | MediaWiki API Demos 5 | Demo of `purge` module: Sending post request to purge first 10 pages in the main namespace 6 | 7 | MIT License 8 | */ 9 | 10 | var params = { 11 | action: 'purge', 12 | generator: 'allpages', 13 | gapnamespace: '0', 14 | gaplimit: '10', 15 | format: 'json' 16 | }, 17 | api = new mw.Api(); 18 | 19 | api.post( params ).done( function ( data ) { 20 | console.log( data ); 21 | } ); 22 | -------------------------------------------------------------------------------- /mediawikijs/purge_two_pages.js: -------------------------------------------------------------------------------- 1 | /* 2 | purge_namespace_pages.js 3 | 4 | MediaWiki API Demos 5 | Demo of `purge` module: Sending post request to purge first 10 pages in the main namespace 6 | 7 | MIT License 8 | */ 9 | 10 | var params = { 11 | action: 'purge', 12 | titles: 'Main_Page|Nonexistent', 13 | format: 'json' 14 | }, 15 | api = new mw.Api(); 16 | 17 | api.post( params ).done( function ( data ) { 18 | console.log( data ); 19 | } ); 20 | -------------------------------------------------------------------------------- /mediawikijs/reset_password.js: -------------------------------------------------------------------------------- 1 | /* 2 | reset_password.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Resetpassword` module: Reset password for all users with an email address. 6 | 7 | MIT license 8 | */ 9 | 10 | var params = { 11 | action: 'resetpassword', 12 | email: 'user@mediawiki.org', 13 | format: 'json' 14 | }, 15 | api = new mw.Api(); 16 | 17 | api.postWithToken( 'csrf', params ).done( function ( data ) { 18 | console.log( data ); 19 | } ); -------------------------------------------------------------------------------- /mediawikijs/revision_delete.js: -------------------------------------------------------------------------------- 1 | /* 2 | revision_delete.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Revisiondelete` module: Hide all information about a certain revision ID. 6 | 7 | MIT license 8 | */ 9 | 10 | var params = { 11 | action: 'revisiondelete', 12 | type: 'revision', 13 | ids: '71', 14 | format: 'json', 15 | hide: 'content|comment|user', 16 | reason: 'Because', 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.postWithToken( 'csrf', params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); -------------------------------------------------------------------------------- /mediawikijs/rollback.js: -------------------------------------------------------------------------------- 1 | /* 2 | rollback.js 3 | 4 | MediaWiki API Demos 5 | Demo of `rollback` module: Sending post request to rollback the 6 | last edits made to a given page. 7 | 8 | MIT License 9 | */ 10 | 11 | var params = { 12 | action: 'rollback', 13 | title: 'Sandbox', 14 | user: '10.0.2.2', 15 | format: 'json' 16 | }, 17 | api = new mw.Api(); 18 | 19 | api.postWithToken( 'rollback', params ).done( function ( data ) { 20 | console.log( data ); 21 | } ); 22 | -------------------------------------------------------------------------------- /mediawikijs/rsd.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | rsd.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Rsd` module: Get request to export an RSD schema. 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'rsd', 14 | format: 'json' 15 | }, 16 | api = new mw.Api(); 17 | 18 | api.get( params ).done( function ( data ) { 19 | console.log( data ); 20 | } ); 21 | -------------------------------------------------------------------------------- /mediawikijs/search.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | search.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Search` module: Search for a text or title 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | list: 'search', 15 | srsearch: 'Nelson Mandela', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | if ( data.query.search[ 0 ].title === 'Nelson Mandela' ) { 22 | console.log( "Your search page 'Nelson Mandela' exists on English Wikipedia" ); 23 | } 24 | } ); 25 | -------------------------------------------------------------------------------- /mediawikijs/send_email.js: -------------------------------------------------------------------------------- 1 | /* 2 | send_email.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Emailuser` module: sending POST request to send email to wiki user 6 | 7 | MIT License 8 | */ 9 | 10 | var params = { 11 | action: 'emailuser', 12 | target: 'ABC', 13 | subject: 'Hi', 14 | text: 'Just wanted to say hi', 15 | format: 'json' 16 | }, 17 | api = new mw.Api(); 18 | 19 | api.postWithToken( 'csrf', params ).done( function ( data ) { 20 | console.log( data ); 21 | } ); 22 | -------------------------------------------------------------------------------- /mediawikijs/set_notification_timestamp.js: -------------------------------------------------------------------------------- 1 | /* 2 | set_notification_timestamp.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Setnotificationtimestamp` module: Reset the notification status for the entire watchlist. 6 | 7 | MIT license 8 | */ 9 | 10 | var params = { 11 | action: 'setnotificationtimestamp', 12 | entirewatchlist: '', 13 | format: 'json' 14 | }, 15 | api = new mw.Api(); 16 | 17 | api.postWithToken( 'csrf', params ).done( function ( data ) { 18 | console.log( data ); 19 | } ); -------------------------------------------------------------------------------- /mediawikijs/set_page_language.js: -------------------------------------------------------------------------------- 1 | /* 2 | set_page_language.js 3 | 4 | MediaWiki API Demos 5 | Demo of `SetPageLanguage` module: POST request to change 6 | the language of a page 7 | 8 | MIT License 9 | */ 10 | 11 | var params = { 12 | action: 'setpagelanguage', 13 | pageid: '66400', 14 | lang: 'es', 15 | format: 'json' 16 | }, 17 | api = new mw.Api(); 18 | 19 | api.postWithToken( 'csrf', params ).done( function ( data ) { 20 | console.log( data ); 21 | } ); 22 | -------------------------------------------------------------------------------- /mediawikijs/stash_image_info.js: -------------------------------------------------------------------------------- 1 | /* 2 | stash_image_info.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Stashimageinfo` module: Return information for a stashed file. 6 | 7 | MIT License 8 | */ 9 | 10 | var params = { 11 | action: "query", 12 | format: "json", 13 | prop: "stashimageinfo", 14 | siifilekey: "124sd34rsdf567" 15 | }, 16 | api = new mw.Api(); 17 | 18 | api.get( params ).done( function ( data ) { 19 | console.log( data ); 20 | } ); 21 | -------------------------------------------------------------------------------- /mediawikijs/tag.js: -------------------------------------------------------------------------------- 1 | /* 2 | tag.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Tag` module: Remove the spam tag from log entry ID 123 with the reason Wrongly applied 6 | 7 | MIT license 8 | */ 9 | 10 | var params = { 11 | 12 | action: "compare", 13 | format: "json", 14 | token: csrf_token, 15 | logid: "123", 16 | remove: "spam", 17 | reason: "Wrongly applied" 18 | }, 19 | api = new mw.Api(); 20 | 21 | api.postWithToken( 'csrf', params ).done( function ( data ) { 22 | console.log( data ); 23 | } ); 24 | -------------------------------------------------------------------------------- /mediawikijs/templates.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | templates.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Templates` module: Get a list of templates used on a page 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | titles: 'Albert Einstein', 15 | prop: 'templates', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/tokens.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | tokens.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Token` module: Fetch token of type `csrf` 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | meta: 'tokens', 15 | type: 'csrf', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data.query.tokens.csrftoken ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/undelete.js: -------------------------------------------------------------------------------- 1 | /* 2 | undelete.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Undelete` module: Restore two revisions of a deleted page 6 | 7 | MIT License 8 | */ 9 | 10 | var params = { 11 | action: 'undelete', 12 | title: 'Sandbox', 13 | reason: 'Test undeleting via the API', 14 | format: 'json' 15 | }, 16 | api = new mw.Api(); 17 | 18 | api.postWithToken( 'csrf', params ).done( function ( data ) { 19 | console.log( data ); 20 | } ); 21 | -------------------------------------------------------------------------------- /mediawikijs/upload_file_directly.js: -------------------------------------------------------------------------------- 1 | /* 2 | upload_file_directly.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Upload` module: Sending post request to upload a file directly 6 | MIT license 7 | */ 8 | 9 | var param = { 10 | filename: 'File_1.jpg', 11 | format: 'json', 12 | ignorewarnings: 1 13 | }, 14 | fileInput = $( '' ).attr( 'type', 'file' ), 15 | submitBtn = $( '' ).attr( 'type', 'button' ).attr( 'value', 'Upload' ), 16 | api = new mw.Api(); 17 | 18 | $( '#bodyContent' ).append( [ fileInput, submitBtn ] ); 19 | 20 | $( submitBtn ).on( 'click', function () { 21 | api.upload( fileInput[ 0 ], param ).done( function ( data ) { 22 | console.log( data.upload.filename + ' has sucessfully uploaded.' ); 23 | } ).fail( function ( data ) { 24 | console.log( data ); 25 | } ); 26 | } ); 27 | -------------------------------------------------------------------------------- /mediawikijs/upload_file_from_url.js: -------------------------------------------------------------------------------- 1 | /* 2 | upload_file_from_url.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Upload` module: Post request to upload a file from a URL 6 | 7 | MIT License 8 | */ 9 | 10 | var params = { 11 | action: 'upload', 12 | filename: 'New_image.jpg', 13 | url: 'https://farm9.staticflickr.com/8213/8300206113_374c017fc5.jpg', 14 | ignorewarnings: '1', 15 | format: 'json' 16 | }, 17 | api = new mw.Api(); 18 | 19 | api.postWithToken( 'csrf', params ).done( function ( data ) { 20 | console.log( data ); 21 | } ); 22 | -------------------------------------------------------------------------------- /mediawikijs/userinfo.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. See modules.json and autogenerator.py for details 2 | 3 | /* 4 | userinfo.js 5 | 6 | MediaWiki API Demos 7 | Demo of `Userinfo` module: Get general user info and user rights 8 | 9 | MIT License 10 | */ 11 | 12 | var params = { 13 | action: 'query', 14 | meta: 'userinfo', 15 | uiprop: 'rights', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.get( params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/userrights.js: -------------------------------------------------------------------------------- 1 | /* 2 | userrights.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Userrights` module: Add and remove user rights by 6 | changing the user's group membership. 7 | 8 | MIT License 9 | */ 10 | 11 | var params = { 12 | action: 'userrights', 13 | user: 'ABCD', 14 | add: 'sysop', 15 | reason: 'Added ABCD to the sysop group', 16 | format: 'json' 17 | }, 18 | api = new mw.Api(); 19 | 20 | api.postWithToken( 'userrights', params ).done( function ( data ) { 21 | console.log( data ); 22 | } ); 23 | -------------------------------------------------------------------------------- /mediawikijs/validatepassword.js: -------------------------------------------------------------------------------- 1 | /* 2 | validatepassword.js 3 | 4 | MediaWiki Action API Code Samples 5 | Demo of `Validatepassword` module: Validate a password against the wiki's password policies. 6 | MIT license 7 | */ 8 | 9 | var params = { 10 | action: "validatepassword", 11 | password: "my_password", 12 | format: "json" 13 | }, 14 | api = new mw.Api(); 15 | 16 | api.postWithToken( 'csrf', params ).done( function ( data ) { 17 | console.log( data ); 18 | } ); 19 | -------------------------------------------------------------------------------- /mediawikijs/watch.js: -------------------------------------------------------------------------------- 1 | /* 2 | watch.js 3 | 4 | MediaWiki API Demos 5 | Demo of `Watch` module: Add a page to your watchlist 6 | 7 | MIT License 8 | */ 9 | 10 | var params = { 11 | action: 'watch', 12 | titles: 'Sandbox', 13 | format: 'json' 14 | }, 15 | api = new mw.Api(); 16 | 17 | api.postWithToken( 'watch', params ).done( function ( data ) { 18 | console.log( data ); 19 | } ); 20 | -------------------------------------------------------------------------------- /php/all_messages.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "meta" => "allmessages", 18 | "ammessages" => "august|mainpage|edit|rollback-success", 19 | "amlang" => "nl", 20 | "format" => "json" 21 | ]; 22 | 23 | $url = $endPoint . "?" . http_build_query( $params ); 24 | 25 | $ch = curl_init( $url ); 26 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 27 | $output = curl_exec( $ch ); 28 | curl_close( $ch ); 29 | 30 | $result = json_decode( $output, true ); 31 | var_dump( $result ); 32 | -------------------------------------------------------------------------------- /php/check_token.php: -------------------------------------------------------------------------------- 1 | "checktoken", 17 | "token" => "123ABC", 18 | "type" => "csrf", 19 | "format" => "json" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | echo( $output ); 30 | -------------------------------------------------------------------------------- /php/clear_has_msg.php: -------------------------------------------------------------------------------- 1 | "clearhasmsg", 15 | "format" => "json" 16 | ]; 17 | 18 | $ch = curl_init(); 19 | 20 | curl_setopt( $ch, CURLOPT_URL, $endPoint ); 21 | curl_setopt( $ch, CURLOPT_POST, true ); 22 | curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query( $params ) ); 23 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 24 | curl_setopt( $ch, CURLOPT_COOKIEJAR, "cookie.txt" ); 25 | curl_setopt( $ch, CURLOPT_COOKIEFILE, "cookie.txt" ); 26 | 27 | $response = curl_exec($ch); 28 | curl_close($ch); 29 | 30 | echo ($response); 31 | -------------------------------------------------------------------------------- /php/compare.php: -------------------------------------------------------------------------------- 1 | "compare", 17 | "fromtitle" => "Template:Unsigned", 18 | "totitle" => "Template:UnsignedIP", 19 | "format" => "json" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | var_dump( $result ); 31 | -------------------------------------------------------------------------------- /php/duplicate_files.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "titles" => "Image:1995.jpg|Image:Welcome.gif", 18 | "prop" => "duplicatefiles", 19 | "format" => "json" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | var_dump( $result ); 31 | -------------------------------------------------------------------------------- /php/expand_templates.php: -------------------------------------------------------------------------------- 1 | "expandtemplates", 17 | "text" => "{{Project:Sandbox}}", 18 | "prop" => "wikitext", 19 | "format" => "json" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | var_dump( $result ); 31 | -------------------------------------------------------------------------------- /php/file_archive.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "list" => "filearchive", 18 | "format" => "json" 19 | ]; 20 | 21 | $url = $endPoint . "?" . http_build_query( $params ); 22 | 23 | $ch = curl_init( $url ); 24 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 25 | $output = curl_exec( $ch ); 26 | curl_close( $ch ); 27 | 28 | $result = json_decode( $output, true ); 29 | var_dump( $result ); 30 | -------------------------------------------------------------------------------- /php/file_repo_info.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "meta" => "filerepoinfo", 18 | "friprop" => "url|name|displayname", 19 | "format" => "json" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | var_dump( $result ); 31 | -------------------------------------------------------------------------------- /php/filearchive.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "falimit" => "3", 18 | "list" => "filearchive", 19 | "fadir" => "descending", 20 | "format" => "json" 21 | ]; 22 | 23 | $url = $endPoint . "?" . http_build_query( $params ); 24 | 25 | $ch = curl_init( $url ); 26 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 27 | $output = curl_exec( $ch ); 28 | curl_close( $ch ); 29 | 30 | $result = json_decode( $output, true ); 31 | var_dump( $result ); 32 | -------------------------------------------------------------------------------- /php/general_site_info.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "meta" => "siteinfo", 18 | "formatversion" => "2", 19 | "format" => "json" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | var_dump( $result ); 31 | -------------------------------------------------------------------------------- /php/get_alldeletedrevs.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "list" => "alldeletedrevisions", 18 | "adruser" => "Mahesh", 19 | "adrprop" => "ids|user|comment", 20 | "format" => "json" 21 | ]; 22 | 23 | $url = $endPoint . "?" . http_build_query( $params ); 24 | 25 | $ch = curl_init( $url ); 26 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 27 | $output = curl_exec( $ch ); 28 | curl_close( $ch ); 29 | 30 | $result = json_decode( $output, true ); 31 | var_dump( $result ); 32 | -------------------------------------------------------------------------------- /php/get_contributors.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "titles" => "MediaWiki", 18 | "prop" => "contributors", 19 | "format" => "json" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | var_dump( $result ); 31 | -------------------------------------------------------------------------------- /php/get_extlinks.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "titles" => "Albert Einstein", 18 | "prop" => "extlinks", 19 | "format" => "json" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | var_dump( $result ); 31 | -------------------------------------------------------------------------------- /php/get_feed_recent_changes.php: -------------------------------------------------------------------------------- 1 | "feedrecentchanges", 17 | "format" => "json" 18 | ]; 19 | 20 | $url = $endPoint . "?" . http_build_query( $params ); 21 | 22 | $ch = curl_init( $url ); 23 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 24 | $output = curl_exec( $ch ); 25 | curl_close( $ch ); 26 | 27 | var_dump( $output ); 28 | -------------------------------------------------------------------------------- /php/get_file_usage.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "titles" => "File:Example.jpg", 18 | "prop" => "fileusage", 19 | "format" => "json" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | var_dump( $result ); 31 | -------------------------------------------------------------------------------- /php/get_help.php: -------------------------------------------------------------------------------- 1 | "help", 17 | "modules" => "query+tokens", 18 | "wrap" => "", 19 | "format" => "json" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | var_dump( $result ); 31 | -------------------------------------------------------------------------------- /php/get_iwlinks.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "format" => "json", 18 | "prop" => "iwlinks", 19 | "titles" => "Albert Einstein" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | 31 | foreach( $result["query"]["pages"] as $k => $v ) { 32 | var_dump( $v["iwlinks"] ); 33 | } -------------------------------------------------------------------------------- /php/get_pagepropnames.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "list" => "pagepropnames", 18 | "format" => "json" 19 | ]; 20 | 21 | $url = $endPoint . "?" . http_build_query( $params ); 22 | 23 | $ch = curl_init( $url ); 24 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 25 | $output = curl_exec( $ch ); 26 | curl_close( $ch ); 27 | 28 | $result = json_decode( $output, true ); 29 | 30 | foreach( $result["query"]["pagepropnames"] as $k => $v ) { 31 | echo( $v["propname"] . "\n" ); 32 | } 33 | -------------------------------------------------------------------------------- /php/get_random.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "format" => "json", 18 | "list" => "random", 19 | "rnlimit" => "5" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | 31 | foreach( $result["query"]["random"] as $k => $v ) { 32 | echo( $v["title"] . "\n" ); 33 | } 34 | -------------------------------------------------------------------------------- /php/get_transcluded_in.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "titles" => "Main Page", 18 | "prop" => "transcludedin", 19 | "format" => "json" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | var_dump( $result ); 31 | -------------------------------------------------------------------------------- /php/get_user_contributions_feed.php: -------------------------------------------------------------------------------- 1 | "feedcontributions", 17 | "user" => "Jimbo Wales", 18 | "format" => "json" 19 | ]; 20 | 21 | $url = $endPoint . "?" . http_build_query( $params ); 22 | 23 | $ch = curl_init( $url ); 24 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 25 | $output = curl_exec( $ch ); 26 | curl_close( $ch ); 27 | 28 | var_dump( $output ); 29 | -------------------------------------------------------------------------------- /php/get_user_watchlist_feed.php: -------------------------------------------------------------------------------- 1 | "feedwatchlist", 17 | "wlowner" => "sample_user", 18 | "wltoken" => "sample_watchlist_token" 19 | ]; 20 | 21 | $url = $endPoint . "?" . http_build_query( $params ); 22 | 23 | $ch = curl_init( $url ); 24 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 25 | $output = curl_exec( $ch ); 26 | curl_close( $ch ); 27 | 28 | $result = json_decode( $output, true ); 29 | var_dump( $result ); 30 | -------------------------------------------------------------------------------- /php/get_usercontribs.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "format" => "json", 18 | "list" => "usercontribs", 19 | "ucuser" => "Jimbo Wales" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | 31 | foreach( $result["query"]["usercontribs"] as $k => $v ) { 32 | echo( $v["title"] . "\n" ); 33 | } 34 | -------------------------------------------------------------------------------- /php/iwbacklinks.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "list" => "iwbacklinks", 18 | "iwblprefix" => "wikibooks", 19 | "iwbltitle" => "Main_Page", 20 | "format" => "json" 21 | ]; 22 | 23 | $url = $endPoint . "?" . http_build_query( $params ); 24 | 25 | $ch = curl_init( $url ); 26 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 27 | $output = curl_exec( $ch ); 28 | curl_close( $ch ); 29 | 30 | echo( $output ); 31 | -------------------------------------------------------------------------------- /php/langbacklinks.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "list" => "langbacklinks", 18 | "lbltitle" => "Test", 19 | "lbllang" => "fr", 20 | "format" => "json" 21 | ]; 22 | 23 | $url = $endPoint . "?" . http_build_query( $params ); 24 | 25 | $ch = curl_init( $url ); 26 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 27 | $output = curl_exec( $ch ); 28 | curl_close( $ch ); 29 | 30 | $result = json_decode( $output, true ); 31 | var_dump( $result ); 32 | -------------------------------------------------------------------------------- /php/langlinks.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "titles" => "Albert Einstein", 18 | "prop" => "langlinks", 19 | "format" => "json" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | var_dump( $result ); 31 | -------------------------------------------------------------------------------- /php/languagesearch.php: -------------------------------------------------------------------------------- 1 | "languagesearch", 17 | "search" => "Gu", 18 | "format" => "json" 19 | ]; 20 | 21 | $url = $endPoint . "?" . http_build_query( $params ); 22 | 23 | $ch = curl_init( $url ); 24 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 25 | $output = curl_exec( $ch ); 26 | curl_close( $ch ); 27 | 28 | $result = json_decode( $output, true ); 29 | 30 | foreach( $result["languagesearch"] as $langcode => $langname ) { 31 | echo( $langcode . ": " . $langname . "\n" ); 32 | } -------------------------------------------------------------------------------- /php/linkshere.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "titles" => "Main Page", 18 | "prop" => "linkshere", 19 | "format" => "json" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | var_dump( $result ); 31 | -------------------------------------------------------------------------------- /php/main_module.php: -------------------------------------------------------------------------------- 1 | "help", 17 | "wrap" => "", 18 | "format" => "json" 19 | ]; 20 | 21 | $url = $endPoint . "?" . http_build_query( $params ); 22 | 23 | $ch = curl_init( $url ); 24 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 25 | $output = curl_exec( $ch ); 26 | curl_close( $ch ); 27 | 28 | $result = json_decode( $output, true ); 29 | var_dump( $result ); 30 | -------------------------------------------------------------------------------- /php/opensearch.php: -------------------------------------------------------------------------------- 1 | "opensearch", 18 | "search" => "Hampi", 19 | "limit" => "5", 20 | "namespace" => "0", 21 | "format" => "json" 22 | ]; 23 | 24 | $url = $endPoint . "?" . http_build_query( $params ); 25 | 26 | $ch = curl_init( $url ); 27 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 28 | $output = curl_exec( $ch ); 29 | curl_close( $ch ); 30 | 31 | $result = json_decode( $output, true ); 32 | var_dump( $result ); 33 | -------------------------------------------------------------------------------- /php/pageprops.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "titles" => "Albert Einstein", 18 | "prop" => "pageprops", 19 | "format" => "json" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | var_dump( $result ); 31 | -------------------------------------------------------------------------------- /php/paraminfo.php: -------------------------------------------------------------------------------- 1 | "paraminfo", 17 | "format" => "json", 18 | "modules" => "parse|query+info|query" 19 | ]; 20 | 21 | $url = $endPoint . "?" . http_build_query( $params ); 22 | 23 | $ch = curl_init( $url ); 24 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 25 | $output = curl_exec( $ch ); 26 | curl_close( $ch ); 27 | 28 | $result = json_decode( $output, true ); 29 | var_dump( $result ); 30 | -------------------------------------------------------------------------------- /php/parse.php: -------------------------------------------------------------------------------- 1 | "parse", 17 | "page" => "Pet door", 18 | "format" => "json" 19 | ]; 20 | 21 | $url = $endPoint . "?" . http_build_query( $params ); 22 | 23 | $ch = curl_init( $url ); 24 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 25 | $output = curl_exec( $ch ); 26 | curl_close( $ch ); 27 | 28 | $result = json_decode( $output, true ); 29 | 30 | echo( $result["parse"]["text"]["*"] ); -------------------------------------------------------------------------------- /php/purge_two_pages.php: -------------------------------------------------------------------------------- 1 | "purge", 21 | "titles" => "Main_Page|Nonexistent", 22 | "format" => "json" 23 | ]; 24 | 25 | $ch = curl_init(); 26 | 27 | curl_setopt( $ch, CURLOPT_URL, $endPoint ); 28 | curl_setopt( $ch, CURLOPT_POST, true ); 29 | curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query( $params ) ); 30 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 31 | 32 | $output = curl_exec( $ch ); 33 | curl_close( $ch ); 34 | 35 | echo ( $output ); 36 | } 37 | -------------------------------------------------------------------------------- /php/rsd.php: -------------------------------------------------------------------------------- 1 | "rsd", 17 | "format" => "json" 18 | ]; 19 | 20 | $url = $endPoint . "?" . http_build_query( $params ); 21 | 22 | $ch = curl_init( $url ); 23 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 24 | $output = curl_exec( $ch ); 25 | curl_close( $ch ); 26 | 27 | $result = json_decode( $output, true ); 28 | var_dump( $result ); 29 | -------------------------------------------------------------------------------- /php/templates.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "titles" => "Albert Einstein", 18 | "prop" => "templates", 19 | "format" => "json" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | var_dump( $result ); 31 | -------------------------------------------------------------------------------- /php/tokens.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "meta" => "tokens", 18 | "type" => "login", 19 | "format" => "json" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | echo( $result['query']['tokens']['logintoken'] . "\n" ); 31 | -------------------------------------------------------------------------------- /php/userinfo.php: -------------------------------------------------------------------------------- 1 | "query", 17 | "meta" => "userinfo", 18 | "uiprop" => "rights", 19 | "format" => "json" 20 | ]; 21 | 22 | $url = $endPoint . "?" . http_build_query( $params ); 23 | 24 | $ch = curl_init( $url ); 25 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 26 | $output = curl_exec( $ch ); 27 | curl_close( $ch ); 28 | 29 | $result = json_decode( $output, true ); 30 | var_dump( $result ); 31 | -------------------------------------------------------------------------------- /python/all_messages.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | all_messages.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Allmessages` module: Get the Dutch translations of some messages 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "meta": "allmessages", 23 | "ammessages": "august|mainpage|edit|rollback-success", 24 | "amlang": "nl", 25 | "format": "json" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | print(DATA) 32 | -------------------------------------------------------------------------------- /python/check_token.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | check_token.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Checktoken` module: Check a CSRF token. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "checktoken", 22 | "token": "123ABC", 23 | "type": "csrf", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | print(DATA) 31 | -------------------------------------------------------------------------------- /python/clear_has_msg.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | """ 4 | clear_has_msg.py 5 | 6 | MediaWiki API Demos 7 | Demo of `ClearHasMsg` module: Clear the hasmsg flag for the current user. 8 | 9 | MIT License 10 | """ 11 | 12 | import requests 13 | 14 | S = requests.Session() 15 | 16 | URL = "https://en.wikipedia.org/w/api.php" 17 | 18 | PARAMS = { 19 | "action": "clearhasmsg", 20 | "format": "json" 21 | } 22 | 23 | R = S.post(url=URL, data=PARAMS) 24 | DATA = R.json() 25 | 26 | print(DATA) 27 | -------------------------------------------------------------------------------- /python/compare.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | compare.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Compare` module: Compare the current revisions of two different pages. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "compare", 22 | "fromtitle": "Template:Unsigned", 23 | "totitle": "Template:UnsignedIP", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | print(DATA) 31 | -------------------------------------------------------------------------------- /python/duplicate_files.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | duplicate_files.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Duplicatefiles` module: List duplicates of the given files. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "titles": "Image:1995.jpg|Image:Welcome.gif", 23 | "prop": "duplicatefiles", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | print(DATA) 31 | -------------------------------------------------------------------------------- /python/expand_templates.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | expand_templates.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Expandtemplates` module: Obtain general site info. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "expandtemplates", 22 | "text": "{{Project:Sandbox}}", 23 | "prop": "wikitext", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | print(DATA) 31 | -------------------------------------------------------------------------------- /python/file_archive.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | file_archive.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Filearchive` module: Get a list of all deleted files. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "list": "filearchive", 23 | "format": "json" 24 | } 25 | 26 | R = S.get(url=URL, params=PARAMS) 27 | DATA = R.json() 28 | 29 | print(DATA) 30 | -------------------------------------------------------------------------------- /python/file_repo_info.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | file_repo_info.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Filerepoinfo` module: Get information about file repositories. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "meta": "filerepoinfo", 23 | "friprop": "url|name|displayname", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | print(DATA) 31 | -------------------------------------------------------------------------------- /python/filearchive.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | filearchive.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Filearchive` module: Enumerate 3 deleted files from filearchive table in descending order. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "falimit": "3", 23 | "list": "filearchive", 24 | "fadir": "descending", 25 | "format": "json" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | print(DATA) 32 | -------------------------------------------------------------------------------- /python/general_site_info.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | general_site_info.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Siteinfo` module: Obtain general site info. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "meta": "siteinfo", 23 | "formatversion": "2", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | print(DATA) 31 | -------------------------------------------------------------------------------- /python/geocoordinates.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | geocoordinates.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Geosearch` module: Obtain coordinates for wiki pages nearby 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "format": "json", 23 | "titles": "Wikimedia Foundation", 24 | "prop": "coordinates" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | PAGES = DATA['query']['pages'] 30 | 31 | for k, v in PAGES.items(): 32 | print("Latitute: " + str(v['coordinates'][0]['lat'])) 33 | print("Longitude: " + str(v['coordinates'][0]['lon'])) 34 | -------------------------------------------------------------------------------- /python/geosearch.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | geosearch.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Geosearch` module: Search for wiki pages nearby 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "format": "json", 22 | "list": "geosearch", 23 | "gscoord": "37.7891838|-122.4033522", 24 | "gslimit": "10", 25 | "gsradius": "10000", 26 | "action": "query" 27 | } 28 | 29 | R = S.get(url=URL, params=PARAMS) 30 | DATA = R.json() 31 | 32 | PLACES = DATA['query']['geosearch'] 33 | 34 | for place in PLACES: 35 | print(place['title']) 36 | -------------------------------------------------------------------------------- /python/get_allcategories.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_allcategories.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Allcategories` module: Get all categories, starting from a 10 | certain point, as ordered by category title. 11 | 12 | MIT License 13 | """ 14 | 15 | import requests 16 | 17 | S = requests.Session() 18 | 19 | URL = "https://en.wikipedia.org/w/api.php" 20 | 21 | PARAMS = { 22 | "action": "query", 23 | "format": "json", 24 | "list": "allcategories", 25 | "acfrom": "15th-century caliphs" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | CATEGORIES = DATA["query"]["allcategories"] 32 | 33 | for cat in CATEGORIES: 34 | print(cat["*"]) 35 | -------------------------------------------------------------------------------- /python/get_alldeletedrevs.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_alldeletedrevs.py 7 | 8 | MediaWiki API Demos 9 | Demo of `alldeletedrevisions` module: List the all deleted revisions from User 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "list": "alldeletedrevisions", 23 | "adruser": "Mahesh", 24 | "adrprop": "ids|user|comment", 25 | "format": "json" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | print(DATA) 32 | -------------------------------------------------------------------------------- /python/get_allfileusages.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_allfileusages.py 7 | 8 | MediaWiki API Demos 9 | Demo of `allfileusage` module: List all file usages, including non-existing 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "afprefix": "Icon", 23 | "list": "allfileusages", 24 | "afprop": "ids|title", 25 | "format": "json" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | USAGES = DATA["query"]["allfileusages"] 32 | 33 | for img in USAGES: 34 | print(img["title"]) 35 | -------------------------------------------------------------------------------- /python/get_allimages_by_date.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_allimages_by_date.py 7 | 8 | MediaWiki API Demos 9 | List all images in the namespace, starting from January 1, 2010, 10 | at 18:05:46 UTC. 11 | 12 | MIT License 13 | """ 14 | 15 | import requests 16 | 17 | S = requests.Session() 18 | 19 | URL = "https://en.wikipedia.org/w/api.php" 20 | 21 | PARAMS = { 22 | "action": "query", 23 | "format": "json", 24 | "list": "allimages", 25 | "aisort": "timestamp", 26 | "aistart": "2010-01-01T18:05:46Z" 27 | } 28 | 29 | R = S.get(url=URL, params=PARAMS) 30 | DATA = R.json() 31 | 32 | IMAGES = DATA["query"]["allimages"] 33 | 34 | for img in IMAGES: 35 | print(img["title"]) 36 | -------------------------------------------------------------------------------- /python/get_allimages_by_name.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_allimages_by_name.py 7 | 8 | MediaWiki API Demos 9 | List all images in the namespace, starting from files that begin with 10 | 'Graffiti_000'. Limit the initial response to just the first three images. 11 | 12 | MIT License 13 | """ 14 | 15 | import requests 16 | 17 | S = requests.Session() 18 | 19 | URL = "https://en.wikipedia.org/w/api.php" 20 | 21 | PARAMS = { 22 | "action": "query", 23 | "format": "json", 24 | "list": "allimages", 25 | "aifrom": "Graffiti_000", 26 | "ailimit": "3" 27 | } 28 | 29 | R = S.get(url=URL, params=PARAMS) 30 | DATA = R.json() 31 | 32 | IMAGES = DATA["query"]["allimages"] 33 | 34 | for img in IMAGES: 35 | print(img["title"]) 36 | -------------------------------------------------------------------------------- /python/get_alllinks.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_alllinks.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Alllinks` module: List links pointing to the given namespace. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "format": "json", 23 | "list": "alllinks", 24 | "alnamespace": "0", 25 | "alunique": "1" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | LINKS = DATA["query"]["alllinks"] 32 | 33 | for l in LINKS: 34 | print(l["title"]) 35 | -------------------------------------------------------------------------------- /python/get_allpages.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_allpages.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Allpages` module: Get all pages whose title contains the text 10 | "Jungle," in whole or part. 11 | 12 | MIT License 13 | """ 14 | 15 | import requests 16 | 17 | S = requests.Session() 18 | 19 | URL = "https://en.wikipedia.org/w/api.php" 20 | 21 | PARAMS = { 22 | "action": "query", 23 | "format": "json", 24 | "list": "allpages", 25 | "apfrom": "jungle", 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | PAGES = DATA["query"]["allpages"] 32 | 33 | for page in PAGES: 34 | print(page["title"]) 35 | -------------------------------------------------------------------------------- /python/get_allredirects.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | python/get_allredirects.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Allredirects` module: Get the first three unique pages containing 10 | redirects to the main namespace. 11 | 12 | MIT License 13 | """ 14 | 15 | import requests 16 | 17 | S = requests.Session() 18 | 19 | URL = "https://en.wikipedia.org/w/api.php" 20 | 21 | PARAMS = { 22 | "action": "query", 23 | "format": "json", 24 | "list": "allredirects", 25 | "arunique": "1", 26 | "arnamespace": "0", 27 | "arlimit": "3" 28 | } 29 | 30 | R = S.get(url=URL, params=PARAMS) 31 | DATA = R.json() 32 | 33 | REDIRECTS = DATA["query"]["allredirects"] 34 | 35 | for r in REDIRECTS: 36 | print(r["title"]) 37 | -------------------------------------------------------------------------------- /python/get_allrevisions.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_allrevisions.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Allrevisions` module: get revision data of multiple pages and users 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "arvprop": "ids|flags|timestamp", 23 | "arvuser": "Place holder", 24 | "list": "allrevisions", 25 | "format": "json" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | ALLREVISIONS = DATA["query"]["allrevisions"] 32 | 33 | for rev in ALLREVISIONS: 34 | print(rev) 35 | -------------------------------------------------------------------------------- /python/get_allusers.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_allusers.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Allusers` module: Get all users, starting from those whose name 10 | begins with the string, 'Drov'. 11 | 12 | MIT License 13 | """ 14 | 15 | import requests 16 | 17 | S = requests.Session() 18 | 19 | URL = "https://en.wikipedia.org/w/api.php" 20 | 21 | PARAMS = { 22 | "action": "query", 23 | "format": "json", 24 | "list": "allusers", 25 | "auprefix": "Drov" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | USERS = DATA["query"]["allusers"] 32 | 33 | for user in USERS: 34 | print(user["name"]) 35 | -------------------------------------------------------------------------------- /python/get_backlinks.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_backlinks.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Backlinks` module: Get request to list pages which link to a certain page. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "format": "json", 23 | "list": "backlinks", 24 | "bltitle": "philosophy" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | BACKLINKS = DATA["query"]["backlinks"] 31 | 32 | for b in BACKLINKS: 33 | print(b["title"]) 34 | -------------------------------------------------------------------------------- /python/get_blocked_users.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_blocked_users.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Blocks` module: GET request to list recent blocked users 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "bklimit": "3", 23 | "list": "blocks", 24 | "bkprop": "id|user|by|timestamp|expiry|reason|range|flags", 25 | "format": "json" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | print(DATA['query']['blocks']) 32 | -------------------------------------------------------------------------------- /python/get_categories.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_categories.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Categories` module: Get categories associated with a page. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "format": "json", 23 | "prop": "categories", 24 | "titles": "Janelle Monáe" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | PAGES = DATA["query"]["pages"] 31 | 32 | for k, v in PAGES.items(): 33 | for cat in v['categories']: 34 | print(cat["title"]) 35 | -------------------------------------------------------------------------------- /python/get_category_info.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | """ 4 | get_category_info.py 5 | 6 | MediaWiki API Demos 7 | Demo of `Categoryinfo` module: Get information about few categories 8 | MIT license 9 | """ 10 | 11 | import requests 12 | 13 | S = requests.Session() 14 | 15 | URL = "https://en.wikipedia.org/w/api.php" 16 | 17 | PARAMS = { 18 | "action": "query", 19 | "format": "json", 20 | "titles": "Category:Foo|Category:Infobox templates", 21 | "prop": "categoryinfo" 22 | } 23 | 24 | R = S.get(url=URL, params=PARAMS) 25 | DATA = R.json() 26 | 27 | PAGES = DATA["query"]["pages"] 28 | 29 | for k, v in PAGES.items(): 30 | print(v["title"] + " has " + str(v["categoryinfo"]["pages"]) + " pages.") 31 | -------------------------------------------------------------------------------- /python/get_category_items.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_category_items.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Categorymembers` module : List twenty items in a category 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "cmtitle": "Category:Physics", 23 | "cmlimit": "20", 24 | "list": "categorymembers", 25 | "format": "json" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | PAGES = DATA['query']['categorymembers'] 32 | 33 | for page in PAGES: 34 | print(page['title']) 35 | -------------------------------------------------------------------------------- /python/get_contributors.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_contributors.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Contributors` module: Get request to list all logged-in contributors and count of anonymous contributors to a page. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "titles": "MediaWiki", 23 | "prop": "contributors", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | print(DATA) 31 | -------------------------------------------------------------------------------- /python/get_embedded_pages.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_embedded_lists.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Embeddedin` module: Get all page(s) that 10 | embed a given page 11 | 12 | MIT License 13 | """ 14 | 15 | import requests 16 | 17 | S = requests.Session() 18 | 19 | URL = "https://en.wikipedia.org/w/api.php" 20 | 21 | PARAMS = { 22 | "action": "query", 23 | "format": "json", 24 | "list": "embeddedin", 25 | "eititle": "Computer", 26 | "eilimit": "20" 27 | } 28 | 29 | R = S.get(url=URL, params=PARAMS) 30 | DATA = R.json() 31 | 32 | PAGES = DATA["query"]["embeddedin"] 33 | 34 | for p in PAGES: 35 | print(p["title"]) 36 | -------------------------------------------------------------------------------- /python/get_extlinks.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_extlinks.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Extlinks` module: Get a list of external links on a page 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "titles": "Albert Einstein", 23 | "prop": "extlinks", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | print(DATA) 31 | -------------------------------------------------------------------------------- /python/get_exturlusage.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_exturlusage.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Exturlusage` module: Enumerate pages that contain a given URL. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "format": "json", 23 | "list": "exturlusage", 24 | "euquery": "slashdot.org" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | EXTURLS = DATA["query"]["exturlusage"] 31 | 32 | for exturl in EXTURLS: 33 | print("Page " + exturl["title"] + " has " + exturl["url"] + " url.") 34 | -------------------------------------------------------------------------------- /python/get_feed_recent_changes.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_feed_recent_changes.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Feedrecentchanges` module: Show recent changes as an RSS feed. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "feedrecentchanges", 22 | "format": "json" 23 | } 24 | 25 | R = S.get(url=URL, params=PARAMS) 26 | DATA = R.content 27 | 28 | print(DATA) 29 | -------------------------------------------------------------------------------- /python/get_file_usage.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_file_usage.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Fileusage` module: Get a list of pages using a given file. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "titles": "File:Example.jpg", 23 | "prop": "fileusage", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | print(DATA) 31 | -------------------------------------------------------------------------------- /python/get_help.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_help.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Help` module: Get help for a specified module. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "help", 22 | "modules": "query+tokens", 23 | "wrap": "", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | print(DATA) 31 | -------------------------------------------------------------------------------- /python/get_imageinfo.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_imageinfo.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Imageinfo` module: Get information about an image file. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "format": "json", 23 | "prop": "imageinfo", 24 | "titles": "File:Billy_Tipton.jpg" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | PAGES = DATA["query"]["pages"] 31 | 32 | for k, v in PAGES.items(): 33 | print(v["title"] + " is uploaded by User:" + v["imageinfo"][0]["user"]) 34 | -------------------------------------------------------------------------------- /python/get_imageusage.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | python/get_imageusage.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Imageusage` module: List the first 3 pages that use a given image title 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "format": "json", 23 | "list": "imageusage", 24 | "iutitle": "File:Wiki_logo_Nupedia.jpg", 25 | "iulimit": "3" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | PAGES = DATA["query"]["imageusage"] 32 | 33 | for p in PAGES: 34 | print(p["title"]) 35 | -------------------------------------------------------------------------------- /python/get_info.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_info.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Info` module: Send a GET request to display information about a page. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "format": "json", 23 | "titles": "Albert Einstein", 24 | "prop": "info", 25 | "inprop": "url|talkid" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | PAGES = DATA["query"]["pages"] 32 | 33 | for k, v in PAGES.items(): 34 | print(v["title"] + " has " + str(v["length"]) + " bytes.") 35 | -------------------------------------------------------------------------------- /python/get_iwlinks.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | python/get_iwlinks.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Iwlinks` module: Get the interwiki links from a given page. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "format": "json", 23 | "prop": "iwlinks", 24 | "titles": "Albert Einstein" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | PAGES = DATA["query"]["pages"] 31 | 32 | for k, v in PAGES.items(): 33 | print(v["iwlinks"]) 34 | -------------------------------------------------------------------------------- /python/get_links.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_links.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Links` module: Get all links on the given page(s) 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "format": "json", 23 | "titles": "Albert Einstein", 24 | "prop": "links" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | PAGES = DATA["query"]["pages"] 31 | 32 | for k, v in PAGES.items(): 33 | for l in v["links"]: 34 | print(l["title"]) 35 | -------------------------------------------------------------------------------- /python/get_logevents.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | python/get_logevents.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Logevents` module: Get the three most recent logevents. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "format": "json", 23 | "list": "logevents", 24 | "lelimit": "3" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | LOGS = DATA["query"]["logevents"] 31 | 32 | for l in LOGS: 33 | print("There is " + l["type"] + " log for page " + l["title"]) 34 | -------------------------------------------------------------------------------- /python/get_page_images.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_page_images.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Images` module: Send a GET request to obtain a JSON 10 | object listing all of the image files embedded on a single page 11 | 12 | MIT License 13 | """ 14 | 15 | import requests 16 | 17 | S = requests.Session() 18 | 19 | URL = "https://en.wikipedia.org/w/api.php" 20 | 21 | PARAMS = { 22 | "action": "query", 23 | "format": "json", 24 | "titles": "Albert Einstein", 25 | "prop": "images" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | PAGES = DATA['query']['pages'] 32 | 33 | for k, v in PAGES.items(): 34 | for img in v['images']: 35 | print(img["title"]) 36 | -------------------------------------------------------------------------------- /python/get_pagepropnames.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_pagepropnames.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Pagepropnames` module: List page property names on the given wiki. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "list": "pagepropnames", 23 | "format": "json" 24 | } 25 | 26 | R = S.get(url=URL, params=PARAMS) 27 | DATA = R.json() 28 | 29 | PAGEPROPS = DATA["query"]["pagepropnames"] 30 | 31 | for p in PAGEPROPS: 32 | print(p["propname"]) 33 | -------------------------------------------------------------------------------- /python/get_pageswithprop.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_pageswithprop.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Pageswithprop` module: List all pages using a given page property. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "list": "pageswithprop", 23 | "pwppropname": "displaytitle", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | PAGESWITHPROP = DATA["query"]["pageswithprop"] 31 | 32 | for p in PAGESWITHPROP: 33 | print(p["title"]) 34 | -------------------------------------------------------------------------------- /python/get_protectedtitles.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | python/get_protectedtitles.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Protectedtitles` module: Get the first 2 titles which only sysops can create 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "format": "json", 23 | "list": "protectedtitles", 24 | "ptlevel": "sysop", 25 | "ptlimit": "2" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | PAGES = DATA["query"]["protectedtitles"] 32 | 33 | for p in PAGES: 34 | print(p["title"]) 35 | -------------------------------------------------------------------------------- /python/get_querypage_list.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_querypage_list.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Querypage` module: List first 10 pages which are uncategorized 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "qplimit": "10", 22 | "action": "query", 23 | "qppage": "Uncategorizedpages", 24 | "list": "querypage", 25 | "format": "json" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | QUERYPAGE = DATA['query']['querypage']['results'] 32 | 33 | for p in QUERYPAGE: 34 | print(str(p['title'])) 35 | -------------------------------------------------------------------------------- /python/get_random.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_random.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Random` module: Get request to list 5 random pages. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "format": "json", 23 | "list": "random", 24 | "rnlimit": "5" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | RANDOMS = DATA["query"]["random"] 31 | 32 | for r in RANDOMS: 33 | print(r["title"]) 34 | -------------------------------------------------------------------------------- /python/get_recent_category_items.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_recent_category_items.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Categorymembers` module : Get the ten articles most recently added to a category 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "cmdir": "desc", 22 | "format": "json", 23 | "list": "categorymembers", 24 | "action": "query", 25 | "cmtitle": "Category:Physics", 26 | "cmsort": "timestamp" 27 | } 28 | 29 | R = S.get(url=URL, params=PARAMS) 30 | DATA = R.json() 31 | 32 | PAGES = DATA["query"]["categorymembers"] 33 | 34 | for page in PAGES: 35 | print(page["title"]) 36 | -------------------------------------------------------------------------------- /python/get_recent_changes.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_recent_changes.py 7 | 8 | MediaWiki API Demos 9 | Demo of `RecentChanges` module: Get the three most recent changes with 10 | sizes and flags 11 | 12 | MIT License 13 | """ 14 | 15 | import requests 16 | 17 | S = requests.Session() 18 | 19 | URL = "https://en.wikipedia.org/w/api.php" 20 | 21 | PARAMS = { 22 | "format": "json", 23 | "rcprop": "title|ids|sizes|flags|user", 24 | "list": "recentchanges", 25 | "action": "query", 26 | "rclimit": "3" 27 | } 28 | 29 | R = S.get(url=URL, params=PARAMS) 30 | DATA = R.json() 31 | 32 | RECENTCHANGES = DATA['query']['recentchanges'] 33 | 34 | for rc in RECENTCHANGES: 35 | print(str(rc['title'])) 36 | -------------------------------------------------------------------------------- /python/get_red_links.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_red_links.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Links` module to identify red or missing links on a page. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "titles": "Wikipedia:Most-wanted_articles", 23 | "gpllimit": "20", 24 | "format": "json", 25 | "generator": "links" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | PAGES = DATA['query']['pages'] 32 | 33 | for page in PAGES.values(): 34 | if 'missing' in page: 35 | print(page['title']) 36 | -------------------------------------------------------------------------------- /python/get_redirects.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_redirects.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Redirects` module: Get all redirects to the given page(s) 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "format": "json", 23 | "titles": "Jacques Kallis", 24 | "prop": "redirects" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | PAGES = DATA["query"]["pages"] 31 | 32 | for k, v in PAGES.items(): 33 | for re in v["redirects"]: 34 | print(re["title"] + " redirect to " + v["title"]) 35 | -------------------------------------------------------------------------------- /python/get_subcategories.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_subcategories.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Categorymembers` module : Get ten subcategories of a category 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "cmtitle": "Category:Wikipedia", 23 | "cmtype": "subcat", 24 | "list": "categorymembers", 25 | "format": "json" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | PAGES = DATA["query"]["categorymembers"] 32 | 33 | for page in PAGES: 34 | print(page["title"]) 35 | -------------------------------------------------------------------------------- /python/get_tags.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | python/get_tags.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Tags` module: Get the first three change tags and their hitcounts. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "format": "json", 23 | "list": "tags", 24 | "tgprop": "hitcount", 25 | "tglimit": "3" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | TAGS = DATA["query"]["tags"] 32 | 33 | for t in TAGS: 34 | print(t["name"]) 35 | -------------------------------------------------------------------------------- /python/get_transcluded_in.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_transcluded_in.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Transcludedin` module: Get a list of pages which transclude a given page 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "titles": "Main Page", 23 | "prop": "transcludedin", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | print(DATA) 31 | -------------------------------------------------------------------------------- /python/get_user_contributions_feed.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_user_contributions_feed.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Feedcontributions` module: Show contributions of a user as an RSS feed. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "feedcontributions", 22 | "user": "Jimbo Wales", 23 | "format": "json" 24 | } 25 | 26 | R = S.get(url=URL, params=PARAMS) 27 | DATA = R.content 28 | 29 | print(DATA) 30 | -------------------------------------------------------------------------------- /python/get_user_watchlist_feed.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_user_watchlist_feed.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Feedwatchlist` module: Get a watchlist feed from another user. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "feedwatchlist", 22 | "wlowner": "sample_user", 23 | "wltoken": "sample_watchlist_token" 24 | } 25 | 26 | R = S.get(url=URL, params=PARAMS) 27 | DATA = R.text 28 | 29 | print(DATA) 30 | -------------------------------------------------------------------------------- /python/get_usercontribs.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | get_usercontribs.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Usercontribs` module: List user contributions. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "format": "json", 23 | "list": "usercontribs", 24 | "ucuser": "Jimbo Wales" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | USERCONTRIBS = DATA["query"]["usercontribs"] 31 | 32 | for uc in USERCONTRIBS: 33 | print(uc["title"]) 34 | -------------------------------------------------------------------------------- /python/iwbacklinks.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | iwbacklinks.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Iwbacklinks` module: Get pages that link to a given interwiki link. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "list": "iwbacklinks", 23 | "iwblprefix": "wikibooks", 24 | "iwbltitle": "Main_Page", 25 | "format": "json" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | print(DATA) 32 | -------------------------------------------------------------------------------- /python/langbacklinks.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | langbacklinks.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Langbacklinks` module: Get pages linking to a given language link 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "list": "langbacklinks", 23 | "lbltitle": "Test", 24 | "lbllang": "fr", 25 | "format": "json" 26 | } 27 | 28 | R = S.get(url=URL, params=PARAMS) 29 | DATA = R.json() 30 | 31 | print(DATA) 32 | -------------------------------------------------------------------------------- /python/langlinks.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | langlinks.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Langlinks` module: Get a list of language links that a given page has 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "titles": "Albert Einstein", 23 | "prop": "langlinks", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | print(DATA) 31 | -------------------------------------------------------------------------------- /python/languagesearch.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | languagesearch.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Languagesearch` module: Search for a language in any language 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "languagesearch", 22 | "search": "Gu", #Could be name of the language, its iso code or native name 23 | "format": "json" 24 | } 25 | 26 | R = S.get(url=URL, params=PARAMS) 27 | DATA = R.json() 28 | 29 | LANG = DATA['languagesearch'] 30 | for code, name in LANG.items(): 31 | print(code + ": " + name) 32 | -------------------------------------------------------------------------------- /python/linkshere.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | linkshere.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Linkshere` module: Get a list of pages linking to a given page 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "titles": "Main Page", 23 | "prop": "linkshere", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | print(DATA) 31 | -------------------------------------------------------------------------------- /python/main_module.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | main_module.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Main module` module: Get help for the main module. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "help", 22 | "wrap": "", 23 | "format": "json" 24 | } 25 | 26 | R = S.get(url=URL, params=PARAMS) 27 | DATA = R.json() 28 | 29 | print(DATA) 30 | -------------------------------------------------------------------------------- /python/opensearch.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | opensearch.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Opensearch` module: Search the wiki and obtain 10 | results in an OpenSearch (http://www.opensearch.org) format 11 | 12 | MIT License 13 | """ 14 | 15 | import requests 16 | 17 | S = requests.Session() 18 | 19 | URL = "https://en.wikipedia.org/w/api.php" 20 | 21 | PARAMS = { 22 | "action": "opensearch", 23 | "namespace": "0", 24 | "search": "Hampi", 25 | "limit": "5", 26 | "format": "json" 27 | } 28 | 29 | R = S.get(url=URL, params=PARAMS) 30 | DATA = R.json() 31 | 32 | print(DATA) 33 | -------------------------------------------------------------------------------- /python/pageprops.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | pageprops.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Pageprops` module: Get various properties defined in the page content 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "titles": "Albert Einstein", 23 | "prop": "pageprops", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | print(DATA) 31 | -------------------------------------------------------------------------------- /python/paraminfo.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | paraminfo.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Paraminfo` module: Obtain information about other modules. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "paraminfo", 22 | "format": "json", 23 | "modules": "parse|query+info|query" 24 | } 25 | 26 | R = S.get(url=URL, params=PARAMS) 27 | DATA = R.json() 28 | 29 | print(DATA) 30 | -------------------------------------------------------------------------------- /python/parse.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | parse.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Parse` module: Parse content of a page 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "parse", 22 | "page": "Pet door", 23 | "format": "json" 24 | } 25 | 26 | R = S.get(url=URL, params=PARAMS) 27 | DATA = R.json() 28 | 29 | print(DATA["parse"]["text"]["*"]) 30 | -------------------------------------------------------------------------------- /python/prefixsearch.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | prefixsearch.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Prefixsearch` module: Perform a prefix search for page titles 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "format": "json", 23 | "list": "prefixsearch", 24 | "pssearch": "Star Wars" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | PAGES = DATA['query']['prefixsearch'] 31 | 32 | for page in PAGES: 33 | print(page["title"]) 34 | -------------------------------------------------------------------------------- /python/purge_namespace_pages.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | """ 4 | purge_namespace_pages.py 5 | 6 | MediaWiki API Demos 7 | Demo of `purge` module: Sending post request to purge first 10 pages in the main namespace 8 | MIT license 9 | """ 10 | 11 | import requests 12 | 13 | S = requests.Session() 14 | 15 | URL = "https://en.wikipedia.org/w/api.php" 16 | 17 | PARAMS = { 18 | "action": "purge", 19 | "generator": "allpages", 20 | "gapnamespace": "0", 21 | "gaplimit": "10", 22 | "format": "json" 23 | } 24 | 25 | R = S.post(url=URL, params=PARAMS) 26 | DATA = R.text 27 | 28 | print(DATA) 29 | -------------------------------------------------------------------------------- /python/purge_two_pages.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | """ 4 | purge_two_pages.py 5 | 6 | MediaWiki API Demos 7 | Demo of `purge` module: Sending post request to purge two or more pages 8 | MIT license 9 | """ 10 | import requests 11 | 12 | S = requests.Session() 13 | 14 | URL = "https://en.wikipedia.org/w/api.php" 15 | 16 | PARAMS = { 17 | "action": "purge", 18 | "titles": "Main_Page|Nonexistent", 19 | "format": "json" 20 | } 21 | 22 | R = S.post(url=URL, params=PARAMS) 23 | DATA = R.text 24 | 25 | print(DATA) 26 | -------------------------------------------------------------------------------- /python/rsd.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | rsd.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Rsd` module: Get request to export an RSD schema. 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "rsd", 22 | "format": "json" 23 | } 24 | 25 | R = S.get(url=URL, params=PARAMS) 26 | DATA = R.json() 27 | 28 | print(DATA) 29 | -------------------------------------------------------------------------------- /python/search.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | search.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Search` module: Search for a text or title 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | SEARCHPAGE = "Nelson Mandela" 21 | 22 | PARAMS = { 23 | "action": "query", 24 | "format": "json", 25 | "list": "search", 26 | "srsearch": SEARCHPAGE 27 | } 28 | 29 | R = S.get(url=URL, params=PARAMS) 30 | DATA = R.json() 31 | 32 | if DATA['query']['search'][0]['title'] == SEARCHPAGE: 33 | print("Your search page '" + SEARCHPAGE + "' exists on English Wikipedia") 34 | -------------------------------------------------------------------------------- /python/templates.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | templates.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Templates` module: Get a list of templates used on a page 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "titles": "Albert Einstein", 23 | "prop": "templates", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | print(DATA) 31 | -------------------------------------------------------------------------------- /python/tokens.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | tokens.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Token` module: Fetch token of type `login` 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://www.mediawiki.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "meta": "tokens", 23 | "type": "login", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | LOGIN_TOKEN = DATA['query']['tokens']['logintoken'] 31 | 32 | print(LOGIN_TOKEN) 33 | -------------------------------------------------------------------------------- /python/userinfo.py: -------------------------------------------------------------------------------- 1 | #This file is auto-generated. See modules.json and autogenerator.py for details 2 | 3 | #!/usr/bin/python3 4 | 5 | """ 6 | userinfo.py 7 | 8 | MediaWiki API Demos 9 | Demo of `Userinfo` module: Get general user info and user rights 10 | 11 | MIT License 12 | """ 13 | 14 | import requests 15 | 16 | S = requests.Session() 17 | 18 | URL = "https://en.wikipedia.org/w/api.php" 19 | 20 | PARAMS = { 21 | "action": "query", 22 | "meta": "userinfo", 23 | "uiprop": "rights", 24 | "format": "json" 25 | } 26 | 27 | R = S.get(url=URL, params=PARAMS) 28 | DATA = R.json() 29 | 30 | print(DATA) 31 | -------------------------------------------------------------------------------- /python/validatepassword.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | """ 4 | validatepassword.py 5 | 6 | MediaWiki Action API Code Samples 7 | Demo of `Validatepassword` module: Validate a password against the wiki's password policies. 8 | MIT license 9 | """ 10 | 11 | import requests 12 | 13 | URL = "https://en.wikipedia.org/w/api.php" 14 | 15 | S = requests.Session() 16 | 17 | PARAMS = { 18 | "action": "validatepassword", 19 | "format": "json", 20 | "password": "your_password", 21 | } 22 | 23 | R = S.post(URL, data=PARAMS) 24 | DATA = R.json() 25 | 26 | print(DATA) 27 | --------------------------------------------------------------------------------