API talk:Edit/Editing with Python

mediawiki 1.32
This example is deprecated in mediawiki 1.32 How would a working example look like nowadays?

older
For mediawiki version 1.19 change line to

params3 = '?format=json&action=query&prop=info&intoken=edit&titles=Main%20Page'

--

For MediaWiki 	1.25.2 PHP 	5.5.0 (cgi-fcgi) MySQL 	5.0.45

payload = {'action': 'query', 'format': 'json', 'utf8': '', 'meta': 'tokens', 'type': 'login'} r1 = requests.post(baseurl + 'api.php', data=payload) print(r1.json)
 * 1) Login request

$ python *.py {'warnings': {'tokens': {'*': "Unrecognized value for parameter 'type': login"}}, 'query': {'tokens': {}}} Traceback (most recent call last): File "import.py", line 17, in    login_token = r1.json['query']['tokens']['logintoken'] KeyError: 'logintoken'

--

Help
I runned this. It returns an error Traceback (most recent call last): File "C:\Users\maathavan.Maathavan-PC\Downloads\compat\mycode.py", line 2, in    import requests ImportError: No module named requests Help me--Maathavan (talk) 08:13, 15 April 2016 (UTC)