Writing a CKAN extension

A CKAN extension adds behavior a portal cannot get from settings or templates, such as API actions, access checks and template helpers. This page covers the plugin decisions, build sequence, effort drivers, compatibility with the two supported CKAN releases, and what to hand over.

On this page

Writing a CKAN extension when templates and settings are not enough

A CKAN extension is the right tool when your portal needs behavior that configuration, a theme or an existing official extension cannot provide, such as a custom API action, an access rule or a template helper. Build one only after you have confirmed that the gap is real. An extension is a Python package that CKAN loads through its plugin configuration, so the work lives in your code, your tests and your upgrade path. Teams usually reach this point when a dataset needs a validation rule the standard forms cannot express, when an integration must call a custom action through the API, or when a template needs a helper that core does not provide. Before you write code, check three things: whether a setting in ckan.ini already covers the need, whether a template override can achieve the result, and whether an existing extension already does the job.

Use the cheapest option that meets the requirement. A theme change suits layout, branding and template text, and the section on building a custom CKAN theme covers that path. An existing extension suits a need that many portals share, such as SAML2 single sign-on through ckanext-saml2auth or DCAT metadata through ckanext-dcat. Check each candidate's supported CKAN versions before you commit, because ckanext-dcat lists CKAN 2.10 and 2.11 as supported, and your target release may fall outside that list. A custom extension is the right choice when the rule is specific to your organization, such as an access check tied to your internal roles, and no maintained extension covers it. Write down the requirement, the closest candidate and the specific reason it falls short. That record becomes the scope you review with your team and any partner you hire.

Settle licensing and code ownership before the first line of code. CKAN is licensed under the GNU Affero General Public License v3.0, and the ckan/ckan repository is the place to read the project's license terms directly. Ask your legal team how AGPL-3.0 applies to an extension that runs inside CKAN, to any change you make to CKAN core, and to what you publish or let users reach over a network. Decide who owns the code, whether it will be released as open source, who may accept outside contributions and where the repository will live. These answers shape how you package the extension, whether other portals can reuse it and who maintains it when CKAN releases change. Record them in writing, because a dispute over ownership raised after launch is much harder to resolve than a decision made during planning.

What a CKAN extension can change

A CKAN extension changes a portal through a small set of plugin hooks, and each hook affects a different audience. Developers write the code, administrators set the options, and portal users see the results on pages and in the API. The cards below cover the parts most extensions touch and the checks to make before relying on each one.

Scaffolding the package

A CKAN extension is a Python package whose entry points tell CKAN which plugin classes to load. Scaffolding sets the package name, the plugin class and the entry point name in the packaging file, so the portal can find the plugin after installation. Portal users see nothing at this stage, but administrators need the entry point name because they add it to the plugins list in the configuration file. Confirm the scaffolding steps and entry point group against the extension documentation for the CKAN release in use.

Implementing plugin interfaces

A plugin class opts into behavior by implementing CKAN interfaces, such as those for configuration, actions, auth functions and template helpers. Each interface is a contract: the class provides the methods CKAN calls, and CKAN calls them at the right point in startup or in a request. Developers should choose the smallest set of interfaces that does the job, because every interface added is another surface to test on each upgrade. Confirm interface names and method signatures against the extension documentation for the CKAN release in use.

Adding actions for web and API

An action is a Python function that performs one operation, such as creating a record or returning a list, and CKAN can expose it to both the web interface and the action API. Registering actions through the actions interface lets one function serve the browser, scripts and integrations, so the logic lives in one place. Treat each action as a public endpoint: validate input with schemas, keep the function thin, and write tests for it. Confirm how actions are registered and named for the CKAN release in use.

Auth functions set access

Each action needs a matching auth function that decides whether the current user may run it, based on the user, the organization and the object involved. Portal users see the outcome as a permission error or a missing button, and administrators see it in the roles they assign. Give every action an explicit auth function, because CKAN's default check may be stricter than expected, and an overly permissive check can expose data. Test each function with anonymous, member, editor and sysadmin accounts, and confirm default behavior for the release in use.

Template helpers for Jinja pages

Template helpers are Python functions that the extension registers so Jinja templates can call them, for example to format a date, look up a label or render a status badge. Portal users see the results on dataset, organization and theme pages, and theme developers call the helpers from template files. Keep helpers read-only, because a helper that writes data can run on every page view, and check how output is escaped so user-supplied text cannot inject markup. Confirm the registration method and template context names for the release in use.

Declaring configuration options

An extension can declare its own settings, such as a service URL, a feature switch or a default language, so administrators can change behavior without editing code. Values are read from the portal's configuration file, which makes them part of the operational record that whoever maintains the deployment must keep. Developers should declare each option with a type and a default, document what it does, and keep secrets out of plain configuration. Confirm how the release in use declares and validates options before the extension ships.

Which extension pattern fits each requirement

This table compares the five decisions that shape a CKAN extension: theme or code, action or endpoint, override or permissions extension, reuse or build, and one package or several. Read each row for when the option fits, what it adds to upgrade and maintenance work, and the question to settle before any code is written. The main takeaway is that the smallest change that meets the requirement is usually the least costly to keep working across CKAN releases.

ChoiceWhen it fitsUpgrade and maintenance costQuestion to answer before building
Theme-only change or custom extensionTheme-only fits template and CSS changes. A custom extension fits new actions, auth rules, helpers or config logic.Template overrides break when core templates change. Extensions need code review and tests at each CKAN upgrade.Does the change only alter how pages look, or does it touch data, permissions or API behavior?
Action or custom API endpointActions fit logic that should be callable through the standard Action API with existing tokens. A custom endpoint fits routes or response formats the Action API cannot provide.Actions stay within the core API contract. Custom endpoints add URL and response handling that you must retest on each upgrade.Will other systems call this as a documented API, and who owns its response format?
Auth function override or separate permissions extensionOverride auth functions when a few access rules change. A separate permissions extension fits many rules or a policy owned by another team.Overrides must track changes to core auth function signatures. A separate extension is another codebase to test and patch.Which access rules change, and does another team need to own them without editing the main extension?
Reuse ckanext-dcat or ckanext-saml2auth, or write new codeReuse when an existing extension covers the need, such as DCAT RDF endpoints or SAML2 sign-in. Write new code only for gaps no extension meets.Reused extensions follow their own release cycle. You still own their configuration and any patches you carry.Does the extension list our CKAN release? ckanext-dcat lists support for CKAN 2.10 and 2.11, so confirm 2.12 before adopting.
One extension or several small extensionsOne extension fits one feature set with one owner and one release cycle. Several small extensions fit separate owners or features that can be enabled independently.Each extension has its own version, dependencies and tests. Fewer packages simplify upgrades, but one change can affect every feature.Do the features have different owners or release timing, and do they need to be switched on separately?

Every request into extension code crosses one trust boundary

A request starts in a browser or API client, enters CKAN core, and reaches the extension through the plugin hooks it registers. The hook lookup marks the trust boundary: beyond it, the extension's action or auth function runs, and template helpers are called from page templates. Those functions read and write PostgreSQL, query the Solr index or read the DataStore. The lower path shows the build: local tests, continuous integration against both supported CKAN releases, then deployment inside the client's infrastructure. Check that every action and auth function enforces its own permissions.

Request path into extension code, with the build path shown separately.

Writing a CKAN extension in six steps, with the output of each

The six steps take an extension from an agreed requirements list to a tested package that runs on both supported CKAN releases and is ready for your team to deploy and maintain. Each step ends with a named output, so you can check progress before the next step starts.

  1. Agree requirements, licensing and target releases

    Your product owner and the DeployOpen lead agree what the extension must do, which datasets, schemas, pages or APIs it touches, and which two minor CKAN releases it must support. CKAN itself is licensed under the GNU Affero General Public License v3.0, so your legal team should confirm the license for the extension before any code is written. Check the release policy for which minor releases are currently supported. The step is done when you have a signed-off requirements list with in-scope and out-of-scope items, a license decision and a named list of target releases.

  2. Scaffold the package and a development instance

    Create the extension package with the scaffolding command documented for the chosen release, then set up the repository layout: plugin entry point, packaging metadata, a tests folder and a README. Build a development CKAN instance for each target release, using the Python, PostgreSQL, Solr and Redis versions that the install documentation lists for that release. Confirm the scaffolding command and the development instance steps in the documentation for the chosen release. The step is done when the repository installs into the development instance, loads its plugin and starts with no errors in the log.

  3. Implement plugin interfaces, actions and auth functions

    Choose the plugin interfaces the requirements need, then add the action functions, auth functions and template helpers that deliver them. Every action gets a matching auth function, so access is decided in code and not only in the templates. DeployOpen engineers write the code, and your technical lead reviews each permission decision as it is made. The step is done when the plugin code has a short list of interfaces used, a mapping from each requirement to an action and an auth function, and a manual walk through the API and web interface as an anonymous user, a member and a sysadmin matches the requirements list.

  4. Write tests against a CKAN test setup

    Write tests with the test tooling and fixtures documented for each target release, so they exercise CKAN's own code paths. Cover each action with valid and invalid input, each auth function for anonymous, member, editor and sysadmin users, and any schema or template behavior the requirements name. Confirm the test database, Solr settings and fixture setup in the release documentation. The step is done when the suite runs from a clean environment with one documented command, passes on two consecutive clean runs, and every requirement on the list maps to at least one test.

  5. Run the extension on both supported releases

    Run the full test suite and the manual checks against each target CKAN release, including the older supported minor version. Expect differences such as deprecated imports, changed interfaces and renamed template blocks, and record each one with the fix applied. Patch releases avoid backwards-incompatible changes, but minor releases may include them, so this check is where those breaks will surface. The step is done when you have a compatibility note for each release and both releases pass the suite and the manual checks with no open items.

  6. Package, deploy and hand over

    Build the distributable package from a tagged version, then write a deployment runbook covering installation, configuration keys, enabling the plugin in the CKAN configuration file, restart, smoke tests and rollback. Hand over the repository, tests, runbook, license decision and a list of known open items to your platform team. Ask your team which deployment tooling they use so the runbook matches it. The step is done when your team installs the package in a non-production environment by following the runbook alone, and the handover record is signed off.

What makes a CKAN extension take longer than expected

This table lists the drivers that most often push a CKAN extension past its first estimate, with the reason each one adds effort and how to keep it down. Read each row before you write the feature list, because the same feature can be small on one driver and large on another. The main takeaway is that scope, release targets and test expectations should be fixed in writing before the build starts.

DriverWhy it adds effortHow to keep it downWhat to request in a quote
Interfaces and actions touchedEach plugin interface, action, auth function and template helper adds code, tests and upgrade surface.Narrow the feature list to the interfaces you need. Reuse existing core actions before writing new ones.A named list of plugin interfaces, actions, auth functions and helpers, with a count of each.
Schema or stored data changesChanges to dataset, organization or group schemas, or to DataStore tables, need validation and migration logic.Limit schema changes to fields the portal already needs. Confirm loader choices with XLoader before writing custom loaders.Schema fields, validators, migration steps and the data volume each step touches.
Authorization depthCustom auth functions for private datasets, roles or organization rules multiply test cases and review time.Map each permission to an existing CKAN role before adding new authorization logic.A written role matrix showing which users may read, create, edit and delete each object type.
CKAN releases supportedEach supported release needs its own test run, and minor releases may include backwards-incompatible changes.Prove one release first, then add the second. Confirm which minor and patch versions your portal will run.The named CKAN releases and patch levels, plus the test evidence for each one.
Test coverage expectedYour change process may require unit, functional and browser tests, each adding build and review work.Agree test types and coverage targets up front, and test the riskiest actions first.Required test types, the coverage target, CI pipeline requirements and who signs off the results.
Dependencies on other extensionsEach dependency adds its own release cycle, configuration and version pinning to your compatibility work.Reuse official extensions, such as ckanext-dcat or ckanext-pages, where they already meet the need.A full list of extension versions to be pinned, and the CKAN releases each one supports.
SSO and external systemsIdentity providers, APIs and data feeds outside CKAN need configuration, failure handling and test environments.Start with the identity provider you already run. Check whether ckanext-saml2auth covers your attribute mapping before coding.Test environment access, attribute mapping rules, sample data and who owns the external system.

How CKAN loads an extension and why that shapes upgrades

CKAN activates an extension only when its plugin name appears in the ckan.plugins setting in the site configuration, and it loads those plugins in the order listed. That order matters: when two extensions override the same template or asset, the one loaded later can win, so reordering the line changes what visitors see without any code change. Overlapping template and asset overrides are therefore a common source of defects. A portal can look correct in one environment and broken in another if the ckan.plugins line differs between them. Before each release, compare that line across environments, confirm the order matches what you tested, and keep a written list of every template and asset your extension overrides so collisions with other extensions can be checked.

CKAN's release policy separates two kinds of update. Patch releases do not break backwards compatibility and leave out schema changes and new features, so a patch should not require code changes in your extension, though a test run is still the way to confirm it. Minor releases may include backwards-incompatible changes, so an extension that passes on one minor release can fail on the next. CKAN targets about two minor releases a year and supports the latest patch of the current minor version and the previous minor version. Your maintenance plan should therefore name both supported minor releases and run the extension's test suite against each of them, with the results recorded before any portal moves.

Patch discipline shapes the upgrade order as well. Outdated patch releases lose support once a newer patch is out, so a portal that stays on an old patch of a supported minor version is running code the project no longer fixes. For the extension, the practical sequence is to test against the target minor release in a separate environment, read its release notes for changes to the interfaces your extension implements, fix and retest, and only then move the production portal. Ask the developers who own the extension to list those interfaces now, because that list tells the upgrade team which release notes matter.

Build in house or bring in a partner for a CKAN extension

Building in house keeps the code, release timing and knowledge inside your team, but the work needs more than general web development. The extension sits between Python packaging, CKAN's plugin interfaces and your portal's data model, so the team must be able to read CKAN core code as well as its own templates. The four points below are what your team has to supply.

  • Python and CKAN skills: Plan for at least one engineer comfortable with Python packaging, pytest and CKAN plugin interfaces, and one who has already worked through a CKAN upgrade. Confirm the Python version your target release needs in its release notes before writing code.
  • A staging portal and repository: Keep a staging CKAN that matches production in release, extensions, Solr and PostgreSQL versions. Host the source in a repository your team controls, with continuous integration running the tests on every pull request. Without a matching staging portal, search index and schema problems appear first in production.
  • A named owner for each minor upgrade: Assign one named person to each minor release and record the name in the repository. That owner reads the release policy, checks the extension against any backwards-incompatible changes and signs off the upgrade.
  • Reviewers and deliverables: Name reviewers who understand CKAN's authorization model, because permission bugs often pass unit tests. Your team also writes the source, tests, runbook and upgrade notes, so schedule that documentation as part of the code, not after it.

Before the first sprint, confirm that the team can name the upgrade owner for the next minor release and that a matching staging portal already exists.

How a custom extension connects to other CKAN parts

A CKAN extension rarely works alone. It shares the database, search index, plugin list, templates and deployment path with CKAN core and with other extensions, so each connection below is a point where one change can break a portal that already works. Check all six before the first line of code is written.

DataStore and XLoader

