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: | GPL-3 |
Version: | 0.0.0.9005 |
Built: | 2024-11-17 03:54:41 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 AuthZot(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.
item <- zot_add_to_collection(id = "<itemId>", collection_id = "<collection_id>")
item <- zot_add_to_collection(id = "<itemId>", collection_id = "<collection_id>")
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 parametere 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.
A OAuth object including the Zotero API key.
credentials <- zot_auth(cache=TRUE)
credentials <- zot_auth(cache=TRUE)
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(tags = c("economy; history", "economy"))
zot_convert_tags_to_df(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 AuthZot(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
key <- zot_create_collection(user = 12345, collection_name = "ZoteroRtest", credentials = "<API>")
key <- zot_create_collection(user = 12345, collection_name = "ZoteroRtest", credentials = "<API>")
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_df <- zot_create_csv_template(item_type = "book")
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 'zoteroR::zot_get_item_template()' for the given item type. |
user |
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 (creates new items on Zotero)
item <- zot_create_items(item_df)
item <- zot_create_items(item_df)
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.
creator_types <- zot_get_creator_types()
creator_types <- zot_get_creator_types()
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.
item_types <- zot_get_item_types()
item_types <- zot_get_item_types()
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.
item_types <- zot_get_item_types()
item_types <- zot_get_item_types()
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.
zot_get_item_types_fields()
zot_get_item_types_fields()
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 AuthZot(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.
item <- ZotReadChildren()
item <- ZotReadChildren()
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 AuthZot(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
item_id <- zot_read_children_id()
item_id <- zot_read_children_id()
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 AuthZot(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.
item <- zot_read_item()
item <- zot_read_item()
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-folde, 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.
size <- zot_size()
size <- zot_size()
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 AuthZot(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.
categories <- zot_which_collection(item = "X1X2X3")
categories <- zot_which_collection(item = "X1X2X3")