catmaid_fetch carries out a GET operation when body=NULL, POST otherwise. The http status code of the response will be checked - if invalid an error will be thrown.

catmaid_fetch(path, body = NULL, conn = NULL, parse.json = TRUE,
  include_headers = TRUE, simplifyVector = FALSE, ...)



The path on the CATMAID server relative to the CATMAID root


The (optional) body of the post request, usually in the form of a named list. See the POST documentation for full details.


A catmaid_connection objection returned by catmaid_login. If NULL (the default) a new connection object will be generated using the values of the catmaid.* package options as described in the help for catmaid_login.


Whether or not to parse a JSON response to an R object (default TRUE)


Whether to include basic headers from the http request as attributes on the parsed JSON object (default TRUE) when parse.json=TRUE.


Whether to use jsonlite::simplifyVector


Additional arguments passed to the httr::GET or httr::POST function


When parse.json=FALSE an object of class response otherwise the raw R object generated by calling jsonlite::fromJSON on the body of the response.

See also


if (FALSE) { ## Make a catmaid_connection object to use for these requests conn=catmaid_login() ## fetch a demo skeleton using a GET request # raw response skel.response=catmaid_fetch("1/10418394/0/0/compact-skeleton", conn=conn) # list object skel=catmaid_fetch("1/10418394/0/0/compact-skeleton", conn=conn) ## Get the names of two skeletons using a POST request # NB that the skids[n] elements are quoted when constructing the list since # they are not valid R names. catmaid_fetch("/1/skeleton/neuronnames", conn=conn, body=list(pid=1, 'skids[1]'=10418394, 'skids[2]'=4453485)) ## get all skeletons with more than 1000 nodes skids=as.integer(catmaid_fetch("/1/skeletons/?nodecount_gt=1000")) ## fetch user history since 1st April 2016 uh = catmaid_fetch('1/stats/history?start_date=2016-04-01', simplifyVector = T, include_headers = F) uh$date=as.Date(uh$date,"%Y%m%d") library(dplyr) # select top 10 users by nodes added top10=uh %>% group_by(name) %>% summarise(total=sum(count)) %>% arrange(desc(total)) %>% top_n(10) # plot cumulative nodes traced library(ggplot2) uh %>% group_by(name) %>% mutate(ccount = cumsum(count)) %>% filter(name %in% top10$name) %>% ggplot(aes(date, ccount, col = name)) + geom_line() ## demonstrate that bad urls will result in an error catmaid_fetch("/1/rhubarb/crumble") }