Skip to content

DokuWiki API and Integration — XML-RPC, JSON API, and External Integration

DodaTech Updated 2026-06-28 7 min read

In this tutorial, you'll learn how to integrate DokuWiki with external systems using the XML-RPC API, JSON API endpoints, webhooks, and common integration patterns for automation.

What You'll Learn

  • DokuWiki's XML-RPC API and available methods
  • Making API calls from scripts and applications
  • JSON API integration
  • Webhook setup for event-driven integration
  • Integration patterns (CI/CD, monitoring, chatops)
  • Securing API access

Why It Matters

A wiki that does not integrate with other tools is an island. The API lets you automate wiki operations from scripts, integrate with chat platforms, trigger page updates from CI/CD pipelines, and build custom applications that interact with wiki content. Integration turns your wiki from a standalone tool into a connected part of your infrastructure.

Real-World Use

A CI/CD pipeline automatically creates a deployment notes page every time a release is deployed. The pipeline script calls the DokuWiki XML-RPC API to: create a new page in the deployments: namespace with the release version and date, update a "latest deployment" page with the current version, and add a link to the deployment from the project's main page. The entire Process is automated — no human intervention needed.

Learning Path

flowchart LR
  A[CLI Tools] --> B[API]
  B --> C[Backup]
  C --> D[Upgrading]
  D --> E[Migration]
  E --> F[Performance]

XML-RPC API

DokuWiki provides an XML-RPC API for remote operations. The API endpoint is:

http://yourserver/wiki/lib/exe/xmlrpc.php

Authentication

API calls require authentication. Use a username and password with sufficient permissions.

Available Methods

Method Description
wiki.getPage Get page content
wiki.putPage Create or update a page
wiki.listPages List pages in a namespace
wiki.getPageInfo Get page metadata
wiki.getPageVersion Get a specific revision
wiki.getRecentChanges Get recent changes
wiki.getAttachments List files in media namespace
wiki.putAttachment Upload a file
wiki.getRPCVersion Get API version

Python Example

#!/usr/bin/env python3
# api-example.py - Interact with DokuWiki API

import xmlrpc.client

# Connection
url = "https://yourserver/wiki/lib/exe/xmlrpc.php"
username = "apiuser"
password = "apipassword"

server = xmlrpc.client.ServerProxy(url)

# Authenticate
try:
    # List all pages in a namespace
    pages = server.wiki.listPages(username, password)
    for page in pages:
        print(f"{page['id']} - {page['title']} - {page['lastModified']}")

    # Get page content
    content = server.wiki.getPage(username, password, "start")
    print(f"\nStart page content:\n{content}")

    # Create/update a page
    new_content = "====== API Test ======\n\nThis page was created via the API."
    result = server.wiki.putPage(
        username, password,
        "api-test",
        new_content,
        {"sum": "Created via API"}
    )
    print(f"\nPage created: {result}")

except xmlrpc.client.Fault as err:
    print(f"Error: {err.faultString}")

except xmlrpc.client.ProtocolError as err:
    print(f"Protocol error: {err.errmsg}")

PHP Example

<?php
// api-example.php

$url = 'https://yourserver/wiki/lib/exe/xmlrpc.php';
$username = 'apiuser';
$password = 'apipassword';

$request = xmlrpc_encode_request('wiki.getPage', array($username, $password, 'start'));

$context = stream_context_create(array(
    'http' => array(
        'method' => 'POST',
        'header' => 'Content-Type: text/xml',
        'content' => $request,
    ),
));

$response = file_get_contents($url, false, $context);
$result = xmlrpc_decode($response);

echo "Start page content:\n" . $result . "\n";

Curl Example

# Get page content via XML-RPC
curl -X POST https://yourserver/wiki/lib/exe/xmlrpc.php \
  -H "Content-Type: text/xml" \
  -d '<?xml version="1.0"?>
  <methodCall>
    <methodName>wiki.getPage</methodName>
    <params>
      <param><value><string>apiuser</string></value></param>
      <param><value><string>apipassword</string></value></param>
      <param><value><string>start</string></value></param>
    </params>
  </methodCall>'

JSON API

DokuWiki does not have a native JSON API, but plugins can provide one.

Installing the JSON API Plugin

cd /var/www/html/wiki/lib/plugins/
wget https://github.com/username/dokuwiki-plugin-jsonapi/archive/master.zip
unzip master.zip
mv dokuwiki-plugin-jsonapi-master jsonapi

Using the JSON API

# Get page content as JSON
curl "https://yourserver/wiki/lib/exe/json.php?page=start"

# Create page via JSON
curl -X POST "https://yourserver/wiki/lib/exe/json.php" \
  -H "Content-Type: application/json" \
  -d '{"method": "putPage", "params": ["apiuser","apipassword","api-test","Page content","API test"]}'

Webhooks

Webhooks allow external services to react to wiki events.

Plugin-Based Webhooks

The Webhook plugin sends HTTP requests when pages are saved:

cd /var/www/html/wiki/lib/plugins/
wget https://github.com/username/dokuwiki-plugin-webhook/archive/master.zip
unzip master.zip
mv dokuwiki-plugin-webhook-master webhook

Configuration:

<?php
// conf/local.php
$conf['plugin']['webhook']['url'] = 'https://hooks.slack.com/services/...';
$conf['plugin']['webhook']['events'] = 'page_save,page_delete,user_register';
$conf['plugin']['webhook']['timeout'] = 5;

