API Reference

Introduction
The PyBitmessage API uses XML-RPC.

Enable the API
To enable the API, copy and paste these lines into the bitmessagesettings section of the keys.dat file. Note that the values "username" and "password" below are merely examples, and should be replaced by values that cannot feasibly be guessed: apienabled = true apiport = 8442 apiinterface = 127.0.0.1 apiusername = username apipassword = password Additionally, you may optionally include an additional entry which will specify a program which Bitmessage will run when certain events occur. apinotifypath = c:\\example\\example.exe One of these arguments will be passed to your program: startingUp, newMessage, newBroadcast. Be sure your program doesn't crash when given newer arguments introduced in the future as this list will likely expand.

Remote Access
To access the Bitmessage API from a remote location, change the apiinterface value from 127.0.0.1 to 0.0.0.0.

The following Python code offers a demonstration of how to create a client that can connect to the PyBitmessage API.

In this example, the username is "username", the password is "password", the IP address of the server running PyBitmessage is 105.168.1.0 (a random example), and the port number which PyBitmessage has been configured to listen on is 8442. In order to connect with the remote copy of PyBitmessage, these settings must match those in PyBitmessage's "keys.dat" file. import xmlrpclib import json import time

api = xmlrpclib.ServerProxy("http://username:password@105.168.1.0:8442/") print api.add(2,3)

A more complete example can be found in the api_client.py file in the PyBitmessage source code.

List of Operations
Required arguments are denoted inside Optional arguments are inside [ and ].

Note: If the minimum required version is higher than then the code is available in source but not yet available in a compiled binary.

Possible error values
Here are the various error numbers and descriptions you might see.