Skip to contents

Also, please see the magnificent vignette and other documentation.

Step 1: Locate Zotero settings

A likely purpose of using c2z is to manipulate a (personal) Zotero library. Thus, the first step is to acquire an access key for your account, which you will find in the settings. As seen from the screenshot below, this is also where you can find your userID.

Figure 1. Zotero settings.

Step 2: Create a key

Next, enter a key description and decide what kind of access you will need. A bare minimum is to “allow library access”, however, if you want to create, edit, copy, or delete items you will need to “allow write access” as well. You can also add group permissions. Now that you have created a key, as seen below, you will need to make it available to c2z.

Figure 2. The key!

Step 3: Add key to R

Though it is possible to directly apply the key in the various functions, it is recommended to add the key to the .Renviron. The simplest approach is to use the usethis edit_r_environ() function, that will open the file for your convenience.


Figure 3. Example of .Renviron content.

How it works

# Access default zotero library
user.library <- Zotero(library = TRUE)
#> Searching for collections 
#> Found 0 collections 
#> Searching for all items in library 
#> Found 0 items
# Print type of library and id
sprintf("The library has the prefix: %s", user.library$prefix)
#> [1] "The library has the prefix: users/9913421"

# Access the group zotero library
group.library <- Zotero(user = FALSE, library = TRUE, silent = TRUE)
# Print type of library and id
sprintf("The library has the prefix: %s", group.library$prefix)
#> [1] "The library has the prefix: groups/4827927"

# Print the API
sprintf("The API key for these libraries is: %s", Sys.getenv("ZOTERO_API"))
#> [1] "The API key for these libraries is: RqlAmlH5l1KPghfCseAq1sQ1"