Custom Webhook via Action Plugin

<?php
class action_plugin_webhook extends DokuWiki_Action_Plugin {

    public function register(Doku_Event_Handler $controller) {
        $controller->register_hook(
            'COMMON_WIKIPAGE_SAVE',
            'AFTER',
            $this,
            'send_webhook'
        );
    }

    public function send_webhook($event, $param) {
        $data = $event->data;
        $payload = json_encode(array(
            'event' => 'page_save',
            'page' => $data['id'],
            'editor' => $data['editor'],
            'timestamp' => time(),
        ));

        $webhookUrl = $this->getConf('url');
        if ($webhookUrl) {
            $http = new DokuHTTPClient();
            $http->post($webhookUrl, $payload);
        }
    }
}

Integration Patterns

CI/CD Integration

Automatically update deployment documentation:

#!/usr/bin/env python3
# ci-cd-integration.py

import xmlrpc.client
import os

version = os.environ.get('CI_COMMIT_TAG', 'unknown')
project = os.environ.get('CI_PROJECT_NAME', 'unknown')

server = xmlrpc.client.ServerProxy('https://wiki.example.com/lib/exe/xmlrpc.php')

# Create deployment page
content = f"""====== Deployment: {project} v{version} ======

**Date:** $(date)
**Version:** {version}
**Deployed by:** CI/CD Pipeline

=== Changes ===

See changelog for details.

=== Verification ===

- [ ] Smoke tests passed
- [ ] Health check passed
"""

server.wiki.putPage('apiuser', 'apipassword',
    f'deployments:{project}-{version}',
    content,
    {'sum': f'Automated deployment documentation for {project} v{version}'}
)

print(f"Deployment page created: deployments:{project}-{version}")

Chat Integration (Slack, Mattermost)

Send notifications to chat when pages change:

<?php
function notify_slack($message) {
    $webhookUrl = 'https://hooks.slack.com/services/...';
    $payload = json_encode(array('text' => $message));

    $ch = curl_init($webhookUrl);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    curl_exec($ch);
    curl_close($ch);
}

Monitoring Integration

Integrate with monitoring systems to update status pages:

def update_status_page(service, status, details):
    server = xmlrpc.client.ServerProxy(API_URL)
    content = f"# {service}: {status}\n\n{details}"
    server.wiki.putPage(USER, PASS, f"status:{service}", content, {})

Securing API Access

Use Dedicated API Users

Create a separate user account with limited permissions for API access.

Restrict API Access

Block API access from external networks using .htaccess:

# conf/xmlrpc.htaccess
Order Deny,Allow
Deny from all
Allow from 192.168.0.0/16
Allow from 10.0.0.0/8

Rate Limiting

Prevent API abuse:

# Limit API requests
location /lib/exe/xmlrpc.php {
    limit_req zone=api burst=5 nodelay;
}

Common Mistakes

  1. Using an admin account for API calls: Create a dedicated API user with minimal required permissions. Do not use an admin account.
  2. Not handling API errors: Network issues, authentication failures, and invalid method calls all return errors. Always handle them.
  3. Hard-coding credentials in scripts: Use environment variables or a config file for API credentials. Never commit them to version control.
  4. Making API calls synchronously in web applications: API calls from a web app block the request. Use async calls or queue systems for production integrations.
  5. Not testing API calls on a staging environment: Always test API integrations on a staging wiki before using production.

Practice Questions

  1. What is the DokuWiki XML-RPC API endpoint URL, and what authentication is required for API calls?
  2. How would you create a new wiki page programmatically using the XML-RPC API?
  3. What are three common integration patterns for the DokuWiki API?
  4. Challenge: Build a complete integration script that: reads a list of pages from an external source (e.g., a JSON file or database), creates or updates each page in the wiki using the XML-RPC API, adds a timestamp and attribution footer to each page, logs each operation (create, update, skip) to a log file, and sends a summary report via email or webhook. The script should handle errors gracefully and retry failed operations. Test the script with at least 5 pages.

FAQ

Can I use the API without authentication?

No. All API methods require authentication. You must provide a valid username and password with each request. This prevents unauthorized access to your wiki content.

Is the XML-RPC API available by default?

Yes. The XML-RPC endpoint at lib/exe/xmlrpc.php is available in every standard DokuWiki installation. No plugin is required for the core API methods.

What is the maximum page size I can create via API?

The same limits apply as web editing. PHP's memory limit and execution time constrain large operations. For very large pages, consider creating them via the filesystem.

Can I upload files via the API?

Yes. The wiki.putAttachment method uploads files. Provide the file content as base64-encoded data with the filename and optional overwrite parameter.

How do I find all available API methods?

Call the wiki.getRPCVersion method to verify connectivity. For a full list of methods, check the DokuWiki API documentation or the lib/exe/xmlrpc.php source file.

Mini Project

Goal: Build an automation script using the DokuWiki API.

  1. Enable the XML-RPC API (it is enabled by default)
  2. Create a dedicated API user account with limited permissions
  3. Write a script (Python or PHP) that:
    • Lists all pages in a namespace
    • Gets the content of a specific page
    • Creates a new page with a title and content
    • Updates an existing page
    • Uploads a small file to the media manager
  4. Handle errors (wrong credentials, non-existent page, permission denied)
  5. Test all operations on a staging wiki
  6. Document the script and its usage

What's Next

The API connects DokuWiki to other systems. Now learn about backup and restore strategies to protect your wiki data.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro