DEPRECATED - please see [Python client library for CKAN]
Latest commit 7ac3b9e Mar 1, 2014 @rufuspollock rufuspollock Merge pull request #38 from reederz/master
fix spelling in docstring



ckanclient is a Python library and command-line client to read and write to a CKAN instance via the API. It supports the CKAN API, the CKAN FileStore's Storage API, and the CKAN DataStore's Data API.


Using pip:

pip install ckanclient

You can also download releases of ckanclient directly from PyPI:

or you can get the latest development version from git:

git clone



You can either pass your API key explicitly when creating the CkanClient instance:

client = CkanClient(api_key='my-api-key')

Or you can put your API key in your ~/.ckanclientrc file:

api_key = {your-api-key}

For example:

api_key = adfakjfafdkjda

api_key = tester

Python Library

Catalog API

ckanclient can be used to make requests to the CKAN API, including the API's REST interface to all primary objects (datasets, groups, tags) and its search interface.

The simplest way to make CKAN API requests is:

import ckanclient

# Instantiate the CKAN client.
ckan = ckanclient.CkanClient(base_location='',
# (use your own api_key from )

# Get the package list.
package_list = ckan.package_register_get()
print package_list

# Get the tag list.
tag_list = ckan.tag_register_get()
print tag_list

# Collect the package metadata.
package_entity = {
    'name': my_package_name,
    'url': my_package_url,
    'download_url': my_package_download_url,
    'tags': my_package_keywords,
    'notes': my_package_long_description,

# Register the package.

# Get the details of a package.
package_entity = ckan.last_message
print package_entity

# Update the details of a package.
package_entity = ckan.last_message
package_entity['url'] = new_package_url
package_entity['notes'] = new_package_notes

# List groups
group_list = ckan.group_register_get()
print group_list

# Create a new group
group_entity = {
    'name': my_group_name,
    'title': my_group_title,
    'description': my_group_description,
    'packages': group_package_names,

# Get the details of a group.
print ckan.group_entity_get(group_name)

# Update the group details
group_entity = ckan.last_message
group_entity['title'] = new_group_title
group_entity['packages'] = new_group_packages

FileStore and Storage API

You can use ckanclient to upload files to CKAN's FileStore via the Storage API, example:

import ckanclient
ckan = ckanclient.CkanClient(base_location='',
ckan.add_package_resource('my_dataset', 'my_data_file.csv',
            resource_type='data', description='...')
ckan.add_package_resource('my_dataset', '',
            name='Foo', resource_type='metadata', format='csv')

DataStore and Data API

To be updated - read the source for the present!

Command Line Interface

Install ckanclient will create a command line client named (unsurprisingly!) ckanclient. To see usage do:

ckanclient -h


ckanclient package_entity_get ckan

You can specify the ckan site you wish to use using the --ckan option:

ckanclient --ckan= package_entity_get ckan

NB: the command line is currently under development.


The ckanclient tests require the ckan and nose modules to be installed. Optionally ckanext-dgu can be installed too and the form api will be tested.

To run the tests:

nosetests --ckan ckanclient/tests