library(zoterro) knitr::opts_chunk$set( cache = TRUE, cache.path = ".cache/README/", collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
library(tidyverse) library(hexSticker) p <- data.frame(x=1, y=1) %>% ggplot(aes(x=x, y=y)) + ggimage::geom_image(image="~/Downloads/zorro_hat.png") sticker( "img-raw/zoterro.png", package = "zoterro", p_size = 20, s_x = 1, s_y = 0.75, s_width = 0.6, h_fill = "#DF0025", url = "https://mbojan.github.io/zoterro", filename = "man/figures/logo.png" )
Zotero is a free tool for collecting, organizing, and citing research developed by the Corporation for Digital Scholarship. Zoterro (with double "r") is a simple R client to the Zotero web API (ver. 3) which can be used to access the data of public groups, your personal account, or groups you are a member of.
The client implements convenience functions for fetching data from the most frequently needed API endpoints. Endpoints for which no convenience wrapper is offered (yet) can be accessed using the low-level interface provided by zotero_api()
. See Zotero API documentation for what endpoints are available.
Install the development version from GitHub via:
# install.packages("remotes") remotes::install_github("mbojan/zoterro")
Fetch a complete collection hierarchy as a data frame. The function defaults to the configured user ID determined by zotero_usr()
, but here we fetch the collections associated with a public Zotero group "Computational Social Science" that has the ID 269768
:
r
collections(user = zotero_group_id(269768))
Collections are identifed with unique key
s. If any of the collections would be nested within some other collection, the key of the parent collection would appear in the column parent
.
Fetch all items from a collection. By default the data is returned as a tibble:
r
items(collection_key = "PJHH85S9", user = zotero_group_id(269768))
The output format can be changed to e.g. BibTeX:
```r items_bibtex <- items( collection_key = "PJHH85S9", as_tibble = FALSE, user = zotero_group_id(269768), query = list(format = "bibtex") ) # This will print all the entries... # cat(rawToChar(items_bibtex))
# ... but to save space we show just the first three: entries <- head(strsplit( rawToChar(items_bibtex), "\n\n" )[[1]], 3 ) cat(entries, sep = "\n\n")
```
Fetch all items from a collection and save to BibTeX file references.bib
. Basically a conveniece wrapper for the example above.
r
write_bib(
collection_key = "PJHH85S9",
path = "references.bib",
user = zotero_group_id(269768)
)
zotero_api()
is a low-level function. It will make multiple requests if the results do not fit in a single response. The following will fetch all items in the "My Publications" collection of the default user:
r
zotero_api(path = "publications/items")
Please note that the zoterro project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.