mw.Rest(optionsopt)

new mw.Rest(optionsopt) #

Constructor to create an object to interact with the REST API of a particular MediaWiki server. mw.Rest objects represent the REST API of a particular MediaWiki server.

Parameters:

Name Type Attributes Description
options mw.Rest.Options <optional>

See mw.Rest.Options

Source:
Constructor to create an object to interact with the REST API of a particular MediaWiki server.

Methods

abort() #

Abort all unfinished requests issued by this Api object.

Source:
Abort all unfinished requests issued by this Api object.

ajax(path, ajaxOptionsopt) → {jQuery.Promise} #

Perform the API call.

Parameters:

Name Type Attributes Description
path string
ajaxOptions Object <optional>
Source:

Returns:

Done: API response data and the jqXHR object. Fail: Error code

Type
jQuery.Promise
Perform the API call.

delete(path, body, headersopt) → {jQuery.Promise} #

Perform REST API DELETE request.

Note: only sending application/json is currently supported.

Parameters:

Name Type Attributes Description
path string
body Object
headers Object <optional>
Source:

Returns:

Type
jQuery.Promise
Perform REST API DELETE request.

get(path, query, headersopt) → {jQuery.Promise} #

Perform REST API get request.

Parameters:

Name Type Attributes Description
path string
query Object
headers Object <optional>
Source:

Returns:

Type
jQuery.Promise
Perform REST API get request.

post(path, bodyopt, headersopt) → {jQuery.Promise} #

Perform REST API post request.

Note: only sending application/json is currently supported.

Parameters:

Name Type Attributes Description
path string
body Object <optional>
headers Object <optional>
Source:

Returns:

Type
jQuery.Promise
Perform REST API post request.

put(path, body, headersopt) → {jQuery.Promise} #

Perform REST API PUT request.

Note: only sending application/json is currently supported.

Parameters:

Name Type Attributes Description
path string
body Object
headers Object <optional>
Source:

Returns:

Type
jQuery.Promise
Perform REST API PUT request.

Type Definitions

Options #

Type:

  • Object

Properties:

Name Type Attributes Default Description
ajax Object <optional>
{ url: mw.util.wikiScript( 'rest' ), timeout: 30 * 1000 }

Default options for ajax() calls. Can be overridden by passing options to the mw.Rest constructor.

Source: