Skip to content

A wrapper for the REST, XML-RPC and Django ORM interfaces to the ActionKit CRM

License

Notifications You must be signed in to change notification settings

neworganizing/python-actionkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

To initialize a connection using the login/password:

from actionkit import ActionKit
ak = ActionKit(instance='act.yourdomain.com', username='yourusername', password='abcd123')

To use the API key authentication use:

from actionkit import ActionKit
ak = ActionKit(instance='act.yourdomain.com', username='yourusername', api_key='abcd123123123')

To use guest access, use:

from actionkit import ActionKit
ak = ActionKit(instance='act.yourdomain.com')

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:

from actionkit import ActionKitXML
akxml = ActionKitXML(instance='act.yourdomain.com', username='yourusername', password='abcd123')

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.py DATABASES dictionary, then request the CoreUser object using the id:

from actionkit.models import CoreUser
user1 = CoreUser.objects.using('actionkit').get(id=1)

All available models and their fields can be found in the models.py file contained in the python-actionkit repository

Authors & License

This plugin was built in-house by the team at the New Organizing Institute led by Nick Catalano and is released under an open source Apache 2.0 license.

Models are based off the scheme extracted from the ActionKit database, developed by We Also Walk Dogs

About

A wrapper for the REST, XML-RPC and Django ORM interfaces to the ActionKit CRM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages