New package: ckanr

We’re happy to finally release the first version to CRAN of ckanr

ckanr is an R client for CKAN.

For those not familiar, CKAN is an open-source data portal platform. After installation, check out ckanr::servers() for a list of instances, or the webpage

You can work with local or remote CKAN instances, create and update datasets and resources, manage users, tags, and organizations, and more.

on CRAN: CRAN - Package ckanr (binaries soon)
on GitHub:
README help:

It’s being developed with some awesome folks:


How/when are ckan instances added to ckanr so that they appear in the output of the servers() function? I was expecting to find in the listing as it is included in the census but did not.

They are added to the servers() function manually. That is simply a function that returns a list, see

I think you are looking for (which is the first result in servers()) - is that right?

I should add that these URLs are (hopefully) the base URLs for the CKAN instance - which can vary quite a bit from instance to instance

1 Like

Yes, apologize for being blind :slight_smile: Didn’t realize that it would be prefixed with catalog. Thanks.

@mihiriyer Hmmm, playing with the pkg to make sure that works, and sometimes it does, but sometimes not. It seems from

ckan_info(url = "")$ckan_version
#> [1] "2.1a"

they are using a quite old CKAN version, which leads to some problems, e.g,.

package_list(url = "")
#> Error: 400 - Search Query Error
#>  message Search Query is invalid: "Invalid search parameters: ['limit', 'offset']"

At least there’s an informative message :slight_smile:

But we can fix that by not passing those limit and offset params, but I’d need to change that internally. Will push a fix soon. After the fix install from github like devtools::install_github("ropensci/ckanr")

issue opened

@sckott What are the implications of receiving a message such as below:

ckan_info(url = "")$ckan_version
Error: lexical error: invalid char in json text.
                                       <!DOCTYPE html> <!--[if IE 7]> 
                     (right here) ------^

I also verified (View Page Info) the ckan version for this site which is 2.5.1. Let me know if you have any ideas, thanks.

thanks for the question @mihiriyer

looks like that CKAN instance requires login, simple auth with username/password

I guess we currently don’t allow you to pass in curl options to that function, but you can to i think almost all others - where you would do

ckanr::package_list("", httr::authenticate(user = "your username", password = "your password"))

We should make sure to allow that for all functions.

let me know if that works

Thanks for the tip @sckott. This is what I got:

Error in vapply(elements, encode, character(1)) :
values must be length 1,
but FUN(X[[2]]) result is length 7

Do you think I need to use the “type” option in the authenticate function?

that’s the error you got after executing what?

after executing the following as you mentioned in you previous reply:

ckanr::package_list(“”, httr::authenticate(user = “your username”, password = “your password”))

sorry, that should have been

ckanr::package_list("", config = httr::authenticate(user = "your username", password = "your password"))

where you need to pass it to config param

that will still error, giving

#>  Error: 409 - Validation Error
#>    offset Invalid integer 

which i’m still working out

1 Like