The DataStore keeps rows from tabular resources in a separate PostgreSQL database, with one write user and one read-only user, and the Data API queries it. XLoader is the officially supported loader for filling it, and DataPusher is legacy. If your extension reads, writes or reshapes DataStore tables, confirm which loader the portal runs, which database user your code connects with, and whether your actions go through the Data API or query tables directly.

DataStore docs

DCAT metadata and harvesting

ckanext-dcat maps CKAN datasets to DCAT-AP v1, v2 and v3 schemas, serves DCAT RDF endpoints and includes an RDF harvester for importing from other catalogs. A field your extension adds or renames changes what the mapping emits, so the schema and RDF output must match. Confirm which DCAT-AP profile your portal publishes, and whether the ckanext-dcat release you pin supports your CKAN version, since its documented support covers CKAN 2.10 and 2.11.

ckanext-dcat repository

SAML2 identity and roles

ckanext-saml2auth adds SAML2 single sign-on to CKAN 2.10 and later. It can assign users to organizations and roles from SAML2 attributes and manage sysadmins from an email list. An extension that creates accounts, changes roles or exposes new actions can bypass those role rules if it does not check them. Confirm which attributes your identity provider sends, that your code reads roles from CKAN's own user and organization records, and that a user without the right SAML2 role is refused by each new action.

ckanext-saml2auth repository

Themes, templates and plugin order

A theme extension overrides the templates, blocks and static assets that your extension may also touch. CKAN loads plugins in the order listed in ckan.plugins, and the plugin listed later generally takes precedence when two of them override the same template. Confirm whether your extension can share a plugin list with the theme or needs its own, where it sits in the plugin order, and which template blocks and asset bundles each one changes. Check the order in a test portal before release.

PostgreSQL, Solr and Redis

CKAN keeps core data in PostgreSQL, indexes datasets for search in Solr and requires Redis. The source install guide lists PostgreSQL 12 or newer and Solr 9 (recommended) or Solr 8. An extension that adds search fields or new tables changes what those services must hold, so the Solr schema and database migrations belong in the install steps. Confirm which Solr schema your extension needs, whether a reindex is required after install, and who runs the migration on production.

Install from source docs

CI and deployment pipelines

Your pipeline should run the extension's tests against each CKAN minor version your portal may run, with PostgreSQL, Solr and Redis available as they are in production. Patch releases avoid backwards-incompatible and schema changes, while minor releases may include them, so testing one pinned version leaves gaps. Confirm which CKAN versions the pipeline builds against, where the packaged extension is published, who approves a production deploy, and how a rollback restores the previous plugin list.

CKAN release policy

How much does writing a CKAN extension cost and how long does it take?

What drives the cost of writing a CKAN extension?

The cost follows how much of CKAN the extension touches and how many behaviors it adds. A small extension with one action, one template helper and a few tests is a different job from one that changes dataset schemas, adds authorization rules and connects to an identity or catalog system. The cost components are discovery, design, build, testing and handover. Discovery covers requirements, target CKAN versions and the plugins already running on the portal. Testing includes runs against a staging portal with representative data. Some work recurs after go-live: upgrading the extension when CKAN releases a new version, and fixing issues found in production. When you request a quote, ask for each component on its own line, the CKAN versions covered, who writes and reviews the tests, and what is excluded. Writing the extension is a one-time project, while upgrades and fixes are recurring costs.

Can our in-house developers write a CKAN extension without a partner?

Yes, if the team knows Python and has built CKAN plugins before. Writing an extension means scaffolding a package, choosing plugin interfaces, adding actions, auth functions and template helpers, and writing tests that run against a CKAN instance. The usual gap is CKAN internals: how actions and auth checks are wired, how configuration is read, and how the release policy affects code written today. A team building alone should name one reviewer who reads the release notes for each CKAN version the portal targets, and one owner for upgrades after the first release. Check whether two or more developers can maintain the code and whether the operations team will deploy and monitor it. A partner makes more sense when the team lacks plugin experience or capacity, or when the work needs a fixed scope with written acceptance criteria.

How long does it take to build a CKAN extension?

