README.rst

python-actionkit

python-actionkit is a python wrapper/sdk allowing easy access to the REST, XMLRPC and SQL interfaces to the ActionKit CRM.

REST Interface

ActionKit provides a REST Interface based on Tastypie. It allows connectivity as an authenticated user both using username/password authentication as well as username/api-key authentication. It also allows a limited number of actions to be taken as guest users.

python-actionkit interacts with the REST interface viw the requests library

Accessing individual resources is easy. If you wanted a dictionary of the JSON response ActionKit returns when you request the user with the ID of 1, you'd use:

user1 = ak.user.get(1)

To update that record (using a PUT request), simply pass in the ID as an argument and then the updated record:

result = ak.user.update(1, {'first_name': 'Joe'})

To delete that record (using a DELETE request), use:

result = ak.user.delete(1)

ActionKit's REST interface also allows raw SQL access. To get the first record from the core_user table simply call the sql method:

sql_result = ak.sql("SELECT * FROM core_user LIMIT 1")

XML-RPC

ActionKit also has an XML-RPC API interface. Usually this is invoked by using the xmlrpc library, but python-actionkit provides a simple shortcut to get an xmlrpc ServerProxy object that is connected to ActionKit

To create a new ServerProxy to ActionKit, simply create a new ActionKitXML object:

Then to pull a dictionary containing the details from User #1 simply use the command:

user1 = akxml.User.get({'id': 1})

Django ORM

ActionKit is based on Django 1.1 and conveniently provides clients direct SQL access to a MySQL Slave. Taking advantage of these two things allows access to client data with minimal latency as well as considerable development speed advantages.

To pull a CoreUser object representing the user if the ID 1, first ensure that your actionkit database details are defined in your settings.pyDATABASES dictionary, then request the CoreUser object using the id: