Jump to content

API:Documentation template: Difference between revisions

From mediawiki.org
Content deleted Content added
Martyav (talk | contribs)
more in line with what is actually being used in the top 50 API docs project (see my user page)
mNo edit summary
Line 10: Line 10:
== Example ==
== Example ==


=== GET Request ===
=== GET request ===
{{ApiEx
{{ApiEx
|desc=Description of script
|desc=Description of script

Revision as of 14:56, 5 October 2019

MediaWiki version:
1.23

API documentation

To embed the documentation of an API module, use the template below. Remember to replace "module name" with the name of an actual module. All main modules are here.

Example

GET request

Description of script

Response

{
    "batchcomplete":""
}

Sample code

hello.py

#!/usr/bin/python3

"""
    hello.py

    MediaWiki Action API Code Samples
    Demo of `...` module
    MIT license
"""

import requests

S = requests.Session()

URL = "https://en.wikipedia.org/w/api.php"

PARAMS = {
    'action':"query",
    'format':"json"
}

R = S.get(url=URL, params=PARAMS)
DATA = R.json()

print(DATA)

Demo app(s)

  • Add a link to the demo app. Embed an image of the demo if applicable

Possible errors

Code Info

Parameter history

  • v1.x: Introduced parameter_1, parameter_2
  • v0.x: Deprecated parameter_3

Additional notes

See also

  • Add link to documentation of related modules