Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Ckan API client

This package provides a client for the ckan API.

Specifically, it includes:

  • a low-level client, which is pretty much just a wrapper around HTTP calls, handling serialization and exception-raising.

  • a high-level client, attempting to make it easier / safer to perform certain operations on a ckan catalog.

  • a synchronization client, used to provide some automation for synchronization tasks of collections of datasets into a catalog (commonly referred to as “harvesting”).

Other than that, it attempts to get work around some common issues with that API, such as inconsistencies and bugs, trying to make sure problems are discovered earlier.

Documentation

Documentation is available on Read The Docs:

http://ckan-api-client.readthedocs.org

a mirror copy is currently available on GitHub pages:

https://opendatatrentino.github.io/ckan-api-client/

Example usage

>>> from ckan_api_client.high_level import CkanHighlevelClient
>>> from ckan_api_client.objects import CkanDataset

>>> client = CkanHighlevelClient('http://127.0.0.1:5000', api_key='e70c15cc-2f07-4845-8c6e-3607df88e905')

We don’t have datasets yet on our clean instance:

>>> client.list_datasets()
[]

Let’s create a new dataset:

>>> new_dataset = client.create_dataset(CkanDataset({
...     'name': 'example-dataset',
...     'title': 'My example dataset'}))

>>> new_dataset
CkanDataset({'maintainer': u'', 'name': u'example-dataset', 'author': u'', 'author_email': u'', 'title': 'My example dataset', 'notes': u'', 'owner_org': None, 'private': False, 'maintainer_email': u'', 'url': u'', 'state': u'active', 'extras': {}, 'groups': [], 'license_id': u'', 'type': u'dataset', 'id': u'dfe41b34-5114-47be-8d94-759f942938fc', 'resources': []})

>>> client.list_datasets()
[u'dfe41b34-5114-47be-8d94-759f942938fc']

Now, let’s change its title:

>>> new_dataset.title = 'NEW TITLE'

>>> client.update_dataset(new_dataset)
CkanDataset({'maintainer': u'', 'name': u'example-dataset', 'author': u'', 'author_email': u'', 'title': 'NEW TITLE', 'notes': u'', 'owner_org': None, 'private': False, 'maintainer_email': u'', 'url': u'', 'state': u'active', 'extras': {}, 'groups': [], 'license_id': u'', 'type': u'dataset', 'id': u'dfe41b34-5114-47be-8d94-759f942938fc', 'resources': []})

Get it back:

>>> client.get_dataset('dfe41b34-5114-47be-8d94-759f942938fc')
(same result as above)

Delete it:

>>> client.wipe_dataset(new_dataset.id)

Trying to get the dataset again will raise a “simulated” 404: Ckan will never delete datasets, it just marks them as “state: deleted”, for administrative users, and returns a 403 for anonymous ones. We want to provide more consistency so we raise an exception.

If you really want to get the deleted dataset, add allow_deleted=True.

>>> client.get_dataset('dfe41b34-5114-47be-8d94-759f942938fc')
HTTPError: HTTPError(404, '(logical) dataset state is deleted', original=None)

Metadata

Release files for ckan-api-client 0.1-beta4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ckan-api-client 0.1-beta4
File Size Uploaded Provenance
ckan-api-client-0.1-beta4.tar.gz 53.4 kB Without provenance Details

Release files / ckan-api-client-0.1-beta4.tar.gz

Download URL ckan-api-client-0.1-beta4.tar.gz
Size 53.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1e7bc05a6fd9038f734d7c3c8de1bac214167ecfcbe14b2932a4f18803b16b0e
BLAKE2b-256 checksum
How to use checksums
731557900744b96e3051c5854132daedf49158110488ef6a3325dab45feb43be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for ckan-api-client 0.1-beta4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page