Automating CKAN dataset publishing with Apache Airflow through the Action API
A team whose pipelines must create and update CKAN datasets and resources on a schedule can publish through the CKAN Action API with plain HTTP calls from Airflow. The core pattern is a dedicated CKAN API token, issued to a service account, that each task sends in the Authorization header. Every call goes to /api/3/action/<function_name>, usually as a JSON POST, so a task that creates a dataset with package_create or updates one with package_patch is an ordinary HTTP request made from a Python task or an HTTP operator. The optional ckanapi Python client wraps the same Action API, so teams already working in Python can use it without changing what CKAN receives. Confirm function names and parameters in the CKAN API guide for your CKAN version before writing the first task.
File uploads need a different request shape. Files go to resources through the upload parameter of resource_create or resource_patch, sent as a multipart/form-data request, so the upload task cannot reuse the JSON body that the metadata tasks send. Plan the token before the first DAG is written. Confirm which organization roles the service account holds, because a token can only change datasets that its user is allowed to edit, and decide whether private datasets belong in the pipeline's scope. Store the token in your Airflow secrets backend or connection store, keep it out of DAG source files, and name the person who rotates it. Test every function call against a staging CKAN instance that runs the same version and extensions as production before scheduling anything against the live portal.
Two boundaries matter for scope. This page covers the documented HTTP path and does not assume that an Airflow provider for CKAN exists, so check the provider list in your own Airflow installation before adopting any shortcut. AirCan, built on Apache Airflow by Datopian, and XLoader are tools for loading tabular resource data into the CKAN DataStore. They are not the path for publishing dataset and resource metadata, and the CKAN DataStore documentation explains where they fit. Airflow itself is licensed under Apache-2.0, and the version you deploy matters: Airflow 2 reached end of life on April 22, 2026, so new pipelines should target Airflow 3. The version support table currently lists 3.3.2 as the Airflow 3 patch release, so confirm the version you pin against that table on the day you deploy.
Prerequisites for automating CKAN dataset publishing with Apache Airflow
These six checks cover the platform versions, the database and runtime Airflow needs, and the CKAN identity and network path that every scheduled publish depends on. Work through them before any DAG writes to a portal, because a mismatch in version, token scope or TLS trust often appears as failed runs with unclear errors.
CKAN version and support window
Pin the CKAN version your pipelines target before writing any DAG. CKAN 2.12.0 was released on August 26, 2026, alongside maintenance releases 2.11.6 and 2.10.11. The project supports the latest patch of the current minor and the previous minor, so 2.12 and 2.11 are the lines to plan against. Confirm your portal runs a supported patch, because older patches lose support once a newer one ships. Minor releases can contain backwards-incompatible changes, so retest the publishing DAGs after each one.
CKAN release policyAirflow 3 on a current patch
Deploy Airflow 3 and pin the current patch, 3.3.2, for new work. Airflow 3 was first released on April 22, 2025. Airflow 2 reached end of life on April 22, 2026, so it receives no fixes and should not carry new publishing pipelines. Airflow 3 changes several interfaces, so review existing DAGs against the upgrade guide before moving them. Check that the scheduler, API server and workers all run the same patch level.
Airflow version life cyclePostgreSQL as metadata database
Use PostgreSQL 14 to 18 as the Airflow metadata database. SQLite is meant for testing only, because the production guide warns that it can lead to data loss, and MariaDB is not supported as a metadata database. Size the database for run history and XCom growth, and plan backups before the first scheduled run. Confirm with your platform team which PostgreSQL minor version they can patch and back up on their schedule.
Airflow production deploymentPython runtime and memory
Run Airflow on Python 3.10 to 3.14, and confirm that the interpreter in worker images matches the one on scheduler hosts. Allocate at least 4 GB of RAM, the figure Airflow's prerequisites recommend. Pipelines that stage large resource files in worker memory or on local disk need headroom above that figure, so measure a representative run before you set limits.
Airflow prerequisitesCKAN service account and token
Create a dedicated service account in CKAN for the pipeline instead of reusing a person's login. Give it only the organization roles needed to create and update datasets and resources in the organizations it publishes for. Generate an API token for that user and store it in an Airflow connection or secrets backend, keeping it out of DAG code. Requests send the token in the Authorization header to /api/3/action/ functions. Ask the portal owner who approves roles and how tokens are rotated.
CKAN API guideNetwork path and TLS to CKAN
Confirm that every Airflow worker can reach the CKAN site over HTTPS, including through any egress proxy, firewall or private DNS rule. Test from a host or pod that uses the same image as the DAG workers, because scheduler hosts often sit on different networks. Install internal certificate authorities into worker images and keep certificate verification on. Check proxy timeouts and request body size limits, since resource uploads can be large.
How a scheduled DAG reaches CKAN and the DataStore
The run starts in the Airflow scheduler, which hands the DAG run to a worker inside the Airflow network. The worker reads the CKAN API token from the secrets store, then calls the Action API over HTTPS to create or update the dataset and resource. The crossing between the two networks is the trust boundary, so confirm that firewall rules and TLS settings allow only this traffic. CKAN stores the dataset metadata and the uploaded file. The DataStore loader is a separate branch that runs after the resource exists. Confirm how your chosen loader, such as XLoader or AirCan, is triggered before you build the DAG around it.
Scheduled DAG run crosses one trust boundary to reach CKAN and the DataStore.
Setup sequence: from service account to a verified scheduled upload
This sequence takes a CKAN portal from a dedicated publishing account to a scheduled Airflow pipeline that creates or updates datasets, uploads files and loads tables into the DataStore. Each step closes with a check you can run yourself, so a fault surfaces before the schedule is switched on. Confirm the versions and loader choices against your own CKAN release before you start.
Create a dedicated CKAN publishing account
A CKAN sysadmin creates a separate service user for the pipeline and adds it as an editor only in the organizations it will publish for. It should not be a sysadmin. Generate its API token from the user profile and store it nowhere yet. Check the account with an authenticated call to
user_show, which should return the service user, and then attempt a write to an organization where it has no role, which should be refused. Both results confirm the token works and that its reach is limited to the target organizations.Store the token in Airflow secrets
The pipeline team places the token in the secrets backend of your Airflow deployment and refers to it by name from the DAG, so the token does not appear in DAG files or task logs. Keep the CKAN base URL in configuration as well, so the same DAG can point at a test portal before production. Confirm which secrets backends your Airflow version supports, and how it reads them, in the Airflow documentation for your release. Check the setup with a small test task that reads the token, makes one authenticated call to CKAN and succeeds, then search the task log and DAG source for the token value to confirm it is absent.
Deploy Airflow 3 with PostgreSQL and an executor
The platform team deploys Apache Airflow 3 on infrastructure you control, with PostgreSQL as the metadata database. Airflow 3 was first released on April 22, 2025, and the current patch listed in the version life cycle table is 3.3.2. Airflow 2 reached end of life on April 22, 2026, so a new deployment should start on Airflow 3. The 3.3.2 prerequisites list PostgreSQL 14 to 18 and Python 3.10 to 3.14, and SQLite should not be used in production. Choose LocalExecutor for a single host, or CeleryExecutor or KubernetesExecutor when workers must scale out, and confirm the choice against your expected volume. Check: the scheduler and API server report healthy, and a no-op test DAG runs to success.
Write a DAG that checks before writing
The pipeline developer writes the DAG so each run first asks CKAN whether the dataset already exists, using a stable dataset name as the lookup key. If it exists, the run updates it, and if not, the run creates it. Resources are matched by name, so a rerun replaces the file and does not add a duplicate. Set the organization and visibility explicitly in every payload. This is what keeps reruns idempotent: the same input run twice leaves one dataset with the same resources. Check it by triggering the DAG twice against a test dataset and confirming that the dataset and resource counts do not change after the second run.
Upload files as multipart requests
The developer sends each file in the upload parameter of resource_create for a new resource or resource_patch for an existing one. CKAN expects these uploads as multipart/form-data requests, and the ckanapi Python client wraps the Action API if your team prefers not to build those requests by hand. Every call carries the service token in the Authorization header and goes to the endpoint for that Action API function. Check: the resource's download link returns a file whose checksum matches the source, and the resource shows the expected name and format. Confirm the upload size limit in your CKAN configuration before you load large files.
Choose the DataStore loader for each resource
For each tabular resource, the developer decides how the data reaches the DataStore. XLoader is the officially supported loader in the CKAN DataStore documentation, and DataPusher is now legacy. AirCan, built on Airflow by Datopian, is also listed there, so a team already running Airflow may evaluate it alongside XLoader. Confirm which loader fits your CKAN version and file types before you set it per resource in the DAG configuration. Check: the DataStore row count for each resource matches the row count of its source file, verified through the Data API.
Set schedules, retries and failure checks
The developer sets the schedule, the retry count and the retry delay in the DAG, so transient CKAN or network failures recover without a person. Because the DAG is idempotent, a retry or a manual rerun after a partial failure updates the dataset without duplicating it. Decide whether catchup should run missed intervals, and leave it off unless the source needs backfill. Route failed-run alerts into your existing monitoring. Check: a scheduled run completes, a forced failure in the upload step retries and then succeeds, and the portal shows the expected dataset state after both runs. Hand over only after all three checks pass.
Mapping pipeline fields to CKAN datasets, organizations and resources
This table maps each pipeline input to the CKAN field it sets, the team that should own that decision, and the CKAN role the service account needs to write it. Read each row before building the DAG, because the dataset name and organization decide how upserts find existing records. The common failure points are an unstable key and an unclear owner, so agree both in writing before the first scheduled run.
| Pipeline input | CKAN field and behavior | Owner | CKAN role needed |
|---|---|---|---|
| Dataset name | Stable URL slug used as the upsert key. Look up by name, create if missing, patch if present. Never derive it from a changing title | Pipeline owner, with the data owner approving the slug | Editor in the owning organization |
| Owning organization | Set on create by organization name or ID. Moving a dataset to another organization should be a reviewed change, not a routine run | Data owner and portal administrator | Editor or admin in the organization receiving the dataset |
| Visibility (public or private) | Set the private flag explicitly on every run so drift between the source and the portal is visible | Data owner, with the portal administrator confirming policy | Editor in the owning organization. Confirm who may change visibility |
| Resource name and format | Matched per resource within the dataset. Set the format from the known file type, not from the URL | Pipeline owner | Editor in the owning organization |
| File upload | Sent with the upload parameter of resource_create or resource_patch as multipart/form-data. Confirm your size limits first | Pipeline owner, with the platform team for storage limits | Editor in the owning organization |
| Linked URL | Stored as the resource URL with no upload. The portal does not copy the file, so the link must stay reachable and stable | Team that maintains the source system | Editor in the owning organization |
| DataStore loader trigger | Starts XLoader or an Airflow loader such as AirCan after a tabular resource changes. Applies only to tabular files | Platform team owns the loader, pipeline owner owns the trigger | Editor on the dataset. Confirm any loader job permissions in your deployment |
Where AirCan fits next to XLoader in a publishing pipeline
Treat XLoader as the default loader and AirCan as a choice you still have to justify. The CKAN DataStore docs name XLoader as the officially supported tool for loading uploaded or linked files into the DataStore and describe DataPusher as legacy. The same docs list AirCan, built on Apache Airflow by Datopian, alongside XLoader, DataPusher+ and DataPusher, so it is a recognized option, but being listed does not establish that it fits your portal. Before choosing it, confirm three things with Datopian and in your own environment: which CKAN releases it supports, whether it deploys as a service next to your Airflow or as DAGs you add to an existing Airflow, and how a load is triggered, whether by a schedule, by your publishing DAG, or by a resource event.
The main design decision is whether loading belongs in the same DAG as publishing or in a separate one. In a single DAG, the task that creates the resource with resource_create and its upload parameter can hand off to the load and wait for it, so a dataset is never marked ready while its DataStore table is missing. The cost is coupling: a slow or failed load holds up the publish task, and a retry can repeat the upload. A separate DAG, started on a schedule or by a sensor that watches for new resources, keeps publishing quick and lets loads be retried on their own. The trade-off is a window in which the dataset is visible but its tables are not, so the dataset description or a status field should say when data is still loading. Choose based on how often your files change and how much a stale or missing table would cost your users.
Whichever layout you choose, run one dataset end to end before you schedule the rest. Upload a small CSV through the pipeline, confirm the loader creates the DataStore table, query it through the Data API, then run the same DAG again with a changed file to check that the update replaces the table. Also check the Airflow version under the loader. According to the Airflow version life cycle, Airflow 2 reached end of life on April 22, 2026 and gets no fixes, so a loader deployed on it needs a plan to move to a supported release. Keep loader errors in the same log stream as your publish task, so an operator can tell a bad file from an expired API token.
Securing the service account, token and Airflow deployment
The pipeline can fail in four places: the CKAN account it acts as, the token that proves that identity, the Airflow deployment that runs the code, and the downstream systems that read what it publishes. The cards below set a boundary for each one before the first scheduled run, so a leaked token or an edited DAG cannot publish to or expose more than the pipeline needs.
Least-privilege CKAN service account
Create a dedicated CKAN user for the pipeline and make it a member of only the organizations it publishes for, with the lowest organization role that allows creating and updating datasets and resources. Do not grant sysadmin, because that role bypasses organization boundaries and turns a leaked token into a portal-wide risk. Check the role permissions for your CKAN version, and confirm whether the pipeline can delete datasets or resources. If it should never remove data, make sure its role cannot.
Token rotation and revocation
CKAN Action API calls authenticate with an API token sent in the Authorization header, so that token is the pipeline's identity. Issue one token per pipeline, record its owner and purpose, and set a rotation schedule that your team can meet before any expiry date. Test revocation before go-live: revoke the token, confirm the next scheduled run fails cleanly, and confirm an alert reaches the owner. Confirm which expiry options your CKAN version offers.
CKAN API guideSecrets backend and log hygiene
Keep the token in your secrets backend and have DAGs read it at runtime through an Airflow connection or variable, so no credentials sit in DAG files under version control. Logs need the same care: do not print request headers, the token or the contents of uploaded files, and avoid logging full response bodies that may echo sensitive fields. Airflow masks values it recognizes as secrets, but do not rely on masking alone. To verify, force a failed task and read its log for tokens and file contents.
Airflow access control and DAG edits
Use the Airflow auth manager to separate people who view runs, people who trigger them and people who change DAG code, and keep edit rights with a small group. Whoever can edit a DAG can read any secret that DAG can reach, so edit rights are code access. DAG changes should pass code review and ship from version control only. Confirm how your Airflow version maps roles to these actions, and audit who holds admin rights on the deployment.
Airflow auth manager docsTLS with certificate validation
The token travels with every API call, so the CKAN endpoint should be reached only over HTTPS. Set the HTTP client to keep certificate verification on. If the portal uses an internal certificate authority, point the client at that CA bundle and leave verification enabled. Disabling verification to get a test environment working is a common shortcut that often survives into production, so search the DAG code for such settings before promotion. Also confirm that certificate expiry is monitored for the CKAN host.
Private datasets and DataStore access
CKAN checks organization permissions when the pipeline calls the Action API, so a private dataset stays private on that path. Direct database access to the DataStore bypasses those checks. A downstream tool that holds the read-only database user can read rows from private resources. Decide per dataset whether its data lands in the DataStore at all, and give downstream tools only the access their audience needs. Confirm this behavior against the DataStore documentation for your CKAN version.
CKAN DataStore docsCommon failures when Airflow publishes to CKAN
This table lists the failures teams most often hit when an Airflow pipeline publishes datasets and resources to CKAN. Each row gives the likely cause and the fix, so you can check your own deployment before a scheduled run fails or publishes bad data. Start with the authentication and upload rows, since they block every run, then review the database and scheduler rows before running several schedulers in production.
| Failure | Cause | Fix |
|---|---|---|
| 401 or 403 responses | Token expired, revoked, or created for a user without rights in the target organization | Issue a token for a service user with the correct organization role, store it in Airflow's secrets backend, and rotate it on a schedule |
| Empty files after upload | Upload sent as a JSON body, so the file is not attached to the request | Send the upload parameter as a multipart/form-data request with the file attached, then check resource size after each run |
| Duplicate datasets or resources | Task retries call create again without checking whether the dataset or resource already exists | Look up the dataset with package_show, or by a stable name, before creating anything, so each task can safely run again |
| Metadata database on SQLite or MariaDB | SQLite is for testing only, and MariaDB is not a supported Airflow metadata database | Move the metadata database to PostgreSQL or MySQL, using versions listed in the Airflow prerequisites, and back it up before the move |
| Contention with several schedulers | Several schedulers share a metadata database that was never prepared for concurrent scheduling | Confirm the database backend and scheduler settings against the Airflow scheduler documentation, then monitor database lock waits before scaling out |
| DataStore stays stale | The loader was never triggered after upload, so the DataStore still holds the previous version | Trigger XLoader or AirCan as a downstream task after each successful upload, and fail the run if the load does not complete |
| Airflow 2 past end of life | Airflow 2 reached end of life on April 22, 2026, so it gets no further fixes | Plan an upgrade to Airflow 3 using the upgrade guide, and test DAG and connection changes in a non-production environment first |
What buyers ask before automating CKAN dataset publishing with Apache Airflow
What drives the cost of automating CKAN publishing with Apache Airflow?
Cost follows scope: how many pipelines and source systems feed CKAN, how large the files are, and how many validation rules each dataset must pass. Where Airflow runs and who owns it afterward also change the price. The factors that move the cost most are:
- Number of pipelines and sources, since each one needs its own DAG logic, credentials and tests.
- File sizes, because large resources change how uploads are streamed, retried and checked.
- Validation rules, which set how much checking runs before a dataset is created or updated.
- Airflow hosting, including the metadata database, executor choice and secrets integration you run yourself.
- CKAN version and extension changes, which can require pipeline updates on each upgrade.
- Who maintains the DAGs after launch, either your team or a retainer.
The initial build is a one-time cost. Ongoing support, upgrades and testing recur only if you choose a retainer. Ask for a quote that lists each factor on its own line.
How long does a first CKAN publishing pipeline take to build?
No single duration applies, because build time depends on the scope and on how ready the portal and source data already are. A first pipeline that loads one source with simple validation takes less time than a set of pipelines spanning several sources, file formats and organizations. The inputs that set the schedule are:
- Number of sources and datasets in the first release.
- How well the source data is already structured and how many validation rules apply.
- Whether CKAN organizations, licenses and any custom schemas are already configured.
- How long access requests, network paths and TLS setup take inside your environment.
- How many review cycles your data owners need before go-live.
Fixed-scope engagements agree the timeline in writing before work starts, so ask for a written schedule tied to the scope. Any estimate you receive should name the inputs it assumes.
What must our team provide before an Airflow pipeline for CKAN starts?
Your team provides the access, data and environment details that the pipelines depend on. Expect to supply:
- CKAN admin access, or a sysadmin-approved account that can create the API tokens the pipeline uses.
- The organization list and a named owner for each dataset group.
- Data owners who approve metadata, validation rules and publication timing.
- Network and TLS details, including which hosts Airflow can reach and the certificate chain the portal presents.
- A secrets store, such as one your security team already operates, to hold API tokens and source credentials.
Access requests often set the pace of the first build, so start them early. A written scope should list each item with the person responsible for providing it.
Can an internal team build CKAN publishing with the Action API and ckanapi?
Yes, an internal team with Python and Airflow experience can build it. The CKAN Action API is called over HTTP, API tokens are sent in the Authorization header, and the ckanapi Python client wraps the same calls. Resource files are uploaded with the upload parameter of resource_create or resource_patch as a multipart request. Your team would own:
- DAGs that map source records to CKAN dataset and resource fields.
- API token management in your secrets store, including rotation.
- Tests for validation rules and failure handling, including retries.
- Run monitoring and the decision on what to do when a load fails partway through.
A partner adds the most value where the team lacks Airflow operations or CKAN upgrade experience, or where the timeline is tight. Compare the internal plan with a written scope before you decide.
Do we need Airflow 3 for new CKAN publishing work?
New work should start on Airflow 3, because Airflow 2 reached end of life on April 22, 2026 and gets no fixes after that date. Airflow 3 was first released on April 22, 2025, and its current patch release is 3.3.2. Check the Airflow version life cycle table before you pin a version, because patch releases move. Points to check on the Airflow 3 line include:
- Executor choice, since the hybrid CeleryKubernetesExecutor and LocalKubernetesExecutor are no longer supported from Airflow 3.0.0.
- Metadata database, since the prerequisites list PostgreSQL 14 to 18 and MySQL 8.0, 8.4 and Innovation releases, and MariaDB is not supported.
- Python and Kubernetes versions, which the prerequisites set for the release you choose.
- Existing DAGs, which may need changes before they run on Airflow 3.
If you already run Airflow 2, include the upgrade path in the written scope.
How do fixed scope, written deliverables and retainers work for this service?
Most DeployOpen engagements are fixed-scope, and the scope, deliverables and timeline are agreed in writing before work starts. A written scope typically names the pipelines and sources, the CKAN and Airflow versions in use, the environments involved and the handover items, so each line can be checked at acceptance. DeployOpen does not publish a price list, so a quote follows from that written scope. Changes to scope are documented in writing before they are priced. Ongoing support, upgrades and continuous testing are available as retainers. A retainer suits pipelines that must follow CKAN minor releases and Airflow patch releases over time. Ask for a quote that separates the one-time build from any retainer and states what each retainer covers.
What breaks a CKAN Airflow pipeline after launch, and how do we prevent it?
Most breakage comes from version changes in CKAN, Airflow and the source systems. CKAN patch releases do not break backwards compatibility, but minor releases may include backwards-incompatible changes, so pipelines need testing before each minor upgrade. CKAN targets about two minor releases a year, and only the latest patch of the current minor and the previous minor receive fixes. Watch for:
- Extension changes, since an extension a pipeline depends on may lag a CKAN minor release.
- Airflow support windows, because a version past end of life gets no fixes.
- Credential expiry or rotation in the secrets store.
- Source schema changes that break field mapping.
Keep a staging CKAN and a test suite that runs every DAG before each production upgrade.
How DeployOpen scopes and delivers CKAN publishing pipelines
DeployOpen plans, builds and hands over scheduled Airflow pipelines that create and update CKAN datasets and resources in infrastructure you control. Each pipeline starts from a written scope that names the CKAN and Airflow versions, the datasets involved and whether XLoader or AirCan loads each tabular file. Work is documented for your team, with optional retainer support afterward.
How we scope
- The written scope names CKAN and Airflow versions, target datasets and the resources each pipeline creates or updates.
- Scope records which loader handles tabular files, XLoader or AirCan, and why it fits your file types and volumes.
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before any work starts.
How we build
- Airflow tasks call the CKAN Action API at
/api/3/action/with API tokens sent in the Authorization header. - Resource uploads use resource_create or resource_patch with multipart/form-data, wrapped by the ckanapi client where it fits.
- The metadata database is PostgreSQL or MySQL on a supported version, since Airflow's SQLite backend is for testing only.
How we hand over
- Handover covers DAG code, CKAN API token setup, environment configuration and a runbook for reruns and failed loads.
- CKAN API tokens are stored in Airflow connections or your secrets backend, and kept out of DAG files.
- Documentation records the datasets, schedules, loader choices and the upgrade path for both CKAN and Airflow.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers for the pipelines.
- Airflow 2 reached end of life on April 22, 2026, so new builds target Airflow 3.
- Upgrades follow CKAN's patch and minor release policy, since minor releases may include backwards-incompatible changes.

