mwstake / mediawiki-component-commonwebapis
Provides various web APIs (Action API and REST)
Installs: 15 073
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 8
Forks: 2
Open Issues: 4
Requires
Requires (Dev)
- mediawiki/mediawiki-codesniffer: 39.0.0
- mediawiki/minus-x: 1.1.1
- php-parallel-lint/php-console-highlighter: 1.0.0
- php-parallel-lint/php-parallel-lint: 1.3.2
- phpunit/phpunit: ^8.5
- dev-master
- 2.0.29
- 2.0.28
- 2.0.27
- 2.0.26
- 2.0.25
- 2.0.24
- 2.0.23
- 2.0.22
- 2.0.21
- 2.0.20
- 2.0.19
- 2.0.18
- 2.0.17
- 2.0.16
- 2.0.15
- 2.0.14
- 2.0.13
- 2.0.12
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.0.x-dev
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-FixFileQueryMajor
- dev-category-store
- dev-AddTitleIsRedirect
- dev-user_query_bug_fix
- dev-FixBatch
- dev-title_tree
- dev-T336567
This package is auto-updated.
Last update: 2024-11-15 13:20:46 UTC
README
Common Web APIs for MediaWiki
Provides various web APIs (Action API and REST).
This code is meant to be executed within the MediaWiki application context. No standalone usage is intended.
Compatibility
2.0.x
-> MediaWiki 1.391.0.x
-> MediaWiki 1.35
Prerequisites
Use in a MediaWiki extension
Require this component in the composer.json
of your extension:
{ "require": { "mwstake/mediawiki-component-commonwebapis": "~2" } }
Getting the available endpoints
$endpoints = MediaWikiServices::getInstance()->getService( 'MWStakeCommonWebAPIs' )->getAvailableEndpoints();
will yield a list of all registered endpoints as well as their REST path configuration
Clientside abstraction
To make it easier to access these endpoints from JS, an abstraction is implemented.
To enable it, load RL module ext.mws.commonwebapis
and use it like this:
mw.loader.using( 'ext.mws.commonwebapis' ).then( function () { mws.commonwebapi.user.query( { query: 'MyUser' } ); } );
REST API
Filtering
In order to specify filters, you can use the filter
parameter. It is an JSON-encoded array of objects. Each object has the following properties:
property
- The field to filter onvalue
- The value to filter onoperator
- The operator to use for the filter. Possible values areeq
(equals),neq
(not equals),lt
(less than),lte
(less than or equal),gt
(greater than),gte
(greater than or equal),like
(like),nlike
(not like),in
(in),nin
(not in),isnull
(is null),isnotnull
(is not null),between
(between),nbetween
(not between),ilike
(case insensitive like),nilike
(case insensitive not like),regexp
(regular expression),nregexp
(not regular expression). Depending on the type of the filter, some operators might not be available.type
- The type of the value. Possible values arestring
,integer
,float
,boolean
,list
Sorting
In order to specify sorting, you can use the sort
parameter. It is an JSON-encoded array of objects. Each object has the following properties:
property
- The field to sort ondirection
- The direction to sort. Possible values areasc
(ascending) anddesc
(descending)
Example
mw.loader.using( 'ext.mws.commonwebapis' ).then( function () { mws.commonwebapi.user.query( { filter: JSON.stringify( [ { field: 'user_name', value: 'MyUser', operator: 'eq', type: 'string' } ] ), sort: JSON.stringify( [ { field: 'user_name', direction: 'asc' } ] ) } ); } );