The CKAN client Python package.
Project description
The CKAN client software may be used to make requests on the Comprehensive
Knowledge Archive Network (CKAN) API including its REST interface to all
primary objects (packages, groups, tags) and its search interface.
Synopsis
========
The simplest way to make CKAN requests is:
import ckanclient
# Instantiate the CKAN client.
ckan = ckanclient.CkanClient(api_key=my_key)
# 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.
ckan.package_register_post(package_entity)
# Get the details of a package.
ckan.package_entity_get(package_name)
package_entity = ckan.last_message
print package_entity
# Update the details of a package.
ckan.package_entity_get(package_name)
package_entity = ckan.last_message
package_entity['url'] = new_package_url
package_entity['notes'] = new_package_notes
ckan.package_entity_put(package_entity)
# 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,
}
ckan.group_register_post(group_entity)
# 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
ckan.group_entity_put(group_entity)
Changelog
=========
v0.5 2010-12-15
---------------
* Exception raised on error (more Pythonic)
v0.4 2010-10-07
---------------
* Form API added
* Package name editing
* Groups added
* Output can be verbose and use logger
* Query API version
* Sends API key via additional header
v0.3 2010-04-28
---------------
* General usability improvements especially around error messages.
* Package Relationships added
* Package deletion fixed
* Changeset entities added
* Improved httpauth (thanks to will waites)
v0.2 2009-11-05
---------------
* Search API support added
* Improved package support to include additional fields such as 'extras'
* Support tag and group entities in addition to package
* Compatibility changes: CkanClient base_location (now should point to base
api e.g. http://ckan.net/api rather than http://ckan.net/api/rest)
v0.1 2008-04
------------
* Fully functional implementation for REST interface to packages
Knowledge Archive Network (CKAN) API including its REST interface to all
primary objects (packages, groups, tags) and its search interface.
Synopsis
========
The simplest way to make CKAN requests is:
import ckanclient
# Instantiate the CKAN client.
ckan = ckanclient.CkanClient(api_key=my_key)
# 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.
ckan.package_register_post(package_entity)
# Get the details of a package.
ckan.package_entity_get(package_name)
package_entity = ckan.last_message
print package_entity
# Update the details of a package.
ckan.package_entity_get(package_name)
package_entity = ckan.last_message
package_entity['url'] = new_package_url
package_entity['notes'] = new_package_notes
ckan.package_entity_put(package_entity)
# 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,
}
ckan.group_register_post(group_entity)
# 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
ckan.group_entity_put(group_entity)
Changelog
=========
v0.5 2010-12-15
---------------
* Exception raised on error (more Pythonic)
v0.4 2010-10-07
---------------
* Form API added
* Package name editing
* Groups added
* Output can be verbose and use logger
* Query API version
* Sends API key via additional header
v0.3 2010-04-28
---------------
* General usability improvements especially around error messages.
* Package Relationships added
* Package deletion fixed
* Changeset entities added
* Improved httpauth (thanks to will waites)
v0.2 2009-11-05
---------------
* Search API support added
* Improved package support to include additional fields such as 'extras'
* Support tag and group entities in addition to package
* Compatibility changes: CkanClient base_location (now should point to base
api e.g. http://ckan.net/api rather than http://ckan.net/api/rest)
v0.1 2008-04
------------
* Fully functional implementation for REST interface to packages
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ckanclient-0.7.tar.gz
(12.5 kB
view details)
File details
Details for the file ckanclient-0.7.tar.gz
.
File metadata
- Download URL: ckanclient-0.7.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14c7c287c0d4196a0a4a129ae7477f8b12c9178f545c6b528a64095f32ddd837 |
|
MD5 | 6b35775740982e1083376c61187180b0 |
|
BLAKE2b-256 | 2240794593a9e3219c3d26e9704c97f5175542d032787fa8cd746f3fd80c3c4c |