[ckan-dev] CKAN API Clients

Rufus Pollock rufus.pollock at okfn.org
Thu Apr 19 22:16:11 UTC 2012


On 19 April 2012 17:22, Haq, Salman <Salman.Haq at neustar.biz> wrote:
> Hi,
>
> I want to programmatically create datasets and upload resources to my CKAN
> 1.6 instance.
>
> Looking at the docs.ckan.org, it seems that there are several client
> libraries available and at least three API versions.
>
> From the documentation, it's not clear to me which which clients support
> which API versions. I assume this is tribal knowledge, but can it be
> tabulated in the documentation?

The only guaranteed up to date one is the Python one as that is core
maintained so with other libs YMMV. However, I note we have not made
breaking changes to RESTFul API for several versions so old stuff
(<1y) should work quite well. I note no client supports the action API
as yet.

> Ideally I'd like to use the Python client which is maintained by the core
> team. I can download the source pypi but I cannot find the source on github
> – can someone point me to it?

https://github.com/okfn/ckanclient

> Upon inspecting the source code, it appears that this client supports API v1
> and v2 but not v3.

That is correct.

> My cursory understanding is that version 3 of the API is what I will need to
> use to accomplish my tasks. Am I correct in assuming that I will have to
> extend the Python client?

That is correct -- patches will be very welcome and we will be looking
to add action API support. I should also say JSON web API's are
trivial to use directly, for example here's a simple python function
do a request with any method and any data to specified URL

    def _request(self, url, data, method):
        opener = urllib2.build_opener(urllib2.HTTPHandler)
        request = urllib2.Request(url, data, self._headers)
        request.get_method = lambda: method
        response = opener.open(request)
        return response.read()

Regards,

Rufus




More information about the ckan-dev mailing list