This is an old revision of the document!
Table of Contents
JSON-RPC API
note this is currently experimental. Feedback via Github issues is welcome. The interface might still change.
This API provides access to all remote API functionality described in XML-RPC using a more modern JSON based API.
Get It Working
- Set the remote option to enable JSON-RPC in the Configuration Settings “Authentication” section
- Set the remoteuser option with a mix of comma separated “usernames,@groups”
- For security reasons it's safer to allow access to the JSON-RPC over HTTPS only. DokuWiki's
.htaccess.dist
contains some rewrite rules to do that. - If you want to access the API from JavaScript, you might want to tune the remotecors option
Accessing The JSON-RPC Interface
You can access the JSON-RPC interface via the following URL:
http(s)://<your wiki/domain/ip>/lib/exe/jsonrpc.php
The API allows access via two different protocols:
- A simplified RPC protocol, where the the method to call is passed as a path segment and the body contains the array of parameters to pass
- Standard conform JSON-RPC calls either using version 1.0, 1.1 or 2.0.
Please note: this is not a REST API. All calls have to made as POST requests.
Simplified Access
This is the easiest way to interact with the API when you're implementing it yourself.
The function you want to call has to be given as a path segment:
http(s)://<your wiki/domain/ip>/lib/exe/jsonrpc.php/<function>
All parameters are passed as a JSON Array in the body of the request. Here's an example using curl:
curl http://localhost/dokuwiki/lib/exe/jsonrpc.php/wiki.getPageInfo \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $token" \ -d '["wiki:syntax"]'
JSON-RPC Standard
The main difference to the simplified form is that all info, including the method to call is passed as body:
curl http://localhost/dokuwiki/lib/exe/jsonrpc.php/wiki.getPageInfo \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $token" \ -d '{"jsonrpc": "2.0", "id": "something", "method": "wiki.getPageInfo", "params": ["wiki:syntax"]}'
Please note, when using version 2.0, only positional parameters are supported. Batching multiple calls is not supported.
Results
Results are always returned as a JSON object.
Here's an example response for a wiki.getPageInfo
call:
{ "result": { "name": "wiki:syntax", "lastModified": 1698917236, "author": "admin", "version": 1698917236 }, "error": { "code": 0, "message": "success" } }
The result object is the result of your call, the error object will have a non-zero code if something goes wrong.
Available Functions
Please refer to the description at XMLRPC.