| Title: | Access the Zotero API in R |
|---|---|
| Description: | zoteror provides tools to access the Zotero API. |
| Authors: | Giorgio Comai [aut, cre] |
| Maintainer: | Giorgio Comai <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.0.9007 |
| Built: | 2026-05-13 08:58:03 UTC |
| Source: | https://github.com/giocomai/zoteror |
Add item to a collection
zot_add_to_collection(id, collection_id, user = NULL, credentials = NULL)zot_add_to_collection(id, collection_id, user = NULL, credentials = NULL)
id |
Id code of a zotero item |
user |
Zotero userId |
credentials |
Either an R object created with zot_auth(store = TRUE), or an API secret key with write access created at https://www.zotero.org/settings/keys |
A list including all available details on a given item.
## Not run: item <- zot_add_to_collection(id = "<itemId>", collection_id = "<collection_id>") ## End(Not run)## Not run: item <- zot_add_to_collection(id = "<itemId>", collection_id = "<collection_id>") ## End(Not run)
Authenticate to a Zotero account (get keys)
zot_auth(cache = TRUE)zot_auth(cache = TRUE)
cache |
Logical, defaults to 'TRUE'. If 'TRUE', it stores the credentials in the working diretory in a file called 'zotero_credentials.rds', which should be considered confidential since it provides access to a given Zotero account. |
The verification code that appears at the end of the URL after authorization in browser should be input as verification PIN. If the parameter cache is enabled - 'zot_auth(cache=TRUE)' - 'zoteror' stores the credentials in a local file called 'zotero_credentials.rds', which should be considered confidential since it provides access to a given Zotero account. If a pre-existing 'zotero_credentials.rds' exists, it is loaded automatically.
An OAuth object including the Zotero API key.
## Not run: credentials <- zot_auth(cache = TRUE) ## End(Not run)## Not run: credentials <- zot_auth(cache = TRUE) ## End(Not run)
Transform a characther vectors of creators (authors, etc.) into a list of properly categorised data frames
zot_convert_creators_to_df_list( creator, creator_type = "author", separator_multiple_authors = "; ", separator_surname_name = ", " )zot_convert_creators_to_df_list( creator, creator_type = "author", separator_multiple_authors = "; ", separator_surname_name = ", " )
creator |
A character vector (usually, a column in a data frame). Names must be given in the format: "Surname, Name; Surname, Name" (use semicolumn only to separate between multiple authors). |
creator_type |
Defaults to "author". Must be a character vector of length 1. |
A data frame, with one column for each accepted input for the given item type.
zot_convert_creators_to_df_list(creator = "Spinelli, Altiero; Rossi, Ernesto")zot_convert_creators_to_df_list(creator = "Spinelli, Altiero; Rossi, Ernesto")
Transform a characther vectors of creators (authors, etc.) into a list of properly categorised data frames
zot_convert_tags_to_df_list(tags, separator = "; ")zot_convert_tags_to_df_list(tags, separator = "; ")
creator |
A character vector (usually, a column in a data frame). Names must be given in the format: "Surname, Name; Surname, Name" (use semicolumn only to separate between multiple authors). |
creator_type |
Defaults to "author". Must be a character vector of length 1. |
A data frame, with one column for each accepted input for the given item type.
zot_convert_tags_to_df_list(tags = c("economy; history", "economy"))zot_convert_tags_to_df_list(tags = c("economy; history", "economy"))
Create a collection in Zotero. If a collection by the same name exists, it does not create a new one, but rather outputs the id of that collection.
zot_create_collection(collection_name, user = NULL, credentials = NULL)zot_create_collection(collection_name, user = NULL, credentials = NULL)
collection_name |
Name of the collection to be added |
user |
Zotero userId |
credentials |
Either an R object created with zot_auth(store = TRUE), or an API secret key with write access created at https://www.zotero.org/settings/keys |
Creating a collection needs an API with write access
The key of the newly created collection (or of the pre-existing collection, if already one with the same name exists) as a character vector
## Not run: key <- zot_create_collection( user = 12345, collection_name = "ZoteroRtest", credentials = "<API>" ) ## End(Not run)## Not run: key <- zot_create_collection( user = 12345, collection_name = "ZoteroRtest", credentials = "<API>" ) ## End(Not run)
Create a template to facilitate import of csv files
zot_create_csv_template(item_type = "book", cache = TRUE)zot_create_csv_template(item_type = "book", cache = TRUE)
item_type |
Defaults to "book". It must correspond to a valid item type. You can chech which item types are valid with the function [zot_get_item_types()]. |
cache |
Logical, defaults to 'TRUE'. If 'TRUE', it stores the template in a 'zot_cache' folder in the current working directory. |
A data frame, with one column for each accepted input for the given item type.
book_template_df <- zot_create_csv_template(item_type = "book") book_template_dfbook_template_df <- zot_create_csv_template(item_type = "book") book_template_df
Create new Zotero items from a data frame
zot_create_items(item_df, collection = NULL, user = NULL, credentials = NULL)zot_create_items(item_df, collection = NULL, user = NULL, credentials = NULL)
item_df |
A data frame representing new items. Column names must correspond to [zot_get_item_template()] for the given item type. |
user |
Zotero userId |
credentials |
Either an R object created with [zot_auth()], or an API secret key with write access created at https://www.zotero.org/settings/keys) |
Nothing, used for its side effects (creates new items on Zotero)
## Not run: item <- zot_create_items(item_df) ## End(Not run)## Not run: item <- zot_create_items(item_df) ## End(Not run)
Find and show all valid creator types
zot_get_creator_types(item_type = "book", cache = TRUE, locale = NULL)zot_get_creator_types(item_type = "book", cache = TRUE, locale = NULL)
cache |
Logical, defaults to TRUE. If TRUE, it stores the list of valid item types in a "zot_cache" folder in the current working directory. |
locale |
Defaults to English. If given, it should correspond to a language code such as "it" or "fr-FR" |
A list including all valid creator types for given item type.
## Not run: creator_types <- zot_get_creator_types() ## End(Not run)## Not run: creator_types <- zot_get_creator_types() ## End(Not run)
Get an item template for a valid item type
zot_get_item_template(item_type = "book", cache = TRUE)zot_get_item_template(item_type = "book", cache = TRUE)
item_type |
Defaults to "book". It must correspond to a valid item type. You can chech which item types are valid with the function 'zot_get_item_types()' |
cache |
Logical, defaults to TRUE. If TRUE, it stores the template in a "zot_cache" folder in the current working directory. |
A list. A template for creating items of the given item_type.
## Not run: item_templates <- zot_get_item_template() ## End(Not run)## Not run: item_templates <- zot_get_item_template() ## End(Not run)
Find and show all valid item types
zot_get_item_types(cache = TRUE, locale = NULL)zot_get_item_types(cache = TRUE, locale = NULL)
cache |
Logical, defaults to TRUE. If TRUE, it stores the list of valid item types in a "zot_cache" folder in the current working directory. |
locale |
Defaults to English. If given, it should correspond to a language code such as "it" or "fr-FR" |
item_type |
Defaults to "book". It must correspond to a valid item type. You can chech which item types are valid with the function 'zot_get_item_types()' |
A charachter vector including all categories in which given item is included.
## Not run: item_types <- zot_get_item_types() ## End(Not run)## Not run: item_types <- zot_get_item_types() ## End(Not run)
Find and show all valid fields for a given item type
zot_get_item_types_fields(item_type = "book", cache = TRUE, locale = NULL)zot_get_item_types_fields(item_type = "book", cache = TRUE, locale = NULL)
item_type |
Defaults to "book". It must correspond to a valid item type. You can chech which item types are valid with the function 'zot_get_item_types()' |
cache |
Logical, defaults to TRUE. If TRUE, it stores the list of valid item types in a "zot_cache" folder in the current working directory. |
locale |
Defaults to English. If given, it should correspond to a language code such as "it" or "fr-FR" |
A data frame including all valid fields for given item type.
## Not run: zot_get_item_types_fields() ## End(Not run)## Not run: zot_get_item_types_fields() ## End(Not run)
Read details of all children of a Zotero item
zot_read_children(id, user = NULL, credentials = NULL)zot_read_children(id, user = NULL, credentials = NULL)
id |
Id code of a zotero item |
user |
Zotero userId |
credentials |
Either an R object created with zot_auth(store = TRUE), or an API secret key with write access created at https://www.zotero.org/settings/keys |
A data.frame including details on all children of a given parent item.
## Not run: item <- zot_read_children(id = "<ID>") ## End(Not run)## Not run: item <- zot_read_children(id = "<ID>") ## End(Not run)
Read IDs of all children of a Zotero item
zot_read_children_id(id, user = NULL, credentials = NULL)zot_read_children_id(id, user = NULL, credentials = NULL)
id |
Id code of a zotero item |
user |
Zotero userId |
credentials |
Either an R object created with zot_auth(store = TRUE), or an API secret key with write access created at https://www.zotero.org/settings/keys |
A vector including the ID of all children
## Not run: item_id <- zot_read_children_id(id = "<ID>") ## End(Not run)## Not run: item_id <- zot_read_children_id(id = "<ID>") ## End(Not run)
Read details of a Zotero item
zot_read_item(id, user = NULL, credentials = NULL)zot_read_item(id, user = NULL, credentials = NULL)
id |
Id code of a zotero item |
user |
Zotero userId |
credentials |
Either an R object created with zot_auth(store = TRUE), or an API secret key with write access created at https://www.zotero.org/settings/keys |
A list including all available details on a given item.
## Not run: item <- zot_read_item() ## End(Not run)## Not run: item <- zot_read_item() ## End(Not run)
It allows to preliminary store options frequently used by 'zoteror', thus removing the requirement to specify them each time a function is called.
zot_set_options(...)zot_set_options(...)
user |
A Zotero userId. |
credentials |
Either an R object created with AuthZot(store = TRUE), or an API secret key with write access created at [https://www.zotero.org/settings/keys] |
Nothing. Used for its side effects (stores settings).
zot_set_options(user = 12345, credentials = "<API>")zot_set_options(user = 12345, credentials = "<API>")
Find size of Zotero objects stored locally
zot_size(path)zot_size(path)
path |
Path to local Zotero storage sub-folder, e.g. "/home/user/.mozilla/firefox/mdk7yirc.default/zotero/storage" |
A data.frame (tibble) with ID and size of each item present in the local storage.
## Not run: size <- zot_size() ## End(Not run)## Not run: size <- zot_size() ## End(Not run)
Extract collections in which given item is included
zot_which_collection(id, user = NULL, credentials = NULL)zot_which_collection(id, user = NULL, credentials = NULL)
user |
Zotero userId |
credentials |
Either an R object created with zot_auth(store = TRUE), or an API secret key with write access created at https://www.zotero.org/settings/keys |
A charachter vector including all categories in which given item is included.
## Not run: categories <- zot_which_collection(item = "X1X2X3") ## End(Not run)## Not run: categories <- zot_which_collection(item = "X1X2X3") ## End(Not run)