Duration depends on the written scope, so ask for a timeline tied to named deliverables, acceptance tests and review points. The main drivers are the number of plugin interfaces and CKAN features the extension uses, whether it changes data schemas or authorization rules, and how many external systems it must reach, such as an identity provider or another catalog. Testing against both supported CKAN lines adds time, as does the pace of your security or architecture review. Delays often come from inputs outside the code, such as a staging CKAN that arrives late, sample data awaiting approval or access requests waiting on another team. Ask for the critical path, the assumptions behind each milestone and the dependencies your side must clear before work starts.

What do we need to provide for a CKAN extension project?

Four inputs decide whether the build starts on time:

  • A staging CKAN that matches production's CKAN version, installed extensions and web server setup.
  • Sample datasets, organizations and users with production-like metadata, without copying personal data from production.
  • A named owner on your side who can answer design questions and accept each deliverable.
  • Repository, CI and identity access, including the SSO or directory system the extension will use.

List the access requests in the written scope so they start on the first day. Confirm the data handling rules for the staging environment with your privacy team before any sample data is loaded.

How does a CKAN extension stay compatible with CKAN 2.11 and 2.12?

Compatibility comes from declaring the supported CKAN versions, running a test suite against both lines and reviewing each CKAN release before upgrading. CKAN 2.12.0 was released on August 26, 2026, together with maintenance releases 2.11.6 and 2.10.11 on the same day. CKAN's release policy says patch releases do not break backwards compatibility and exclude schema changes and new features, while minor releases may include backwards-incompatible changes. A patch update should therefore be low risk but still tested, and a move between minor versions needs release-note review and a full test run. The policy supports the latest patch of the current minor version and the previous minor version, and outdated patches lose support once a newer patch is out. Confirm which minor version is current when you start, and schedule re-testing after every patch.

Who owns the extension code after delivery, and what does AGPL-3.0 require?

Code ownership is set by the written agreement, so confirm who holds the copyright, who may reuse the code and who maintains it after handover. CKAN itself is licensed under the GNU Affero General Public License v3.0, so an extension that runs inside CKAN should be reviewed under that license before it is distributed. The obligations to check include:

  • Keeping license notices and the license text in the repository.
  • Making the source available to anyone who receives a distributed copy.
  • Offering the corresponding source of a modified version to users who interact with it over a network.

Ask counsel to confirm how your extension is linked and distributed, and whether each bundled dependency has a compatible license. Request a handover package that includes the repository, a dependency and license list, and the named maintainer.

How DeployOpen scopes and hands over CKAN extension work

DeployOpen treats a CKAN extension as code that has to stay compatible through later CKAN upgrades, so scoping starts with the plugin interfaces, actions and helpers your portal needs and the CKAN releases it runs on. Most engagements are fixed-scope, with scope and deliverables agreed in writing before work starts, and ongoing support is available as a retainer.

How we scope

  • We confirm which plugin interfaces, actions, auth functions and template helpers the extension needs before any code is written.
  • We record the two supported CKAN releases the extension must run on, plus your Python and Solr versions.
  • The written scope lists each deliverable, the tests, the documentation and the acceptance checks agreed before work starts.

How we build

  • Each interface, action or helper ships with automated tests before the next one is added.
  • Auth functions are tested for both permitted and denied users, so access rules are checked in the test suite.
  • Template helpers and actions are checked against the two supported CKAN releases before anything is handed over.

How we hand over

  • Handover includes the source repository, the packaged extension, install and configuration notes and the test suite.
  • The documentation covers each action, auth function and template helper, with the configuration keys the extension reads.
  • Your team checks the test results and documentation against the written scope before acceptance.

How we support

  • Ongoing support is available as a retainer, including compatibility checks when new CKAN releases come out.
  • CKAN patch releases do not break backwards compatibility, but minor releases may, so each minor upgrade is re-tested.
  • Documentation and tests stay in the repository, so your own team can run the suite and extend the extension later.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.