Version 38 (modified by athomas, 10 years ago) (diff)

Updated examples

Trac XML-RPC Plugin


This plugin allows Trac plugins to export select parts of their interface via XML-RPC.

It also includes some exported functions for manipulating tickets, with plans to include interfaces to other parts of Trac's API.

The browsable XML-RPC URI suffix is /xmlrpc, however most XML-RPC clients should use the authenticated URL suffix /login/xmlrpc as this is correctly authenticated by Trac.

WikiRPC API is complete, mostly thanks to mgood.

Ticket API is also complete, with the following types exported: component, version, milestone, type, status, resolution, priority and severity.

For example, for TracHacks the URIs are and (must be authenticated).


Outstanding tasks are roadmap, timeline, user management (?), plugin management (?) probably more.


This plugin requires the current trunk of Trac ([T2997] as of this writing). It will not work with Trac 0.9.x or earlier.

Install in the same manner as any other Trac plugin:

# python bdist_egg
# cp dist/*.egg /srv/trac/env/plugins

You will also probably need to enable the plugin in your environments trac.ini:

tracrpc.* = enabled

Bugs/Feature Requests

Existing bugs and feature requests for XmlRpcPlugin are here.

If you have any issues, create a new ticket.


Download the zipped source from [download:xmlrpcplugin here].


You can check out the source for XmlRpcPlugin using Subversion from here or browse the source with Trac.


End-User Usage

Obtain and print a list of XML-RPC exported functions available to my user:

import xmlrpclib

server = xmlrpclib.ServerProxy("http://athomas:password@localhost/trac-dev/login/xmlrpc")
for method in server.system.listMethods():
  print method
  print '\n'.join(['  ' + x for x in server.system.methodHelp(method).split('\n')])

The same example using system.multicall(). This reduces network and server load by compacting all of the system.methodHelp() calls into one HTTP POST.

import xmlrpclib

server = xmlrpclib.ServerProxy("http://athomas:password@localhost/trac/devel/login/xmlrpc")

multicall = xmlrpclib.MultiCall(server)
for method in server.system.listMethods():

for help in multicall():
    lines = help.splitlines()
    print lines[0]
    print '\n'.join(['  ' + x for x in lines[2:]])

List all tickets that are owned by athomas, using the XML-RPC multicall system to issue multiple RPC calls with one HTTP request:

import xmlrpclib

server = xmlrpclib.ServerProxy("http://athomas:password@localhost/trac/devel/login/xmlrpc")

multicall = xmlrpclib.MultiCall(server)
for ticket in server.ticket.query("owner=athomas"):
print map(str, multicall())

Access the Wiki with WikiRPC

import xmlrpclib

server = xmlrpclib.ServerProxy("http://athomas:password@localhost/trac-dev/login/xmlrpc")

# print the content of WikiStart

# print WikiStart as HTML

# write to the SandBox page from a text file
sandbox_content = file("sandbox.txt").read()"SandBox", sandbox_content, {"comments": "testing the WikiRPC interface"})

API Usage

See the source for details.


If the HTTP request to this URI is not XML, the XmlRpcPlugin will list all exported functions that the current user has permission to use.

Change Log

15032 by osimons on 2015-11-04 10:05:15
XmlRpcPlugin: Never try to update ticket 'time' and 'changetime' fields. Closes #12430.
14872 by osimons on 2015-08-12 14:41:00
XmlRpcPlugin: Removed unused macros.html include. Closes #12481.
14747 by osimons on 2015-06-25 22:21:55
XmlRpcPlugin: Bump version. Ref #12285 request.
14744 by osimons on 2015-06-25 11:46:46
XmlRpcPlugin: Formatting of 'owner' in ticket action controllers has changed.
14743 by osimons on 2015-06-25 11:46:44
XmlRpcPlugin: Support Trac 1.1+ database API. Closes #12285.


Author: athomas
Contributors: mgood


Attachments (2)

Download all attachments as: .zip