Title: | Client for the Comprehensive Knowledge Archive Network ('CKAN') API |
---|---|
Description: | Client for 'CKAN' API (<https://ckan.org/>). Includes interface to 'CKAN' 'APIs' for search, list, show for packages, organizations, and resources. In addition, provides an interface to the 'datastore' API. |
Authors: | Scott Chamberlain [aut] , Imanuel Costigan [aut], Wush Wu [aut] , Florian Mayer [aut] , Sharla Gelfand [aut], Francisco Alves [aut, cre] |
Maintainer: | Francisco Alves <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.7.0.9000 |
Built: | 2024-09-28 06:28:27 UTC |
Source: | https://github.com/ropensci/ckanr |
ckanr is a full client for the CKAN API, wrapping all APIs, including for reading and writing data. Please get in touch (https://github.com/ropensci/ckanr/issues or https://discuss.ropensci.org/) if you have problems, or have use cases that we don't cover yet.
Document for the CKAN API is at https://docs.ckan.org/en/latest/api/index.html. We'll always be following the latest version of the API.
The functions can be grouped into those for setup, packages, resources, tags, organizations, groups, and users.
Setup - The main one is ckanr_setup()
- and many related
functions, e.g., get_default_key()
Packages - Create a package with package_create()
, and see
other functions starting with package_*
Resources - Create a package with resource_create()
, and see
other functions starting with resource_*
Tags - List tags with tag_list()
, and see
other functions starting with tag_*
Organizations - List organizations with organization_list()
,
show a specific organization with organization_show()
, and
create with organization_create()
Groups - List groups with group_list()
, and see
other functions starting with group_*
Users - List users with user_list()
, and see
other functions starting with user_*
Related items - See functions starting with related_*
We are also working on supporting the Datastore extension (https://docs.ckan.org/en/latest/maintaining/datastore.html). We currently have these functions:
Data can come back in a huge variety of formats. We've attempted a function to
help you fetch not just metadata but the actual data for a link to a file on
a CKAN instance. Though if you know what you're doing, you can easily use
whatever is your preferred tool for the job (e.g., maybe you like
read.csv()
for reading csv files).
We have a helper function (servers()
) that spits out the current
CKAN instances we know about, with URLs to their base URLs that should work
using this package. That is, not necessarily landing pages of each instance,
although, the URL may be the landing page and the base API URL.
Scott Chamberlain [email protected]
Florian Mayer [email protected]
Wush Wu
Imanuel Costigan [email protected]
ckan_group class helpers
as.ckan_group(x, ...) is.ckan_group(x)
as.ckan_group(x, ...) is.ckan_group(x)
x |
Variety of things, character, list, or ckan_group class object |
... |
Further args passed on to |
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) (grps <- group_list()) grps[[3]] # create item class from only an item ID as.ckan_group(grps[[3]]$id) # gives back itself (x <- as.ckan_group(grps[[3]]$id)) as.ckan_group(x) ## End(Not run)
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) (grps <- group_list()) grps[[3]] # create item class from only an item ID as.ckan_group(grps[[3]]$id) # gives back itself (x <- as.ckan_group(grps[[3]]$id)) as.ckan_group(x) ## End(Not run)
ckan_organization class helpers
as.ckan_organization(x, ...) is.ckan_organization(x)
as.ckan_organization(x, ...) is.ckan_organization(x)
x |
Variety of things, character, list, or ckan_organization class object |
... |
Further args passed on to |
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) (orgs <- organization_list(limit = 3)) orgs[[3]] # create item class from only an item ID as.ckan_organization(orgs[[3]]$id) # gives back itself (x <- as.ckan_organization(orgs[[3]]$id)) as.ckan_organization(x) ## End(Not run)
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) (orgs <- organization_list(limit = 3)) orgs[[3]] # create item class from only an item ID as.ckan_organization(orgs[[3]]$id) # gives back itself (x <- as.ckan_organization(orgs[[3]]$id)) as.ckan_organization(x) ## End(Not run)
ckan_package class helpers
as.ckan_package(x, ...) is.ckan_package(x)
as.ckan_package(x, ...) is.ckan_package(x)
x |
Variety of things, character, list, or ckan_package class object |
... |
Further args passed on to |
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) (pkgs <- package_search()) pkgs$results pkgs$results[[3]] # create item class from only an item ID as.ckan_package(pkgs$results[[3]]$id) # gives back itself (x <- as.ckan_package(pkgs$results[[3]]$id)) as.ckan_package(x) ## End(Not run)
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) (pkgs <- package_search()) pkgs$results pkgs$results[[3]] # create item class from only an item ID as.ckan_package(pkgs$results[[3]]$id) # gives back itself (x <- as.ckan_package(pkgs$results[[3]]$id)) as.ckan_package(x) ## End(Not run)
ckan_resource class helpers
as.ckan_resource(x, ...) is.ckan_resource(x)
as.ckan_resource(x, ...) is.ckan_resource(x)
x |
Variety of things, character, list, or ckan_package class object |
... |
Further args passed on to |
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) (resrcs <- resource_search(q = 'name:data')) resrcs$results resrcs$results[[3]] # create item class from only an item ID as.ckan_resource(resrcs$results[[3]]$id) # gives back itself (x <- as.ckan_resource(resrcs$results[[3]]$id)) as.ckan_resource(x) ## End(Not run)
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) (resrcs <- resource_search(q = 'name:data')) resrcs$results resrcs$results[[3]] # create item class from only an item ID as.ckan_resource(resrcs$results[[3]]$id) # gives back itself (x <- as.ckan_resource(resrcs$results[[3]]$id)) as.ckan_resource(x) ## End(Not run)
ckan_tag class helpers
as.ckan_tag(x, ...) is.ckan_tag(x)
as.ckan_tag(x, ...) is.ckan_tag(x)
x |
Variety of things, character, list, or ckan_tag class object |
... |
Further args passed on to |
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) (tags <- tag_search(query = 'ta')) tags[[3]] # create item class from only an item ID as.ckan_tag(tags[[3]]$id) # gives back itself (x <- as.ckan_tag(tags[[3]]$id)) as.ckan_tag(x) ## End(Not run)
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) (tags <- tag_search(query = 'ta')) tags[[3]] # create item class from only an item ID as.ckan_tag(tags[[3]]$id) # gives back itself (x <- as.ckan_tag(tags[[3]]$id)) as.ckan_tag(x) ## End(Not run)
ckan_user class helpers
as.ckan_user(x, ...) is.ckan_user(x)
as.ckan_user(x, ...) is.ckan_user(x)
x |
Variety of things, character, list, or ckan_user class object |
... |
Further args passed on to |
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) (usrs <- user_list()) usrs[1:3] usrs[[3]] # create item class from only an item ID as.ckan_user(usrs[[3]]$id) # gives back itself (x <- as.ckan_user(usrs[[3]]$id)) as.ckan_user(x) ## End(Not run)
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) (usrs <- user_list()) usrs[1:3] usrs[[3]] # create item class from only an item ID as.ckan_user(usrs[[3]]$id) # gives back itself (x <- as.ckan_user(usrs[[3]]$id)) as.ckan_user(x) ## End(Not run)
Get an activity stream of recently changed datasets on a site.
changes( offset = 0, limit = 31, url = get_default_url(), key = get_default_key(), as = "list", ... )
changes( offset = 0, limit = 31, url = get_default_url(), key = get_default_key(), as = "list", ... )
offset |
(numeric) Where to start getting activity items from (optional, default: 0) |
limit |
(numeric) The maximum number of activities to return (optional, default: 31) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: changes() changes(as = 'json') changes(as = 'table') ## End(Not run)
## Not run: changes() changes(as = 'json') changes(as = 'table') ## End(Not run)
ckanr S3 classes
ckan_package - CKAN package
ckan_resource - CKAN resource
ckan_related - CKAN related item
The functions as.ckan_*()
for each CKAN object type coerce something
to a S3 class of that type. For example, you can coerce a package ID as a
character string into an ckan_package
object by calling
as.ckan_package(<id>
.
To test whether an object is of a particular ckan_*
class, there is a
is._ckan_*()
function for all of the classes listed above. You can use
one of those functions to get a logical back, TRUE
or FALSE
.
These are simple S3 classes, basically an R list with an attached class so we can know what to do with the object and have flexible inputs and outputs from functions. You can edit one of these classes yourself by simply changing values in the list.
Download a file
ckan_fetch( x, store = "session", path = "file", format = NULL, key = get_default_key(), ... )
ckan_fetch( x, store = "session", path = "file", format = NULL, key = get_default_key(), ... )
x |
URL for the file |
store |
One of session (default) or disk. session stores in R session, and disk saves the file to disk. |
path |
if |
format |
Format of the file. Required if format is not detectable through file URL. |
key |
A CKAN API key (optional, character) |
... |
Arguments passed on to the function used to read the file, if |
The ...
argument can be used to pass additional arguments to the
function that actually reads the file. It is only used when store="session"
and if the file is not a ZIP file.
This list shows what function is used to read what file format, so that you can see what additional arguments are available:
csv: read.csv
xls, xlsx: read_excel
xml: read_xml
html: read_html
json: fromJSON
shp, geojson: st_read
txt: read.table
## Not run: # CSV file ckanr_setup("http://datamx.io") res <- resource_show(id = "6145a539-cbde-4b0d-a3d3-d1a5eb013f5c", as = "table") head(ckan_fetch(res$url)) ckan_fetch(res$url, "disk", "myfile.csv") # CSV file, format not available ckanr_setup("https://ckan0.cf.opendata.inter.prod-toronto.ca") res <- resource_show(id = "c57c3e1c-20e2-470f-bc82-e39a0264be31", as = "table") res$url res$format head(ckan_fetch(res$url, format = res$format)) # Excel file - requires readxl package ckanr_setup("http://datamx.io") res <- resource_show(id = "e883510e-a082-435c-872a-c5b915857ae1", as = "table") head(ckan_fetch(res$url)) # Excel file, multiple sheets - requires readxl package ckanr_setup() res <- resource_show(id = "ce02a1cf-35f1-41df-91d9-11ed1fdd4186", as = "table") x <- ckan_fetch(res$url) names(x) head(x[["Mayor - Maire"]]) # XML file - requires xml2 package # ckanr_setup("http://data.ottawa.ca") # res <- resource_show(id = "380061c1-6c46-4da6-a01b-7ab0f49a881e", # as = "table") # ckan_fetch(res$url) # HTML file - requires xml2 package ckanr_setup("http://open.canada.ca/data/en") res <- resource_show(id = "80321bac-4283-487c-93bd-c65acaa660f5", as = "table") ckan_fetch(res$url) library("xml2") xml_text(xml_find_first(xml_children(ckan_fetch(res$url))[[1]], "title")) # JSON file, by default reads in to a data.frame for ease of use ckanr_setup("http://data.surrey.ca") res <- resource_show(id = "8d07c662-800d-4977-9e3e-5a3d2d1e99ab", as = "table") head(ckan_fetch(res$url)) # SHP file (spatial data, ESRI format) - requires sf package ckanr_setup("https://ckan0.cf.opendata.inter.prod-toronto.ca") res <- resource_show(id = "27362290-8bbf-434b-a9de-325a6c2ef923", as = "table") x <- ckan_fetch(res$url) class(x) plot(x[, c("AREA_NAME", "geometry")]) # GeoJSON file - requires sf package ckanr_setup("http://datamx.io") res <- resource_show(id = "b1cd35b7-479e-4fa0-86e9-e897d3c617e6", as = "table") x <- ckan_fetch(res$url) class(x) plot(x[, c("mun_name", "geometry")]) # ZIP file - packages required depends on contents ckanr_setup("https://ckan0.cf.opendata.inter.prod-toronto.ca") res <- resource_show(id = "bb21e1b8-a466-41c6-8bc3-3c362cb1ed55", as = "table") x <- ckan_fetch(res$url) names(x) head(x[["ChickenpoxAgegroups2017.csv"]]) # TXT file ckanr_setup("https://ckan0.cf.opendata.inter.prod-toronto.ca") res <- resource_show(id = "e4211f49-611f-438c-a444-aaa7f3f84117", as = "table") x <- ckan_fetch(res$url) head(x) # TXT file, semicolon used as separator ckanr_setup("https://data.coat.no") res <- resource_show(id = "384fe537-e0bd-4e57-8a0d-420b7a745196", as = "table") x <- ckan_fetch(res$url, sep = ";") head(x) ## End(Not run)
## Not run: # CSV file ckanr_setup("http://datamx.io") res <- resource_show(id = "6145a539-cbde-4b0d-a3d3-d1a5eb013f5c", as = "table") head(ckan_fetch(res$url)) ckan_fetch(res$url, "disk", "myfile.csv") # CSV file, format not available ckanr_setup("https://ckan0.cf.opendata.inter.prod-toronto.ca") res <- resource_show(id = "c57c3e1c-20e2-470f-bc82-e39a0264be31", as = "table") res$url res$format head(ckan_fetch(res$url, format = res$format)) # Excel file - requires readxl package ckanr_setup("http://datamx.io") res <- resource_show(id = "e883510e-a082-435c-872a-c5b915857ae1", as = "table") head(ckan_fetch(res$url)) # Excel file, multiple sheets - requires readxl package ckanr_setup() res <- resource_show(id = "ce02a1cf-35f1-41df-91d9-11ed1fdd4186", as = "table") x <- ckan_fetch(res$url) names(x) head(x[["Mayor - Maire"]]) # XML file - requires xml2 package # ckanr_setup("http://data.ottawa.ca") # res <- resource_show(id = "380061c1-6c46-4da6-a01b-7ab0f49a881e", # as = "table") # ckan_fetch(res$url) # HTML file - requires xml2 package ckanr_setup("http://open.canada.ca/data/en") res <- resource_show(id = "80321bac-4283-487c-93bd-c65acaa660f5", as = "table") ckan_fetch(res$url) library("xml2") xml_text(xml_find_first(xml_children(ckan_fetch(res$url))[[1]], "title")) # JSON file, by default reads in to a data.frame for ease of use ckanr_setup("http://data.surrey.ca") res <- resource_show(id = "8d07c662-800d-4977-9e3e-5a3d2d1e99ab", as = "table") head(ckan_fetch(res$url)) # SHP file (spatial data, ESRI format) - requires sf package ckanr_setup("https://ckan0.cf.opendata.inter.prod-toronto.ca") res <- resource_show(id = "27362290-8bbf-434b-a9de-325a6c2ef923", as = "table") x <- ckan_fetch(res$url) class(x) plot(x[, c("AREA_NAME", "geometry")]) # GeoJSON file - requires sf package ckanr_setup("http://datamx.io") res <- resource_show(id = "b1cd35b7-479e-4fa0-86e9-e897d3c617e6", as = "table") x <- ckan_fetch(res$url) class(x) plot(x[, c("mun_name", "geometry")]) # ZIP file - packages required depends on contents ckanr_setup("https://ckan0.cf.opendata.inter.prod-toronto.ca") res <- resource_show(id = "bb21e1b8-a466-41c6-8bc3-3c362cb1ed55", as = "table") x <- ckan_fetch(res$url) names(x) head(x[["ChickenpoxAgegroups2017.csv"]]) # TXT file ckanr_setup("https://ckan0.cf.opendata.inter.prod-toronto.ca") res <- resource_show(id = "e4211f49-611f-438c-a444-aaa7f3f84117", as = "table") x <- ckan_fetch(res$url) head(x) # TXT file, semicolon used as separator ckanr_setup("https://data.coat.no") res <- resource_show(id = "384fe537-e0bd-4e57-8a0d-420b7a745196", as = "table") x <- ckan_fetch(res$url, sep = ";") head(x) ## End(Not run)
Get information on a CKAN server
ckan_info(url = get_default_url(), ...) ckan_version(url = get_default_url(), ...)
ckan_info(url = get_default_url(), ...) ckan_version(url = get_default_url(), ...)
url |
Base url to use. Default: https://data.ontario.ca. See
also |
... |
Curl args passed on to crul::verb-GET (optional) |
for ckan_info
a list with many slots with various info.
for ckan_version
, list of length two, with actual version as character,
and another with version converted to numeric (any dots or letters removed)
## Not run: ckan_info() ckan_info(servers()[5]) ckan_version(servers()[5]) ## End(Not run)
## Not run: ckan_info() ckan_info(servers()[5]) ckan_version(servers()[5]) ## End(Not run)
Get or set ckanr CKAN settings
ckanr_settings() get_default_url() get_default_key() get_test_url() get_test_key() get_test_did() get_test_rid() get_test_gid() get_test_oid() get_test_behaviour()
ckanr_settings() get_default_url() get_default_key() get_test_url() get_test_key() get_test_did() get_test_rid() get_test_gid() get_test_oid() get_test_behaviour()
ckanr_settings
prints your base url, API key (if used), and
optional test server settings (URL, API key, a dataset ID and a resource ID).
ckanr_setup
sets your production and test settings, while
get_test_*
get each of those respective settings.
test_behaviour
indicates whether the CKANR test suite will skip
("SKIP") or fail ("FAIL") writing tests in case the configured test
CKAN settings don't work.
ckanr_setup()
,
get_default_url()
, get_default_key()
, get_test_url()
,
get_test_key()
, get_test_did()
, get_test_rid()
,
get_test_gid()
, get_test_oid
, get_test_behaviour
ckanr_settings()
ckanr_settings()
Configure default CKAN settings
ckanr_setup( url = "https://data.ontario.ca/", key = NULL, test_url = NULL, test_key = NULL, test_did = NULL, test_rid = NULL, test_gid = NULL, test_oid = NULL, test_behaviour = NULL, proxy = NULL )
ckanr_setup( url = "https://data.ontario.ca/", key = NULL, test_url = NULL, test_key = NULL, test_did = NULL, test_rid = NULL, test_gid = NULL, test_oid = NULL, test_behaviour = NULL, proxy = NULL )
url |
A CKAN URL (optional), default: https://data.ontario.ca |
key |
A CKAN API key (optional, character) |
test_url |
(optional, character) A valid CKAN URL for testing purposes |
test_key |
(optional, character) A valid CKAN API key privileged to
create datasets at |
test_did |
(optional, character) A valid CKAN dataset ID, existing at
|
test_rid |
(optional, character) A valid CKAN resource ID, attached to
|
test_gid |
(optional, character) A valid CKAN group name at |
test_oid |
(optional, character) A valid CKAN organization name at
|
test_behaviour |
(optional, character) Whether to fail ("FAIL") or skip ("SKIP") writing tests in case of problems with the configured test CKAN. |
proxy |
an object of class |
ckanr_setup()
sets CKAN connection details. ckanr's functions
default to use the default URL and API key unless specified explicitly.
ckanr's automated tests require a valid CKAN URL, a privileged API key for that URL, plus the IDs of an existing dataset and an existing resource, respectively.
The writing tests (create, update, delete) can fail for two reasons: failures in ckanr's code which the tests aim to detect, or failures in the configured CKAN, which are not necessarily a problem with ckanr's code but prevent the tests to prove otherwise.
Setting test_behaviour
to "SKIP"
will allow writing tests to skip
if the configured test CKAN fails. This is desirable to e.g. test the other
functions even if the tester has no write access to a CKAN instance.
Setting test_behaviour
to "FAIL"
will let the tester find any
problems with both the configured test CKAN and the writing functions.
# CKAN users without admin/editor privileges could run: ckanr_setup(url = "https://data.ontario.ca/") # Privileged CKAN editor/admin users can run: ckanr_setup(url = "https://data.ontario.ca/", key = "some-CKAN-API-key") # ckanR developers/testers can run: ckanr_setup(url = "https://data.ontario.ca/", key = "some-CKAN-API-key", test_url = "http://test-ckan.gov/",test_key = "test-ckan-API-key", test_did = "test-ckan-dataset-id",test_rid = "test-ckan-resource-id", test_gid = "test-group-name", test_oid = "test-organzation-name", test_behaviour = "FAIL") # Not specifying the default CKAN URL will reset the CKAN URL to its default # "https://data.ontario.ca/": ckanr_setup() # set a proxy ckanr_setup(proxy = crul::proxy("64.251.21.73:8080")) ckanr_settings() ## run without setting proxy to reset to no proxy ckanr_setup() ckanr_settings()
# CKAN users without admin/editor privileges could run: ckanr_setup(url = "https://data.ontario.ca/") # Privileged CKAN editor/admin users can run: ckanr_setup(url = "https://data.ontario.ca/", key = "some-CKAN-API-key") # ckanR developers/testers can run: ckanr_setup(url = "https://data.ontario.ca/", key = "some-CKAN-API-key", test_url = "http://test-ckan.gov/",test_key = "test-ckan-API-key", test_did = "test-ckan-dataset-id",test_rid = "test-ckan-resource-id", test_gid = "test-group-name", test_oid = "test-organzation-name", test_behaviour = "FAIL") # Not specifying the default CKAN URL will reset the CKAN URL to its default # "https://data.ontario.ca/": ckanr_setup() # set a proxy ckanr_setup(proxy = crul::proxy("64.251.21.73:8080")) ckanr_settings() ## run without setting proxy to reset to no proxy ckanr_setup() ckanr_settings()
These functions still work but will be removed (defunct) in the next version.
ds_create_dataset()
: The functionality of this function is already in
another function in this package. See function resource_create()
Authorized user's dashboard activity stream
dashboard_activity_list( limit = 31, offset = 0, url = get_default_url(), key = get_default_key(), as = "list", ... )
dashboard_activity_list( limit = 31, offset = 0, url = get_default_url(), key = get_default_key(), as = "list", ... )
limit |
(integer) The maximum number of activities to return (optional). Default: 31 |
offset |
(integer) Where to start getting activity items from (optional). Default: 0 |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # get activity (res <- dashboard_activity_list()) ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # get activity (res <- dashboard_activity_list()) ## End(Not run)
Number of new activities of an authorized user
dashboard_count( url = get_default_url(), key = get_default_key(), as = "list", ... )
dashboard_count( url = get_default_url(), key = get_default_key(), as = "list", ... )
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
Important: Activities from the user herself are not counted by this function even though they appear in the dashboard (users don't want to be notified about things they did themselves).
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # count dashboard_count() ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # count dashboard_count() ## End(Not run)
BEWARE: This function still doesn't quite work yet.
ds_create( resource_id = NULL, resource = NULL, force = FALSE, aliases = NULL, fields = NULL, records = NULL, primary_key = NULL, indexes = NULL, url = get_default_url(), key = get_default_key(), as = "list", ... )
ds_create( resource_id = NULL, resource = NULL, force = FALSE, aliases = NULL, fields = NULL, records = NULL, primary_key = NULL, indexes = NULL, url = get_default_url(), key = get_default_key(), as = "list", ... )
resource_id |
(string) Resource id that the data is going to be stored against. |
resource |
(dictionary) Resource dictionary that is passed to
|
force |
(logical) Set to |
aliases |
(character) Names for read only aliases of the resource. (optional) |
fields |
(list) Fields/columns and their extra metadata. (optional) |
records |
(list) The data, eg: |
primary_key |
(character) Fields that represent a unique key (optional) |
indexes |
(character) Indexes on table (optional) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
http://bit.ly/ds_create
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # create a package (res <- package_create("foobarrrrr", author="Jane Doe")) # then create a resource file <- system.file("examples", "actinidiaceae.csv", package = "ckanr") (xx <- resource_create(package_id = res$id, description = "my resource", name = "bears", upload = file, rcurl = "http://google.com" )) ds_create(resource_id = xx$id, records = iris, force = TRUE) resource_show(xx$id) ## End(Not run)
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # create a package (res <- package_create("foobarrrrr", author="Jane Doe")) # then create a resource file <- system.file("examples", "actinidiaceae.csv", package = "ckanr") (xx <- resource_create(package_id = res$id, description = "my resource", name = "bears", upload = file, rcurl = "http://google.com" )) ds_create(resource_id = xx$id, records = iris, force = TRUE) resource_show(xx$id) ## End(Not run)
Datastore - create a new resource on an existing dataset
ds_create_dataset( package_id, name, path, url = get_default_url(), key = get_default_key(), as = "list", ... )
ds_create_dataset( package_id, name, path, url = get_default_url(), key = get_default_key(), as = "list", ... )
package_id |
(character) Existing package ID (required) |
name |
(character) Name of the new resource (required) |
path |
(character) Path of the file to add (required) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
This function is deprecated - will be defunct in the next version of this package
http://docs.ckan.org/en/latest/api/index.html#ckan.logic.action.create.resource_create
## Not run: path <- system.file("examples", "actinidiaceae.csv", package = "ckanr") ckanr_setup(url = "https://demo.ckan.org/", key = "my-demo-ckan-org-api-key") ds_create_dataset(package_id='testingagain', name="mydata", path = path) # Testing: see ?ckanr_setup to set test settings ckanr_setup(test_url = "http://my-ckan.org/", test_key = "my-ckan-api-key", test_did="an-existing-package-id", test_rid="an-existing-resource-id") ds_create_dataset(package_id=get_test_pid(), name="mydata", path=system.file("examples", "actinidiaceae.csv", package = "ckanr"), key = get_test_key(), url = get_test_url()) ## End(Not run)
## Not run: path <- system.file("examples", "actinidiaceae.csv", package = "ckanr") ckanr_setup(url = "https://demo.ckan.org/", key = "my-demo-ckan-org-api-key") ds_create_dataset(package_id='testingagain', name="mydata", path = path) # Testing: see ?ckanr_setup to set test settings ckanr_setup(test_url = "http://my-ckan.org/", test_key = "my-ckan-api-key", test_did="an-existing-package-id", test_rid="an-existing-resource-id") ds_create_dataset(package_id=get_test_pid(), name="mydata", path=system.file("examples", "actinidiaceae.csv", package = "ckanr"), key = get_test_key(), url = get_test_url()) ## End(Not run)
Datastore - search or get a dataset from CKAN datastore
ds_search( resource_id = NULL, filters = NULL, q = NULL, plain = NULL, language = NULL, fields = NULL, offset = NULL, limit = NULL, sort = NULL, url = get_default_url(), key = get_default_key(), as = "list", ... )
ds_search( resource_id = NULL, filters = NULL, q = NULL, plain = NULL, language = NULL, fields = NULL, offset = NULL, limit = NULL, sort = NULL, url = get_default_url(), key = get_default_key(), as = "list", ... )
resource_id |
(character) id or alias of the resource to be searched against |
filters |
(character) matching conditions to select, e.g
|
q |
(character) full text query (optional) |
plain |
(character) treat as plain text query (optional, default:
|
language |
(character) language of the full text query (optional, default: english) |
fields |
(character) fields to return (optional, default: all fields in original order) |
offset |
(numeric) Where to start getting activity items from (optional, default: 0) |
limit |
(numeric) The maximum number of activities to return (optional, default: 100) |
sort |
Field to sort on. You can specify ascending (e.g., score desc) or descending (e.g., score asc), sort by two fields (e.g., score desc, price asc), or sort by a function (e.g., sum(x_f, y_f) desc, which sorts by the sum of x_f and y_f in a descending order). (optional) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
From the help for this method "The datastore_search action allows you to search data in a resource. DataStore resources that belong to private CKAN resource can only be read by you if you have access to the CKAN resource and send the appropriate authorization."
Setting plain=FALSE
enables the entire PostgreSQL full text search query
language. A listing of all available resources can be found at the alias
table_metadata full text search query language:
http://www.postgresql.org/docs/9.1/static/datatype-textsearch.html#DATATYPE-TSQUERY
## Not run: ckanr_setup(url = 'https://data.nhm.ac.uk/') ds_search(resource_id = '8f0784a6-82dd-44e7-b105-6194e046eb8d') ds_search(resource_id = '8f0784a6-82dd-44e7-b105-6194e046eb8d', as = "table") ds_search(resource_id = '8f0784a6-82dd-44e7-b105-6194e046eb8d', as = "json") ds_search(resource_id = '8f0784a6-82dd-44e7-b105-6194e046eb8d', limit = 1, as = "table") ds_search(resource_id = '8f0784a6-82dd-44e7-b105-6194e046eb8d', q = "a*") ## End(Not run)
## Not run: ckanr_setup(url = 'https://data.nhm.ac.uk/') ds_search(resource_id = '8f0784a6-82dd-44e7-b105-6194e046eb8d') ds_search(resource_id = '8f0784a6-82dd-44e7-b105-6194e046eb8d', as = "table") ds_search(resource_id = '8f0784a6-82dd-44e7-b105-6194e046eb8d', as = "json") ds_search(resource_id = '8f0784a6-82dd-44e7-b105-6194e046eb8d', limit = 1, as = "table") ds_search(resource_id = '8f0784a6-82dd-44e7-b105-6194e046eb8d', q = "a*") ## End(Not run)
Datastore - search or get a dataset from CKAN datastore
ds_search_sql( sql, url = get_default_url(), key = get_default_key(), as = "list", ... )
ds_search_sql( sql, url = get_default_url(), key = get_default_key(), as = "list", ... )
sql |
(character) A single SQL select statement. (required) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: url <- 'https://demo.ckan.org/' sql <- 'SELECT * from "f4129802-22aa-4437-b9f9-8a8f3b7b2a53" LIMIT 2' ds_search_sql(sql, url = url, as = "table") sql2 <- 'SELECT "Species","Genus","Family" from "f4129802-22aa-4437-b9f9-8a8f3b7b2a53" LIMIT 2' ds_search_sql(sql2, url = url, as = "table") ## End(Not run)
## Not run: url <- 'https://demo.ckan.org/' sql <- 'SELECT * from "f4129802-22aa-4437-b9f9-8a8f3b7b2a53" LIMIT 2' ds_search_sql(sql, url = url, as = "table") sql2 <- 'SELECT "Species","Genus","Family" from "f4129802-22aa-4437-b9f9-8a8f3b7b2a53" LIMIT 2' ds_search_sql(sql2, url = url, as = "table") ## End(Not run)
Create a group
group_create( name = NULL, id = NULL, title = NULL, description = NULL, image_url = NULL, type = NULL, state = "active", approval_status = NULL, extras = NULL, packages = NULL, groups = NULL, users = NULL, url = get_default_url(), key = get_default_key(), as = "list", ... )
group_create( name = NULL, id = NULL, title = NULL, description = NULL, image_url = NULL, type = NULL, state = "active", approval_status = NULL, extras = NULL, packages = NULL, groups = NULL, users = NULL, url = get_default_url(), key = get_default_key(), as = "list", ... )
name |
(character) the name of the new dataset, must be between 2 and 100 characters long and contain only lowercase alphanumeric characters,
|
id |
(character) The id of the group (optional) |
title |
(character) The title of the dataset (optional, default: same as name) |
description |
(character) The description of the group (optional) |
image_url |
(character) The URL to an image to be displayed on the group's page (optional) |
type |
(character) The type of the dataset (optional), IDatasetForm plugins associate themselves with different dataset types and provide custom dataset handling behaviour for these types |
state |
(character) The current state of the dataset, e.g. 'active' or 'deleted', only active datasets show up in search results and other lists of datasets, this parameter will be ignored if you are not authorized to change the state of the dataset (optional, default: 'active') |
approval_status |
(character) Approval status (optional) |
extras |
(list of dataset extra dictionaries) The dataset's extras (optional), extras are arbitrary (key: value) metadata items that can be added to datasets, each extra dictionary should have keys 'key' (a string), 'value' (a string) |
packages |
(data.frame) The datasets (packages) that belong to the group, a data.frame, where each row has column 'name' (string, the id or name of the dataset) and optionally 'title' (string, the title of the dataset) |
groups |
(data.frame) The groups to which the dataset
belongs (optional), each data.frame row should have one or more of the
following columns which identify an existing group: 'id' (the id of the group,
string), or 'name' (the name of the group, string), to see which groups
exist call |
users |
(list of dictionaries) The users that belong to the group, a list of dictionaries each with key 'name' (string, the id or name of the user) and optionally 'capacity' (string, the capacity in which the user is a member of the group) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org", key = getOption("ckan_demo_key")) # create a group (res <- group_create("fruitloops2", description="A group about fruitloops")) res$users res$num_followers ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org", key = getOption("ckan_demo_key")) # create a group (res <- group_create("fruitloops2", description="A group about fruitloops")) res$users res$num_followers ## End(Not run)
Delete a group
group_delete(id, url = get_default_url(), key = get_default_key(), ...)
group_delete(id, url = get_default_url(), key = get_default_key(), ...)
id |
(character) The id of the group. Required. |
url |
Base url to use. Default: https://data.ontario.ca
See also |
key |
A privileged CKAN API key, Default: your key set with
|
... |
Curl args passed on to crul::verb-POST (optional) |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org", key = getOption("ckan_demo_key")) # create a group (res <- group_create("lions", description="A group about lions")) # show the group group_show(res$id) # delete the group group_delete(res) ## or with it's id # group_delete(res$id) ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org", key = getOption("ckan_demo_key")) # create a group (res <- group_create("lions", description="A group about lions")) # show the group group_show(res$id) # delete the group group_delete(res) ## or with it's id # group_delete(res$id) ## End(Not run)
List groups.
group_list( offset = 0, limit = 31, sort = NULL, groups = NULL, all_fields = FALSE, url = get_default_url(), key = get_default_key(), as = "list", ... )
group_list( offset = 0, limit = 31, sort = NULL, groups = NULL, all_fields = FALSE, url = get_default_url(), key = get_default_key(), as = "list", ... )
offset |
(numeric) Where to start getting activity items from (optional, default: 0) |
limit |
(numeric) The maximum number of activities to return (optional, default: 31) |
sort |
Field to sort on. You can specify ascending (e.g., score desc) or descending (e.g., score asc), sort by two fields (e.g., score desc, price asc), or sort by a function (e.g., sum(x_f, y_f) desc, which sorts by the sum of x_f and y_f in a descending order). |
groups |
(character) A list of names of the groups to return, if given only groups whose names are in this list will be returned |
all_fields |
(logical) Return full group dictionaries instead of just
names. Default: |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: group_list(limit = 3) group_list(limit = 3, as = 'json') group_list(limit = 3, as = 'table') ## End(Not run)
## Not run: group_list(limit = 3) group_list(limit = 3, as = 'json') group_list(limit = 3, as = 'table') ## End(Not run)
Update a group's metadata
group_patch( x, id, url = get_default_url(), key = get_default_key(), as = "list", ... )
group_patch( x, id, url = get_default_url(), key = get_default_key(), as = "list", ... )
x |
(list) A list with key-value pairs |
id |
(character) Resource ID to update (required) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org", key = getOption("ckan_demo_key")) # Create a package (res <- group_create("hello-my-world2")) # Get a resource grp <- group_show(res$id) grp$title grp$author_email # Make some changes x <- list(title = "!hello world!", maintainer_email = "[email protected]") group_patch(x, id = grp) ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org", key = getOption("ckan_demo_key")) # Create a package (res <- group_create("hello-my-world2")) # Get a resource grp <- group_show(res$id) grp$title grp$author_email # Make some changes x <- list(title = "!hello world!", maintainer_email = "[email protected]") group_patch(x, id = grp) ## End(Not run)
Show a package
group_show( id, include_datasets = TRUE, url = get_default_url(), key = get_default_key(), as = "list", ... )
group_show( id, include_datasets = TRUE, url = get_default_url(), key = get_default_key(), as = "list", ... )
id |
(character) Package identifier. |
include_datasets |
(logical) Include a list of the group's datasets.
Default: |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
By default the help and success slots are dropped, and only the
result slot is returned. You can request raw json with as = 'json'
then parse yourself to get the help slot.
## Not run: res <- group_list() # via a group name/id group_show(res[[1]]$name) # or via an object of class ckan_group group_show(res[[1]]) # return different data formats group_show(res[[1]]$name, as = 'json') group_show(res[[1]]$name, as = 'table') ## End(Not run)
## Not run: res <- group_list() # via a group name/id group_show(res[[1]]$name) # or via an object of class ckan_group group_show(res[[1]]) # return different data formats group_show(res[[1]]$name, as = 'json') group_show(res[[1]]$name, as = 'table') ## End(Not run)
Update a group
group_update( x, id, url = get_default_url(), key = get_default_key(), as = "list", ... )
group_update( x, id, url = get_default_url(), key = get_default_key(), as = "list", ... )
x |
(list) A list with key-value pairs |
id |
(character) Package identifier |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # First, create a group grp <- group_create("water-bears2") group_show(grp) ## update just chosen things # Make some changes x <- list(description = "A group about water bears and people that love them") # Then update the packge group_update(x, id = grp) ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # First, create a group grp <- group_create("water-bears2") group_show(grp) ## update just chosen things # Make some changes x <- list(description = "A group about water bears and people that love them") # Then update the packge group_update(x, id = grp) ## End(Not run)
Return the list of licenses available for datasets on the site.
license_list( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
license_list( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
id |
(character) Package identifier. |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: license_list() license_list(as = "table") license_list(as = "json") ## End(Not run)
## Not run: license_list() license_list(as = "table") license_list(as = "json") ## End(Not run)
Create an organization
organization_create( name = NULL, id = NULL, title = NULL, description = NULL, image_url = NULL, state = "active", approval_status = NULL, extras = NULL, packages = NULL, users = NULL, url = get_default_url(), key = get_default_key(), as = "list", ... )
organization_create( name = NULL, id = NULL, title = NULL, description = NULL, image_url = NULL, state = "active", approval_status = NULL, extras = NULL, packages = NULL, users = NULL, url = get_default_url(), key = get_default_key(), as = "list", ... )
name |
(character) the name of the organization, a string between 2 and 100 characters long, containing only lowercase alphanumeric characters,
|
id |
the id of the organization (optional) |
title |
(character) the title of the organization (optional) |
description |
(character) the description of the organization (optional) |
image_url |
(character) the URL to an image to be displayed on the organization's page (optional) |
state |
(character) the current state of the organization, e.g. 'active' or 'deleted', only active organization show up in search results and other lists of organization, this parameter will be ignored if you are not authorized to change the state of the organization (optional). Default: 'active' |
approval_status |
(character) Approval status |
extras |
The organization's extras (optional), extras are arbitrary
(key: value) metadata items that can be added to organizations, each extra
dictionary should have keys 'key' (a string), 'value' (a string)
|
packages |
(list of dictionaries) the datasets (packages) that belong to the organization, a list of dictionaries each with keys 'name' (string, the id or name of the dataset) and optionally 'title' (string, the title of the dataset) |
users |
(character) the users that belong to the organization, a list of dictionaries each with key 'name' (string, the id or name of the user) and optionally 'capacity' (string, the capacity in which the user is a member of the organization) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # create an organization (res <- organization_create("foobar", title = "Foo bars", description = "love foo bars")) res$name ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # create an organization (res <- organization_create("foobar", title = "Foo bars", description = "love foo bars")) res$name ## End(Not run)
Delete an organization
organization_delete( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
organization_delete( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
id |
(character) name or id of the organization |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
an empty list on success
## Not run: ckanr_setup(url = "https://demo.ckan.org", key=getOption("ckan_demo_key")) # create an organization (res <- organization_create("foobar", title = "Foo bars", description = "love foo bars")) # delete the organization just created res$id organization_delete(id = res$id) ## End(Not run)
## Not run: ckanr_setup(url = "https://demo.ckan.org", key=getOption("ckan_demo_key")) # create an organization (res <- organization_create("foobar", title = "Foo bars", description = "love foo bars")) # delete the organization just created res$id organization_delete(id = res$id) ## End(Not run)
List organization
organization_list( order_by = c("name", "package"), decreasing = FALSE, organizations = NULL, all_fields = TRUE, limit = 31, url = get_default_url(), key = get_default_key(), as = "list", ... )
organization_list( order_by = c("name", "package"), decreasing = FALSE, organizations = NULL, all_fields = TRUE, limit = 31, url = get_default_url(), key = get_default_key(), as = "list", ... )
order_by |
(character, only the first element is used).
The field to sort the list by, must be |
decreasing |
(logical). Is the sort-order is decreasing or not. |
organizations |
(character or |
all_fields |
(logical). Return the name or all fields of the object. |
limit |
(numeric) The maximum number of organizations to return (optional, default: 31) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: ckanr_setup(url = "https://demo.ckan.org/") # list organizations res <- organization_list() res[1:2] # Different data formats organization_list(as = 'json') organization_list(as = 'table') ## End(Not run)
## Not run: ckanr_setup(url = "https://demo.ckan.org/") # list organizations res <- organization_list() res[1:2] # Different data formats organization_list(as = 'json') organization_list(as = 'table') ## End(Not run)
IMPORTANT: You must be a sysadmin to purge an organization. Once an organization is purged, it is permanently removed from the system.
organization_purge( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
organization_purge( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
id |
(character) name or id of the organization |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
an empty list on success
## Not run: ckanr_setup(url = "https://demo.ckan.org", key=getOption("ckan_demo_key")) # create an organization (res <- organization_create("foobar", title = "Foo bars", description = "love foo bars")) # delete the organization just created res$id organization_delete(id = res$id) # purge the organization just deleted res$id organization_purge(id = res$id) ## End(Not run)
## Not run: ckanr_setup(url = "https://demo.ckan.org", key=getOption("ckan_demo_key")) # create an organization (res <- organization_create("foobar", title = "Foo bars", description = "love foo bars")) # delete the organization just created res$id organization_delete(id = res$id) # purge the organization just deleted res$id organization_purge(id = res$id) ## End(Not run)
Show an organization
organization_show( id, include_datasets = FALSE, url = get_default_url(), key = get_default_key(), as = "list", ... )
organization_show( id, include_datasets = FALSE, url = get_default_url(), key = get_default_key(), as = "list", ... )
id |
(character) Organization id or name. |
include_datasets |
(logical). Whether to include a list of the organization datasets |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
By default the help and success slots are dropped, and only the
result slot is returned. You can request raw json with as = 'json'
then parse yourself to get the help slot.
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) res <- organization_create("stuffthings2") organization_show(res$id) ## End(Not run)
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) res <- organization_create("stuffthings2") organization_show(res$id) ## End(Not run)
Return a list of the package's activity
package_activity_list( id, offset = 0, limit = 31, url = get_default_url(), key = get_default_key(), as = "list", ... )
package_activity_list( id, offset = 0, limit = 31, url = get_default_url(), key = get_default_key(), as = "list", ... )
id |
(character) Package identifier. |
offset |
(numeric) Where to start getting activity items from (optional, default: 0) |
limit |
(numeric) The maximum number of activities to return (optional, default: 31) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # create a package (res <- package_create("owls64")) # list package activity package_activity_list(res$id) # make a change x <- list(maintainer = "Jane Forest") package_update(x, res) # list activity again package_activity_list(res) # output different data formats package_activity_list(res$id, as = "table") package_activity_list(res$id, as = "json") ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # create a package (res <- package_create("owls64")) # list package activity package_activity_list(res$id) # make a change x <- list(maintainer = "Jane Forest") package_update(x, res) # list activity again package_activity_list(res) # output different data formats package_activity_list(res$id, as = "table") package_activity_list(res$id, as = "json") ## End(Not run)
Create a package
package_create( name = NULL, title = NULL, private = FALSE, author = NULL, author_email = NULL, maintainer = NULL, maintainer_email = NULL, license_id = NULL, notes = NULL, package_url = NULL, version = NULL, state = "active", type = NULL, resources = NULL, tags = NULL, extras = NULL, relationships_as_object = NULL, relationships_as_subject = NULL, groups = NULL, owner_org = NULL, url = get_default_url(), key = get_default_key(), as = "list", ... )
package_create( name = NULL, title = NULL, private = FALSE, author = NULL, author_email = NULL, maintainer = NULL, maintainer_email = NULL, license_id = NULL, notes = NULL, package_url = NULL, version = NULL, state = "active", type = NULL, resources = NULL, tags = NULL, extras = NULL, relationships_as_object = NULL, relationships_as_subject = NULL, groups = NULL, owner_org = NULL, url = get_default_url(), key = get_default_key(), as = "list", ... )
name |
(character) the name of the new dataset, must be between 2 and 100 characters long and contain only lowercase alphanumeric characters, - and _, e.g. 'warandpeace' |
title |
(character) the title of the dataset (optional, default: same as name) |
private |
(logical) whether the dataset should be private (optional,
default: |
author |
(character) the name of the dataset's author (optional) |
author_email |
(character) the email address of the dataset's author (optional) |
maintainer |
(character) the name of the dataset's maintainer (optional) |
maintainer_email |
(character) the email address of the dataset's maintainer (optional) |
license_id |
(license id string) - the id of the dataset's license, see license_list() for available values (optional) |
notes |
(character) a description of the dataset (optional) |
package_url |
(character) a URL for the dataset's source (optional) |
version |
(string, no longer than 100 characters) - (optional) |
state |
(character) the current state of the dataset, e.g. 'active' or 'deleted', only active datasets show up in search results and other lists of datasets, this parameter will be ignored if you are not authorized to change the state of the dataset (optional, default: 'active') |
type |
(character) the type of the dataset (optional), IDatasetForm plugins associate themselves with different dataset types and provide custom dataset handling behaviour for these types |
resources |
(list of resource dictionaries) - the dataset's resources,
see |
tags |
(list of tag dictionaries) - the dataset's tags, see
|
extras |
(list of dataset extra dictionaries) - the dataset's extras (optional), extras are arbitrary (key: value) metadata items that can be added to datasets, each extra dictionary should have keys 'key' (a string), 'value' (a string) |
relationships_as_object |
(list of relationship dictionaries) - see
|
relationships_as_subject |
(list of relationship dictionaries) - see
|
groups |
(data.frame) the groups to which the dataset
belongs, each row should have one or more of the
following columns which identify an existing group: 'id' (the id of the group,
string), or 'name' (the name of the group, string), to see which groups
exist call |
owner_org |
(character) the id of the dataset's owning organization,
see |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # create a package ## Example 1 (res <- package_create("foobar4", author="Jane Doe")) res$author ## Example 2 - create package, add a resource (res <- package_create("helloworld", author="Jane DOe")) # include a group # package_create("brownbear", groups = data.frame(id = "some-id")) ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # create a package ## Example 1 (res <- package_create("foobar4", author="Jane Doe")) res$author ## Example 2 - create package, add a resource (res <- package_create("helloworld", author="Jane DOe")) # include a group # package_create("brownbear", groups = data.frame(id = "some-id")) ## End(Not run)
Delete a package
package_delete(id, url = get_default_url(), key = get_default_key(), ...)
package_delete(id, url = get_default_url(), key = get_default_key(), ...)
id |
(character) The id of the package. Required. |
url |
Base url to use. Default: https://data.ontario.ca
See also |
key |
A privileged CKAN API key, Default: your key set with
|
... |
Curl args passed on to crul::verb-POST (optional) |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org", key = getOption("ckan_demo_key")) # create a package (res <- package_create("lions-bears-tigers")) # show the package package_show(res) # delete the package package_delete(res) ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org", key = getOption("ckan_demo_key")) # create a package (res <- package_create("lions-bears-tigers")) # show the package package_show(res) # delete the package package_delete(res) ## End(Not run)
List datasets.
package_list( offset = 0, limit = 31, url = get_default_url(), key = get_default_key(), as = "list", ... )
package_list( offset = 0, limit = 31, url = get_default_url(), key = get_default_key(), as = "list", ... )
offset |
(numeric) Where to start getting activity items from (optional, default: 0) |
limit |
(numeric) The maximum number of activities to return (optional, default: 31) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: package_list() package_list(as = 'json') package_list(as = 'table') package_list(url = 'https://data.nhm.ac.uk') ## End(Not run)
## Not run: package_list() package_list(as = 'json') package_list(as = 'table') package_list(url = 'https://data.nhm.ac.uk') ## End(Not run)
List current packages with resources.
package_list_current( offset = 0, limit = 31, url = get_default_url(), key = get_default_key(), as = "list", ... )
package_list_current( offset = 0, limit = 31, url = get_default_url(), key = get_default_key(), as = "list", ... )
offset |
(numeric) Where to start getting activity items from (optional, default: 0) |
limit |
(numeric) The maximum number of activities to return (optional, default: 31) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: package_list_current() package_list_current(as = 'json') package_list_current(as = 'table') ## End(Not run)
## Not run: package_list_current() package_list_current(as = 'json') package_list_current(as = 'table') ## End(Not run)
Update a package's metadata
package_patch( x, id = NULL, extras = NULL, http_method = "GET", key = get_default_key(), url = get_default_url(), as = "list", ... )
package_patch( x, id = NULL, extras = NULL, http_method = "GET", key = get_default_key(), url = get_default_url(), as = "list", ... )
x |
(list) A list with key-value pairs |
id |
(character) Resource ID to update (optional, required if x does not have an "id" field) |
extras |
(character vector) - the dataset's extras (optional), extras are arbitrary (key: value) metadata items that can be added to datasets, each extra dictionary should have keys 'key' (a string), 'value' (a string) |
http_method |
(character) which HTTP method (verb) to use; one of "GET" or "POST". Default: "GET" |
key |
A privileged CKAN API key, Default: your key set with
|
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org", key = getOption("ckan_demo_key")) # Create a package (res <- package_create("hello-world13", author="Jane Doe")) # Get a resource res <- package_show(res$id) res$title # patch package_patch(res, extras = list(list(key = "foo", value = "bar"))) unclass(package_show(res)) ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org", key = getOption("ckan_demo_key")) # Create a package (res <- package_create("hello-world13", author="Jane Doe")) # Get a resource res <- package_show(res$id) res$title # patch package_patch(res, extras = list(list(key = "foo", value = "bar"))) unclass(package_show(res)) ## End(Not run)
Return a dataset (package's) revisions as a list of dictionaries.
package_revision_list( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
package_revision_list( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
id |
(character) Package identifier. |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # create a package (res <- package_create("dolphins")) # list package revisions package_revision_list(res$id) # Make change to the package x <- list(title = "dolphins and things") package_patch(x, id = res$id) # list package revisions package_revision_list(res$id) # Output different formats package_revision_list(res$id, as = "table") package_revision_list(res$id, as = "json") ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # create a package (res <- package_create("dolphins")) # list package revisions package_revision_list(res$id) # Make change to the package x <- list(title = "dolphins and things") package_patch(x, id = res$id) # list package revisions package_revision_list(res$id) # Output different formats package_revision_list(res$id, as = "table") package_revision_list(res$id, as = "json") ## End(Not run)
Search for packages.
package_search( q = "*:*", fq = NULL, sort = NULL, rows = NULL, start = NULL, facet = FALSE, facet.limit = NULL, facet.field = NULL, facet.mincount = NULL, include_drafts = FALSE, include_private = FALSE, use_default_schema = FALSE, url = get_default_url(), key = get_default_key(), as = "list", ... )
package_search( q = "*:*", fq = NULL, sort = NULL, rows = NULL, start = NULL, facet = FALSE, facet.limit = NULL, facet.field = NULL, facet.mincount = NULL, include_drafts = FALSE, include_private = FALSE, use_default_schema = FALSE, url = get_default_url(), key = get_default_key(), as = "list", ... )
q |
Query terms, defaults to ':', or everything. |
fq |
Filter query, this does not affect the search, only what gets returned |
sort |
Field to sort on. You can specify ascending (e.g., score desc) or descending (e.g., score asc), sort by two fields (e.g., score desc, price asc), or sort by a function (e.g., sum(x_f, y_f) desc, which sorts by the sum of x_f and y_f in a descending order). |
rows |
Number of records to return. Defaults to 10. |
start |
Record to start at, default to beginning. |
facet |
(logical) Whether to return facet results or not.
Default: |
facet.limit |
(numeric) This param indicates the maximum number of constraint counts that should be returned for the facet fields. A negative value means unlimited. Default: 100. Can be specified on a per field basis. |
facet.field |
(character) This param allows you to specify a field which should be treated as a facet. It will iterate over each Term in the field and generate a facet count using that Term as the constraint. This parameter can be specified multiple times to indicate multiple facet fields. None of the other params in this section will have any effect without specifying at least one field name using this param. |
facet.mincount |
(integer) the minimum counts for facet fields should be included in the results |
include_drafts |
(logical) if |
include_private |
(logical) if |
use_default_schema |
(logical) use default package schema instead of a
custom schema defined with an IDatasetForm plugin. default: |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: ckanr_setup(url = "https://demo.ckan.org", key=getOption("ckan_demo_key")) package_search(q = '*:*') package_search(q = '*:*', rows = 2, as = 'json') package_search(q = '*:*', rows = 2, as = 'table') package_search(q = '*:*', sort = 'score asc') package_search(q = '*:*', fq = 'num_tags:[3 TO *]')$count package_search(q = '*:*', fq = 'num_tags:[2 TO *]')$count package_search(q = '*:*', fq = 'num_tags:[1 TO *]')$count ## End(Not run)
## Not run: ckanr_setup(url = "https://demo.ckan.org", key=getOption("ckan_demo_key")) package_search(q = '*:*') package_search(q = '*:*', rows = 2, as = 'json') package_search(q = '*:*', rows = 2, as = 'table') package_search(q = '*:*', sort = 'score asc') package_search(q = '*:*', fq = 'num_tags:[3 TO *]')$count package_search(q = '*:*', fq = 'num_tags:[2 TO *]')$count package_search(q = '*:*', fq = 'num_tags:[1 TO *]')$count ## End(Not run)
Show a package.
package_show( id, use_default_schema = FALSE, http_method = "GET", url = get_default_url(), key = get_default_key(), as = "list", ... )
package_show( id, use_default_schema = FALSE, http_method = "GET", url = get_default_url(), key = get_default_key(), as = "list", ... )
id |
(character/ckan_package) Package identifier, or a |
use_default_schema |
(logical) Use default package schema instead of a
custom schema defined with an IDatasetForm plugin. Default: |
http_method |
(character) which HTTP method (verb) to use; one of "GET" or "POST". Default: "GET" |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
By default the help and success slots are dropped, and only the
result slot is returned. You can request raw json with as = 'json'
then parse yourself to get the help slot.
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # create a package (res <- package_create("purposeful55")) # show package ## From the output of package_create package_show(res) ## Or, from the ID package_show(res$id) # get data back in different formats package_show(res$id, as = 'json') package_show(res$id, as = 'table') # use default schema or not package_show(res$id, TRUE) ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # create a package (res <- package_create("purposeful55")) # show package ## From the output of package_create package_show(res) ## Or, from the ID package_show(res$id) # get data back in different formats package_show(res$id, as = 'json') package_show(res$id, as = 'table') # use default schema or not package_show(res$id, TRUE) ## End(Not run)
Update a package
package_update( x, id, http_method = "GET", url = get_default_url(), key = get_default_key(), as = "list", ... )
package_update( x, id, http_method = "GET", url = get_default_url(), key = get_default_key(), as = "list", ... )
x |
(list) A list with key-value pairs |
id |
(character) Package identifier |
http_method |
(character) which HTTP method (verb) to use; one of "GET" or "POST". Default: "GET" |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # Create a package (pkg <- package_create("hello-world11", author="Jane Doe")) # Next show the package to see the fields (res <- package_show(pkg$id)) ## update just chosen things # Make some changes x <- list(maintainer_email = "[email protected]") # Then update the packge package_update(x, pkg$id) ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # Create a package (pkg <- package_create("hello-world11", author="Jane Doe")) # Next show the package to see the fields (res <- package_show(pkg$id)) ## update just chosen things # Make some changes x <- list(maintainer_email = "[email protected]") # Then update the packge package_update(x, pkg$id) ## End(Not run)
Ping a CKAN server to test that it's up or down.
ping(url = get_default_url(), key = get_default_key(), as = "logical", ...)
ping(url = get_default_url(), key = get_default_key(), as = "logical", ...)
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: ping() ping(as = "json") ## End(Not run)
## Not run: ping() ping(as = "json") ## End(Not run)
Create a resource
resource_create( package_id = NULL, rcurl = NULL, revision_id = NULL, description = NULL, format = NULL, hash = NULL, name = NULL, resource_type = NULL, mimetype = NULL, mimetype_inner = NULL, webstore_url = NULL, cache_url = NULL, size = NULL, created = NULL, last_modified = NULL, cache_last_updated = NULL, webstore_last_updated = NULL, upload = NULL, extras = NULL, http_method = "GET", url = get_default_url(), key = get_default_key(), as = "list", ... )
resource_create( package_id = NULL, rcurl = NULL, revision_id = NULL, description = NULL, format = NULL, hash = NULL, name = NULL, resource_type = NULL, mimetype = NULL, mimetype_inner = NULL, webstore_url = NULL, cache_url = NULL, size = NULL, created = NULL, last_modified = NULL, cache_last_updated = NULL, webstore_last_updated = NULL, upload = NULL, extras = NULL, http_method = "GET", url = get_default_url(), key = get_default_key(), as = "list", ... )
package_id |
(character) id of package that the resource should be added to. This should be an alphanumeric string. Required. |
rcurl |
(character) url of resource. Required. |
revision_id |
(character) revision id (optional) |
description |
(character) description (optional). Required. |
format |
(character) format (optional) |
hash |
(character) hash (optional) |
name |
(character) name (optional). Required. |
resource_type |
(character) resource type (optional) |
mimetype |
(character) mime type (optional) |
mimetype_inner |
(character) mime type inner (optional) |
webstore_url |
(character) webstore url (optional) |
cache_url |
(character) cache url(optional) |
size |
(integer) size (optional) |
created |
(character) iso date string (optional) |
last_modified |
(character) iso date string (optional) |
cache_last_updated |
(character) iso date string (optional) |
webstore_last_updated |
(character) iso date string (optional) |
upload |
(character) A path to a local file (optional) |
extras |
(list) - the resources' extra metadata fields (optional) |
http_method |
(character) which HTTP method (verb) to use; one of "GET" or "POST". Default: "GET" |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # create a package (res <- package_create("foobarrrr", author="Jane Doe")) # then create a resource file <- system.file("examples", "actinidiaceae.csv", package = "ckanr") (xx <- resource_create(package_id = res$id, description = "my resource", name = "bears", upload = file, extras = list(species = "grizzly"), rcurl = "http://google.com" )) package_create("foobbbbbarrrr") %>% resource_create(description = "my resource", name = "bearsareus", upload = file, extras = list(my_extra = "some value"), rcurl = "http://google.com") ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # create a package (res <- package_create("foobarrrr", author="Jane Doe")) # then create a resource file <- system.file("examples", "actinidiaceae.csv", package = "ckanr") (xx <- resource_create(package_id = res$id, description = "my resource", name = "bears", upload = file, extras = list(species = "grizzly"), rcurl = "http://google.com" )) package_create("foobbbbbarrrr") %>% resource_create(description = "my resource", name = "bearsareus", upload = file, extras = list(my_extra = "some value"), rcurl = "http://google.com") ## End(Not run)
Delete a resource.
resource_delete(id, url = get_default_url(), key = get_default_key(), ...)
resource_delete(id, url = get_default_url(), key = get_default_key(), ...)
id |
(character) Resource identifier. |
url |
Base url to use. Default: https://data.ontario.ca
See also |
key |
A privileged CKAN API key, Default: your key set with
|
... |
Curl args passed on to crul::verb-POST (optional) |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = Sys.getenv("CKAN_DEMO_KEY")) # create a package (res <- package_create("yellow9")) # then create a resource file <- system.file("examples", "actinidiaceae.csv", package = "ckanr") (xx <- resource_create(res, description = "my resource", name = "bears", upload = file, rcurl = "http://google.com" )) # delete the resource resource_delete(xx) ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = Sys.getenv("CKAN_DEMO_KEY")) # create a package (res <- package_create("yellow9")) # then create a resource file <- system.file("examples", "actinidiaceae.csv", package = "ckanr") (xx <- resource_create(res, description = "my resource", name = "bears", upload = file, rcurl = "http://google.com" )) # delete the resource resource_delete(xx) ## End(Not run)
Update a resource's metadata
resource_patch( x, id, url = get_default_url(), key = get_default_key(), as = "list", ... )
resource_patch( x, id, url = get_default_url(), key = get_default_key(), as = "list", ... )
x |
(list) A list with key-value pairs |
id |
(character) Resource ID to update (required) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org", key = getOption("ckan_demo_key")) # create a package (res <- package_create("twist", author="Alexandria")) # then create a resource file <- system.file("examples", "actinidiaceae.csv", package = "ckanr") (xx <- resource_create(package_id = res$id, description = "my resource")) # Get a resource res <- resource_show(xx$id) res$description # Make some changes x <- list(description = "My newer description") z <- resource_patch(x, id = res) z$description # Add an extra key:value pair extra <- list("extra_key" = "my special value") zz <- resource_patch(extra, id = res) zz$extra_key ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org", key = getOption("ckan_demo_key")) # create a package (res <- package_create("twist", author="Alexandria")) # then create a resource file <- system.file("examples", "actinidiaceae.csv", package = "ckanr") (xx <- resource_create(package_id = res$id, description = "my resource")) # Get a resource res <- resource_show(xx$id) res$description # Make some changes x <- list(description = "My newer description") z <- resource_patch(x, id = res) z$description # Add an extra key:value pair extra <- list("extra_key" = "my special value") zz <- resource_patch(extra, id = res) zz$extra_key ## End(Not run)
Search for resources.
resource_search( q, sort = NULL, offset = NULL, limit = NULL, url = get_default_url(), key = get_default_key(), as = "list", ... )
resource_search( q, sort = NULL, offset = NULL, limit = NULL, url = get_default_url(), key = get_default_key(), as = "list", ... )
q |
Query terms. It is a string of the form |
sort |
Field to sort on. You can specify ascending (e.g., score desc) or descending (e.g., score asc), sort by two fields (e.g., score desc, price asc), or sort by a function (e.g., sum(x_f, y_f) desc, which sorts by the sum of x_f and y_f in a descending order). |
offset |
Record to start at, default to beginning. |
limit |
Number of records to return. |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: resource_search(q = 'name:data') resource_search(q = 'name:data', as = 'json') resource_search(q = 'name:data', as = 'table') resource_search(q = 'name:data', limit = 2, as = 'table') resource_search(q=c("description:encoded", "name:No.2"),url='demo.ckan.org') ## End(Not run)
## Not run: resource_search(q = 'name:data') resource_search(q = 'name:data', as = 'json') resource_search(q = 'name:data', as = 'table') resource_search(q = 'name:data', limit = 2, as = 'table') resource_search(q=c("description:encoded", "name:No.2"),url='demo.ckan.org') ## End(Not run)
Show a resource.
resource_show( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
resource_show( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
id |
(character) Resource identifier. |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = Sys.getenv("CKAN_DEMO_KEY")) # create a package (res <- package_create("yellow7")) # then create a resource file <- system.file("examples", "actinidiaceae.csv", package = "ckanr") (xx <- resource_create(package_id = res$id, description = "my resource", name = "bears", upload = file, rcurl = "http://google.com" )) # show the resource resource_show(xx$id) # eg. from the NHM CKAN store resource_show(id = "05ff2255-c38a-40c9-b657-4ccb55ab2feb", url = "http://data.nhm.ac.uk") ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = Sys.getenv("CKAN_DEMO_KEY")) # create a package (res <- package_create("yellow7")) # then create a resource file <- system.file("examples", "actinidiaceae.csv", package = "ckanr") (xx <- resource_create(package_id = res$id, description = "my resource", name = "bears", upload = file, rcurl = "http://google.com" )) # show the resource resource_show(xx$id) # eg. from the NHM CKAN store resource_show(id = "05ff2255-c38a-40c9-b657-4ccb55ab2feb", url = "http://data.nhm.ac.uk") ## End(Not run)
This function can be used to update a resource's file attachment and "extra" metadata fields. Any update will also set the metadata key "last_updated". Other metadata, such as name or description, are not updated.
The new file must exist on a local path. R objects have to be written to a
file, e.g. using tempfile()
- see example.
For convenience, CKAN base url and API key default to the global options,
which are set by ckanr_setup
.
resource_update( id, path = NULL, extras = list(), url = get_default_url(), key = get_default_key(), as = "list", ... )
resource_update( id, path = NULL, extras = list(), url = get_default_url(), key = get_default_key(), as = "list", ... )
id |
(character) Resource ID to update (required) |
path |
(character) Local path of the file to upload (optional) |
extras |
(list) - the resources' extra metadata fields (optional) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
The HTTP response from CKAN, formatted as list (default), table, or JSON.
http://docs.ckan.org/en/latest/api/index.html#ckan.logic.action.create.resource_create
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # Get file path <- system.file("examples", "actinidiaceae.csv", package = "ckanr") # Create package, then a resource within that package (res <- package_create("newpackage10")) (xx <- resource_create(package_id = res$id, description = "my resource", name = "bears", upload = path, rcurl = "http://google.com" )) # Modify dataset, here lowercase strings in one column dat <- read.csv(path, stringsAsFactors = FALSE) dat$Family <- tolower(dat$Family) newpath <- tempfile(fileext = ".csv") write.csv(dat, file = newpath, row.names = FALSE) # Upload modified dataset ## Directly from output of resource_create resource_update(xx, path=newpath) ## or from the resource id resource_update(xx$id, path=newpath) ## optionally include extra tags resource_update(xx$id, path=newpath, extras = list(some="metadata")) # Update a resource's extra tags ## add extra tags without uploading a new file resource_update(id, extras = list(some="metadata")) ## or remove all extra tags resource_update(id, extras = list()) ####### # Using default settings ckanr_setup(url = "http://demo.ckan.org/", key = "my-demo-ckan-org-api-key") path <- system.file("examples", "actinidiaceae.csv", package = "ckanr") resource_update(id="an-existing-resource-id", path = path) # Using an R object written to a tempfile, and implicit CKAN URL and API key write.csv(data <- installed.packages(), path <- tempfile(fileext = ".csv")) ckanr_setup(url = "http://demo.ckan.org/", key = "my-demo-ckan-org-api-key") resource_update(id="an-existing-resource-id", path = path) # Testing: see ?ckanr_setup to set default test CKAN url, key, package id ckanr_setup(test_url = "http://my-ckan.org/", test_key = "my-ckan-api-key", test_did = "an-existing-package-id", test_rid = "an-existing-resource-id") resource_update(id = get_test_rid(), path = system.file("examples", "actinidiaceae.csv", package = "ckanr"), key = get_test_key(), url = get_test_url()) # other file formats ## html path <- system.file("examples", "mapbox.html", package = "ckanr") # Create package, then a resource within that package (res <- package_create("mappkg")) (xx <- resource_create(package_id = res$id, description = "a map, yay", name = "mapyay", upload = path, rcurl = "http://google.com" )) browseURL(xx$url) # Modify dataset, here lowercase strings in one column dat <- readLines(path) dat <- sub("-111.06", "-115.06", dat) newpath <- tempfile(fileext = ".html") cat(dat, file = newpath, sep = "\n") # Upload modified dataset ## Directly from output of resource_create (xxx <- resource_update(xx, path=newpath)) browseURL(xxx$url) ## End(Not run)
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # Get file path <- system.file("examples", "actinidiaceae.csv", package = "ckanr") # Create package, then a resource within that package (res <- package_create("newpackage10")) (xx <- resource_create(package_id = res$id, description = "my resource", name = "bears", upload = path, rcurl = "http://google.com" )) # Modify dataset, here lowercase strings in one column dat <- read.csv(path, stringsAsFactors = FALSE) dat$Family <- tolower(dat$Family) newpath <- tempfile(fileext = ".csv") write.csv(dat, file = newpath, row.names = FALSE) # Upload modified dataset ## Directly from output of resource_create resource_update(xx, path=newpath) ## or from the resource id resource_update(xx$id, path=newpath) ## optionally include extra tags resource_update(xx$id, path=newpath, extras = list(some="metadata")) # Update a resource's extra tags ## add extra tags without uploading a new file resource_update(id, extras = list(some="metadata")) ## or remove all extra tags resource_update(id, extras = list()) ####### # Using default settings ckanr_setup(url = "http://demo.ckan.org/", key = "my-demo-ckan-org-api-key") path <- system.file("examples", "actinidiaceae.csv", package = "ckanr") resource_update(id="an-existing-resource-id", path = path) # Using an R object written to a tempfile, and implicit CKAN URL and API key write.csv(data <- installed.packages(), path <- tempfile(fileext = ".csv")) ckanr_setup(url = "http://demo.ckan.org/", key = "my-demo-ckan-org-api-key") resource_update(id="an-existing-resource-id", path = path) # Testing: see ?ckanr_setup to set default test CKAN url, key, package id ckanr_setup(test_url = "http://my-ckan.org/", test_key = "my-ckan-api-key", test_did = "an-existing-package-id", test_rid = "an-existing-resource-id") resource_update(id = get_test_rid(), path = system.file("examples", "actinidiaceae.csv", package = "ckanr"), key = get_test_key(), url = get_test_url()) # other file formats ## html path <- system.file("examples", "mapbox.html", package = "ckanr") # Create package, then a resource within that package (res <- package_create("mappkg")) (xx <- resource_create(package_id = res$id, description = "a map, yay", name = "mapyay", upload = path, rcurl = "http://google.com" )) browseURL(xx$url) # Modify dataset, here lowercase strings in one column dat <- readLines(path) dat <- sub("-111.06", "-115.06", dat) newpath <- tempfile(fileext = ".html") cat(dat, file = newpath, sep = "\n") # Upload modified dataset ## Directly from output of resource_create (xxx <- resource_update(xx, path=newpath)) browseURL(xxx$url) ## End(Not run)
Return a list of the IDs of the site's revisions.
revision_list( url = get_default_url(), key = get_default_key(), as = "list", ... )
revision_list( url = get_default_url(), key = get_default_key(), as = "list", ... )
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: revision_list() revision_list(as = "table") revision_list(as = "json") ## End(Not run)
## Not run: revision_list() revision_list(as = "table") revision_list(as = "json") ## End(Not run)
CKAN server URLS and other info
servers()
servers()
Comes from the links at https://ckan.org/about/instances/
There were a number of other URLs for CKAN instances in the CKAN URL above, but some sites are now gone completely, or if they do exist, I can't figure out how to get access to the CKAN API on their instance.
## Not run: servers() ckan_info(servers()[5]) # what version is each CKAN server running out <- lapply(servers()[1:6], function(w) { cat(w, sep='\n') ckan_info(w) }) vapply(out, "[[", "", "ckan_version") ## End(Not run)
## Not run: servers() ckan_info(servers()[5]) # what version is each CKAN server running out <- lapply(servers()[1:6], function(w) { cat(w, sep='\n') ckan_info(w) }) vapply(out, "[[", "", "ckan_version") ## End(Not run)
Use src_ckan
to connect to an existing CKAN instance and tbl
to
connect to tables within that CKAN based on the DataStore Data API.
src_ckan(url)
src_ckan(url)
url |
the url of the CKAN instance |
## Not run: library("dplyr") # To connect to a CKAN instance first create a src: my_ckan <- src_ckan("http://demo.ckan.org") # List all tables in the CKAN instance db_list_tables(my_ckan$con) # Then reference a tbl within that src my_tbl <- tbl(src = my_ckan, name = "44d7de5f-7029-4f3a-a812-d7a70895da7d") # You can use the dplyr verbs with my_tbl. For example: dplyr::filter(my_tbl, GABARITO == "C") ## End(Not run)
## Not run: library("dplyr") # To connect to a CKAN instance first create a src: my_ckan <- src_ckan("http://demo.ckan.org") # List all tables in the CKAN instance db_list_tables(my_ckan$con) # Then reference a tbl within that src my_tbl <- tbl(src = my_ckan, name = "44d7de5f-7029-4f3a-a812-d7a70895da7d") # You can use the dplyr verbs with my_tbl. For example: dplyr::filter(my_tbl, GABARITO == "C") ## End(Not run)
IMPORTANT: You must be a sysadmin to create vocabulary tags.
tag_create( name, vocabulary_id, url = get_default_url(), key = get_default_key(), as = "list", ... )
tag_create( name, vocabulary_id, url = get_default_url(), key = get_default_key(), as = "list", ... )
name |
(character) The name for the new tag, a string between 2 and 100 characters long containing only alphanumeric characters and -, _ and ., e.g. 'Jazz' |
vocabulary_id |
(character) The id of the vocabulary that the new tag should be added to, e.g. the id of vocabulary 'Genre' |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = Sys.getenv("CKAN_DEMO_KEY")) tag_create(name = "TestTag1", vocabulary_id = "Testing1") ## End(Not run)
## Not run: ckanr_setup(url = "https://demo.ckan.org/", key = Sys.getenv("CKAN_DEMO_KEY")) tag_create(name = "TestTag1", vocabulary_id = "Testing1") ## End(Not run)
List tags.
tag_list( query = NULL, vocabulary_id = NULL, all_fields = FALSE, url = get_default_url(), key = get_default_key(), as = "list", ... )
tag_list( query = NULL, vocabulary_id = NULL, all_fields = FALSE, url = get_default_url(), key = get_default_key(), as = "list", ... )
query |
(character) A tag name query to search for, if given only tags whose names contain this string will be returned |
vocabulary_id |
(character) The id or name of a vocabulary, if given, only tags that belong to this vocabulary will be returned |
all_fields |
(logical) Return full tag dictionaries instead of
just names. Default: |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # list all tags tag_list() # search for a specific tag tag_list(query = 'aviation') # all fields tag_list(all_fields = TRUE) # give back different data formats tag_list('aviation', as = 'json') tag_list('aviation', as = 'table') ## End(Not run)
## Not run: # list all tags tag_list() # search for a specific tag tag_list(query = 'aviation') # all fields tag_list(all_fields = TRUE) # give back different data formats tag_list('aviation', as = 'json') tag_list('aviation', as = 'table') ## End(Not run)
Search tags.
tag_search( query = NULL, vocabulary_id = NULL, offset = 0, limit = 31, url = get_default_url(), key = get_default_key(), as = "list", ... )
tag_search( query = NULL, vocabulary_id = NULL, offset = 0, limit = 31, url = get_default_url(), key = get_default_key(), as = "list", ... )
query |
(character) A tag name query to search for, if given only tags whose names contain this string will be returned; one or more search strings |
vocabulary_id |
(character) The id or name of a vocabulary, if give only tags that belong to this vocabulary will be returned |
offset |
(numeric) Where to start getting activity items from (optional, default: 0) |
limit |
(numeric) The maximum number of activities to return (optional, default: 31) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: tag_search(query = 'ta') tag_search(query = c('ta', 'al')) # different formats back tag_search(query = 'ta', as = 'json') tag_search(query = 'ta', as = 'table') ## End(Not run)
## Not run: tag_search(query = 'ta') tag_search(query = c('ta', 'al')) # different formats back tag_search(query = 'ta', as = 'json') tag_search(query = 'ta', as = 'table') ## End(Not run)
Show a tag.
tag_show( id, include_datasets = FALSE, url = get_default_url(), key = get_default_key(), as = "list", ... )
tag_show( id, include_datasets = FALSE, url = get_default_url(), key = get_default_key(), as = "list", ... )
id |
(character) The name or id of the tag |
include_datasets |
include a list of up to 1000 of the tag's datasets.
Limit 1000 datasets, use |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # get tags with tag_list() tags <- tag_list() tags[[30]]$id # show a tag (x <- tag_show(tags[[30]]$id)) # give back different data formats tag_show(tags[[30]]$id, as = 'json') tag_show(tags[[30]]$id, as = 'table') ## End(Not run)
## Not run: # get tags with tag_list() tags <- tag_list() tags[[30]]$id # show a tag (x <- tag_show(tags[[30]]$id)) # give back different data formats tag_show(tags[[30]]$id, as = 'json') tag_show(tags[[30]]$id, as = 'table') ## End(Not run)
Return a list of a user's activities
user_activity_list( id, offset = 0, limit = 31, url = get_default_url(), key = get_default_key(), as = "list", ... )
user_activity_list( id, offset = 0, limit = 31, url = get_default_url(), key = get_default_key(), as = "list", ... )
id |
(character) User identifier. |
offset |
(numeric) Where to start getting activity items from (optional, default: 0) |
limit |
(numeric) The maximum number of activities to return (optional, default: 31) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # list package activity user_activity_list('sckottie') # input a ckan_user object (x <- user_show('sckottie')) user_activity_list(x) # output different data formats user_activity_list(x, as = "table") user_activity_list(x, as = "json") ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # list package activity user_activity_list('sckottie') # input a ckan_user object (x <- user_show('sckottie')) user_activity_list(x) # output different data formats user_activity_list(x, as = "table") user_activity_list(x, as = "json") ## End(Not run)
Create a user.
user_create( name, email, password, id = NULL, fullname = NULL, about = NULL, openid = NULL, url = get_default_url(), key = get_default_key(), as = "list", ... )
user_create( name, email, password, id = NULL, fullname = NULL, about = NULL, openid = NULL, url = get_default_url(), key = get_default_key(), as = "list", ... )
name |
(character) the name of the new user, a string between 2 and 100 characters in length, containing only lowercase alphanumeric characters, - and _ (required) |
email |
(character) the email address for the new user (required) |
password |
(character) the password of the new user, a string of at least 4 characters (required) |
id |
(character) the id of the new user (optional) |
fullname |
(character) user full name |
about |
(character) a description of the new user (optional) |
openid |
(character) an openid (optional) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
http://docs.ckan.org/en/latest/api/index.html#ckan.logic.action.create.user_create
## Not run: # Setup ckanr_setup(url = "https://data-demo.dpaw.wa.gov.au", key = "824e7c50-9577-4bfa-bf32-246ebed1a8a2") # create a user user_create(name = 'stacy', email = "[email protected]", password = "helloworld") ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://data-demo.dpaw.wa.gov.au", key = "824e7c50-9577-4bfa-bf32-246ebed1a8a2") # create a user user_create(name = 'stacy', email = "[email protected]", password = "helloworld") ## End(Not run)
Delete a user.
user_delete( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
user_delete( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
id |
(character) the id of the new user (required) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
http://docs.ckan.org/en/latest/api/index.html#ckan.logic.action.delete.user_delete
## Not run: # Setup ckanr_setup(url = "https://data-demo.dpaw.wa.gov.au", key = "824e7c50-9577-4bfa-bf32-246ebed1a8a2") # create a user res <- user_delete(name = 'stacy', email = "[email protected]", password = "helloworld") # then, delete a user user_delete(id = "stacy") ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://data-demo.dpaw.wa.gov.au", key = "824e7c50-9577-4bfa-bf32-246ebed1a8a2") # create a user res <- user_delete(name = 'stacy', email = "[email protected]", password = "helloworld") # then, delete a user user_delete(id = "stacy") ## End(Not run)
Return a a user's follower count
user_followee_count( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
user_followee_count( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
id |
(character) User identifier. |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # list package activity user_followee_count('sckottie') # input a ckan_user object (x <- user_show('sckottie')) user_followee_count(x) # output different data formats user_followee_count(x, as = "table") user_followee_count(x, as = "json") ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # list package activity user_followee_count('sckottie') # input a ckan_user object (x <- user_show('sckottie')) user_followee_count(x) # output different data formats user_followee_count(x, as = "table") user_followee_count(x, as = "json") ## End(Not run)
Return a a user's follower count
user_follower_count( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
user_follower_count( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
id |
(character) User identifier. |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # list package activity user_follower_count('sckottie') # input a ckan_user object (x <- user_show('sckottie')) user_follower_count(x) # output different data formats user_follower_count(x, as = "table") user_follower_count(x, as = "json") ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # list package activity user_follower_count('sckottie') # input a ckan_user object (x <- user_show('sckottie')) user_follower_count(x) # output different data formats user_follower_count(x, as = "table") user_follower_count(x, as = "json") ## End(Not run)
Return a a user's follower count
user_follower_list( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
user_follower_list( id, url = get_default_url(), key = get_default_key(), as = "list", ... )
id |
(character) User identifier. |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # list package activity user_follower_list('sckottie') # input a ckan_user object (x <- user_show('sckottie')) user_follower_list(x) # output different data formats user_follower_list(x, as = "table") user_follower_list(x, as = "json") ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # list package activity user_follower_list('sckottie') # input a ckan_user object (x <- user_show('sckottie')) user_follower_list(x) # output different data formats user_follower_list(x, as = "table") user_follower_list(x, as = "json") ## End(Not run)
Return a list of the site's user accounts.
user_list( q = NULL, order_by = NULL, url = get_default_url(), key = get_default_key(), as = "list", ... )
user_list( q = NULL, order_by = NULL, url = get_default_url(), key = get_default_key(), as = "list", ... )
q |
(character) Restrict the users returned to those whose names contain a string |
order_by |
(character) Which field to sort the list by (optional, default: 'name') |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # all users user_list() # search for a user user_list(q = "j") # different data formats user_list(q = "j", as = "table") user_list(q = "j", as = "json") ## End(Not run)
## Not run: # all users user_list() # search for a user user_list(q = "j") # different data formats user_list(q = "j", as = "table") user_list(q = "j", as = "json") ## End(Not run)
Show a user.
user_show( id, user_obj = NULL, include_datasets = FALSE, include_num_followers = FALSE, url = get_default_url(), key = get_default_key(), as = "list", ... )
user_show( id, user_obj = NULL, include_datasets = FALSE, include_num_followers = FALSE, url = get_default_url(), key = get_default_key(), as = "list", ... )
id |
(character) Package identifier. |
user_obj |
(user dictionary) The user dictionary of the user (optional) |
include_datasets |
(logical) Include a list of datasets the user has created. If it is the same user or a sysadmin requesting, it includes datasets that are draft or private. (optional, default:False, limit:50) |
include_num_followers |
(logical) Include the number of followers the user has (optional, default:False) |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # show user user_show('sckottie') # include datasets user_show('sckottie', include_datasets = TRUE) # include datasets user_show('sckottie', include_num_followers = TRUE) ## End(Not run)
## Not run: # Setup ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # show user user_show('sckottie') # include datasets user_show('sckottie', include_datasets = TRUE) # include datasets user_show('sckottie', include_num_followers = TRUE) ## End(Not run)