|
Wikibase
MediaWiki Wikibase extension
|
As of REL1_44, the Wikibase REST API is enabled when the Wikibase repo extension is loaded
To enable routes in development (not recommended for production use), also add:
Some REST API routes — particularly those related to Items and Properties search — require Elasticsearch to be configured and enabled through the CirrusSearch extensions.
If Elasticsearch is not set up, these routes will return an error response.
Our REST API specification is provided using an OpenAPI specification in the specs directory. The latest version is published on doc.wikimedia.org.
The specification can be "built" (i.e., compiled into a single JSON OpenAPI specs file) and validated using the provided npm scripts.
To modify API specs, install npm dependencies first, using a command like the following:
API specs can be validated using the npm test script, using a command like the following:
API specs can be bundled into a single file using the npm build:spec script, using a command like the following:
Autodocs can be generated from the API specification using the npm build:docs script, using a command like the following:
The base URL of the API can be configured by passing an API_URL environment variable:
The autodocs and the bundled OpenAPI specification files are generated in the ../../docs/rest-api/ directory.
MAJOR.MINOR versions, omitting .PATCH, will be created as we see little use for patch versions./info/version field of the OpenAPI schema.Descriptions of the different kinds of tests can be found in the respective section of the directory structure overview above.
These tests can be run with the command npm run api-testing.
The following needs to be correctly set up in order for all the tests to pass:
.api-testing.config file in repo/rest-api (next to this README.md file) - see the MediaWiki API integration tests docsX-Config-Override hack from Wikibase.ci.php to your LocalSettings.php. Do NOT do this on any sort of production wiki.