Skip to content

Drupal 8 Module to connect to a CKAN endpoint providing a wrapper around the CKAN Action API

Notifications You must be signed in to change notification settings

govCMS/ckan_connect

Repository files navigation

CKAN Connect

CKAN connect is a Drupal 8/9 companion module for the Data Visualisation Framework (DVF) module. Its goal is to provide CKAN connectivity and abstract API calls. Other modules can use CKAN connect if they need CKAN connectivity from Drupal and it does not require DVF to function.

CKAN is the industry standard for large dataset storage and is used by most governments for public data storage. It provides a robust API for retrieving data records with support for filtering, searching and more.

Examples of CKAN instances:

Install and configure

Install

CKAN connect is ideally installed via composer

composer require drupal/ckan_connect

Then enabled via Drupal UI or drush

drush en ckan_connect

Configure

Once installed you must set the Base URL for the CKAN instance.

  • Visit: Admin > Configuration > Webservices > CKAN Connect (/admin/config/services/ckan-connect)
  • Set the API url to match your CKAN instance eg. https://data.gov.au/api/3
  • If you need write access to CKAN or you need to view private datasets then you can also add an API key. Note the security implications here, you could potentially expose private data on your Drupal site when an API key is used

CKAN Connect API

Add as dependency

If your module requires CKAN Connect, ensure dependencies are added

composer.json

"require": {
    "drupal/ckan_connect": "*"
}

module.info.yml

dependencies:
  - ckan_connect:ckan_connect

Usage

The CkanClientInterface documents available methods, but most of the time you will only need the get() method. This will make an API call to a specific endpoint with the appropriate query parameters added.

Example of querying the action/datastore_search endpoint:

use Drupal\ckan_connect\Client\CkanClientInterface;

$client = new CkanClientInterface();

$response = $client->get('action/datastore_search', [
  'id' => 'da675507-10b5-4825-8e79-09dcbb577ece',
  'limit' => 10,
  'offset' => 0,
]);

if ($response->success === TRUE) {
  var_dump($response->result);
}

View the CKAN API docs for more information on available endpoints and query parameters.

Issues and feature suggestions

Development of CKAN Connect is currently occurring over at GitHub

Issues are ideally logged in the Github issue queue but we also monitor the Drupal issue queue

Contributing and extending CKAN Connect

We welcome (and appreciate) improvements and fixes to CKAN Connect, so if you have something to add please submit a Github pull request.

Supporting organizations

Primary Developers

Doghouse Agency

Sponsors

About

Drupal 8 Module to connect to a CKAN endpoint providing a wrapper around the CKAN Action API

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages