Registry / api / ckanapi

ckanapi

JSON →
library4.11pypypi✓ verified 84d ago

A command line interface and Python module for accessing the CKAN Action API. Current version 4.11, requires Python >=3.9. Released on PyPI with maintenance updates as needed.

pip install ckanapi
INSTALL
IMPORT
SIG · CKANAPI
C
ckanapi
apipythonv4.11
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ckanapi
import ckanapi
from ckanapi import ckanapi
ckanapi is the module itself; no submodule named ckanapi.
RemoteCKAN
from ckanapi import RemoteCKAN
from ckanapi.client import RemoteCKAN
RemoteCKAN is a top-level export.
LocalCKAN
from ckanapi import LocalCKAN
import ckanapi.local
LocalCKAN is also a top-level export.

Initialize a connection to a CKAN instance and list datasets. For authenticated actions, set the apikey parameter.

from ckanapi import RemoteCKAN # Replace with your CKAN instance URL and API key ckan = RemoteCKAN('https://demo.ckan.org', apikey='') # List datasets packages = ckan.action.package_list() print(packages[:5])
Debug
Known issues
breakingPython 3.9+ required. Python 2 support was dropped in version 4.0.
fix
Ensure your Python version is 3.9 or higher.
affects: >=4.0
gotchaAPI key is sent as a header; never commit it to version control. Prefer environment variables.
fix
Use os.environ.get('CKAN_API_KEY') instead of hardcoding.
affects: all
gotchaThe Action API call method uses dot notation for actions (e.g., ckan.action.package_list). This is not the same as calling the API endpoint directly.
fix
Use ckan.action.<action_name>(**params).
affects: all
Errors
Common errors & fixes
ckanapi.exceptions.ValidationError: ...
Invalid parameters or missing required fields for a CKAN action.
fix
Check the CKAN API documentation for the correct parameters, or use ckan.action.help_show(name='<action>') to see the required fields.
ModuleNotFoundError: No module named 'ckanapi'
ckanapi is not installed in the current environment.
fix
Run 'pip install ckanapi' in your virtual environment.
AttributeError: module 'ckanapi' has no attribute 'RemoteCKAN'
Importing incorrectly, e.g., 'import ckanapi' then 'ckanapi.RemoteCKAN' is valid but might be confused with other patterns.
fix
Use 'from ckanapi import RemoteCKAN'.
Upgrade
Version history
4.11latest on PyPI · released Mar 20, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
49 hits · last 30 days
node
42
OpenAI (training)
1
Resources
ckanapi — pip install ckanapi · libregistry