Using the API with Javascript

From CKAN

Jump to: navigation, search

Using CKAN (via its API) from javascript including how to use the official CKAN javascript client library.

Contents

Pre-requisities

3 Learn jquery in 18 minutes: http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery

Getting Started

Try out the online demo

Visit: http://okfnlabs.org/ckanjs/app and play around

Get the code on your machine

Start Changing Things

Get your own file

 jQuery(document).ready(function($) {
 ...
 }

so it reads

jQuery(document).ready(function($) {
  cfg = {
    endpoint: 'http://ckan.net'
  }
  CKAN.Model.configure(cfg);
});

Search for a dataset

CKAN.Model.search('ckan', function(data) {
    $('.flash-banner-box').html(data);
    });

In your console (firebug or chrome) you should see an object.

Original Notes

http://ckan.okfnpad.org/tutorial-js

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox