Package 'biblioview'

Title: A Shiny Web Portal and Abstract Enricher for Zotero Libraries
Description: Provides automated pipelines to fetch Zotero group libraries, generate APA citations, and harvest citation counts and missing abstracts from external metadata APIs (Crossref, OpenAlex, and Europe PMC).
Authors: Thomas Petzoldt [aut, cre] (ORCID: <https://orcid.org/0000-0002-4951-6468>)
Maintainer: Thomas Petzoldt <[email protected]>
License: GPL (>= 2)
Version: 0.5.9
Built: 2026-09-30 12:35:32 UTC
Source: https://github.com/tpetzoldt/biblioview

Help Index


Check Abstract Availability Across Providers for a Single DOI

Description

Debugging utility to query external APIs directly for a specific DOI and print abstract availability and character length.

Usage

check_doi_abstracts(doi, email_contact = Sys.getenv("POLITE_EMAIL"))

Arguments

doi

Character string. Raw or clean DOI (e.g., "10.1007/s10452-015-9564-x").

email_contact

Character. Contact email for API headers.

Value

A named list of retrieved abstracts (or NULL per provider).

Examples

# 1. PLOS ONE: "phyloseq: An R Package for Reproducible Interactive Analysis..."
check_doi_abstracts("10.1371/journal.pone.0061217")

# 2. Journal of Statistical Software: "Data Validation Infrastructure for R" (validate package)
check_doi_abstracts("10.18637/jss.v097.i10")

# 3. PLOS ONE: "Dose-Response Analysis Using R" (drc package)
check_doi_abstracts("10.1371/journal.pone.0146021")

Clean and Normalize DOI Strings

Description

Strips common URL prefixes (including bare 'doi.org/'), leading/trailing whitespace, and verifies that the resulting string follows standard DOI format.

Usage

clean_doi_string(raw_doi)

Arguments

raw_doi

Character string containing a raw DOI or DOI URL.

Value

Character string containing the clean DOI (e.g., "10.1579/..."), or NULL if input is invalid or missing the '10.' prefix.


Enrich Missing Abstracts from External Metadata APIs

Description

Enrich Missing Abstracts from External Metadata APIs

Usage

enrich_missing_abstracts(
  df,
  email_contact = Sys.getenv("POLITE_EMAIL"),
  providers = list(epmc = fetch_abstract_epmc, crossref = fetch_abstract_crossref,
    openalex = fetch_abstract_openalex)
)

Arguments

df

A data frame generated by fetch_all_zotero_data.

email_contact

Character. Valid email address for polite API pools. Defaults to the environment variable POLITE_EMAIL.

providers

Named list of provider fetcher functions executed in list order. Defaults to Europe PMC -> OpenAlex -> Crossref.

Value

Data frame with updated Abstract column where matches were found.

Examples

## Not run: 
# Default usage (Europe PMC -> OpenAlex -> Crossref)
df_enriched <- enrich_missing_abstracts(df = my_zotero_df)

# Custom provider order: OpenAlex primary, Europe PMC secondary
custom_order <- list(
  openalex = fetch_abstract_openalex,
  epmc     = fetch_abstract_epmc
)

df_enriched <- enrich_missing_abstracts(
  df = my_zotero_df,
  providers = custom_order
)

## End(Not run)

Extract and Normalize DOI from Zotero Item Data

Description

Inspects a Zotero item's metadata list for a DOI, checking the primary DOI field first, followed by the extra field if necessary. Automatically normalizes URL prefixes and validates the '10.' prefix structure.

Usage

extract_doi(data)

Arguments

data

List. The data element of a Zotero API item list (e.g., item$data).

Value

Clean character string containing the DOI, or NULL if no valid DOI is found.


Extract 4-Digit Year from Raw Zotero Date Fields safely

Description

Extract 4-Digit Year from Raw Zotero Date Fields safely

Usage

extract_zotero_year(date_vec)

Arguments

date_vec

Character vector or list item containing raw date string(s).

Value

Character vector of 4-digit years (or NA_character_).


Extract Year from Zotero Date Fields (including BCE / Ancient Dates)

Description

Extract Year from Zotero Date Fields (including BCE / Ancient Dates)

Usage

extract_zotero_year_extended(date_vec)

Arguments

date_vec

Character vector of raw date strings from Zotero.

Value

Character vector containing year strings (e.g., "2024", "384 BCE", "-0383", or NA).


Fetch Abstract from Crossref

Description

Fetch Abstract from Crossref

Usage

fetch_abstract_crossref(doi, req_template)

Arguments

doi

Clean DOI string.

req_template

httr2 base request.

Value

Character string containing abstract or NULL if not found.


Fetch Abstract from Europe PMC API

Description

Queries Europe PMC for an article's abstract using its DOI. Requires resultType = "core" in the query parameters to ensure abstract text is included.

Usage

fetch_abstract_epmc(encoded_doi, base_req)

Arguments

encoded_doi

Character string. Clean or URL-encoded DOI.

base_req

An httr2 request object configured with user-agent/headers.

Value

Character string containing abstract text, or NULL if not found.


Fetch Abstract from OpenAlex

Description

Fetch Abstract from OpenAlex

Usage

fetch_abstract_openalex(doi, req_template)

Arguments

doi

Clean DOI string.

req_template

httr2 base request.

Value

Character string containing abstract or NULL if not found.


Fetch Abstract from Semantic Scholar

Description

Fetch Abstract from Semantic Scholar

Usage

fetch_abstract_semanticscholar(doi, base_req)

Arguments

doi

Clean DOI string.

base_req

httr2 base request.

Value

Character string containing abstract or NULL if not found.


Fetch All Data from a Zotero Group Library

Description

Loops through specified or all collections in a Zotero group library, retrieves their items, formats them into a tabular structure, and appends the collection name.

Usage

fetch_all_zotero_data(group_id, api_key, collection_id = NULL)

Arguments

group_id

Character or numeric. The target Zotero Group ID.

api_key

Character. Your secret Zotero Web API v3 key.

collection_id

Optional character vector. Unique Zotero collection keys (hashes) to pull down. If NULL (default), all collections in the library are processed.

Value

A data frame containing structured reference data with columns: Sub_Collection, Authors, Year, Title, DOI, APA_Citation, and Abstract.


Fetch Citation Counts from OpenAlex via Batch Queries

Description

Scans a data frame for a DOI column, extracts all valid identifiers, and queries the OpenAlex API in batches of up to 50 items to retrieve up-to-date citation metrics (cited_by_count). The results are joined back to the original data frame under a new citations column.

Usage

fetch_citation_counts(df, email_contact = Sys.getenv("POLITE_EMAIL"))

Arguments

df

A data frame containing bibliographic data, typically generated by fetch_all_zotero_data().

email_contact

Character string containing the contact email used to gain entry to the OpenAlex "Polite Pool." Defaults to the system environment variable Sys.getenv("POLITE_EMAIL").

Value

A data frame identical to the input, but with an added integer column named citations containing the citation metrics. Rows with missing or unmatched DOIs will default to NA.

Examples

## Not run: 
enriched_data <- fetch_citation_counts(raw_data)

## End(Not run)

Fetch All Items Within a Specific Zotero Collection

Description

Handles paginated API requests (100 items per page) to retrieve all top-level items from a specific Zotero collection key.

Usage

fetch_collection_items(group_id, api_key, collection_key)

Arguments

group_id

Character or numeric. The target Zotero Group ID.

api_key

Character. Your secret Zotero Web API v3 key.

collection_key

Character. The unique alphanumeric key for the sub-collection.

Value

A data frame of processed items belonging to the collection.


Fetch Bibliography Metadata in RIS Format from Crossref

Description

Takes a vector of DOIs and retrieves their bibliographic data formatted as RIS using Crossref Content Negotiation. Includes robust error handling and automatic retry logic for network rate-limiting.

Usage

fetch_ris_from_crossref(dois, email = NULL)

Arguments

dois

Character vector of DOIs.

email

Optional email address for Crossref's polite pool (recommended).

Value

A character vector of RIS formatted entries.

See Also

write_ris()

Examples

## Not run: 
ris <- fetch_ris_from_crossref(
  dois = c("10.1016/j.ecolmodel.2020.109282", "10.1111/gcb.15000"),
  email = "[email protected]"
)
write_ris(ris, "export.ris")

## End(Not run)

Fetch Sub-Folders (Collections) from a Zotero Group

Description

Connects to the Zotero API and retrieves a named vector of all sub-folders (collections) within the specified group library.

Usage

fetch_zotero_collections(group_id, api_key)

Arguments

group_id

Character or numeric string containing the Zotero Group ID.

api_key

Character string containing the Zotero API access key.

Value

A named character vector where the values are the unique Zotero collection hashes (e.g., "A8F3X2Z9") and the names are the human-readable folder titles (e.g., "Marine Biology"). Returns an empty vector if no folders exist.

Examples

## Not run: 
folders <- fetch_zotero_collections("1234567", "your_api_key")

## End(Not run)

Launch the Biblioview Dashboard Locally

Description

Launch the Biblioview Dashboard Locally

Usage

launch_dashboard(group = NULL, key = NULL, folder = NULL, title = NULL)

Arguments

group

Optional character string containing a default Zotero Group ID.

key

Optional character string containing a default Zotero API Key.

folder

Optional character string containing a sub-collection (folder) of the group library.

title

Optional character string to override the default portal header title.


Create Standard Biblioview DataTable

Description

Handles hyperlink formatting, JS tooltips, column truncation, and export button configurations uniformly.

Usage

render_biblioview_table(df, title = "export", show_buttons = TRUE)

Arguments

df

Data frame containing reference entries.

title

Character. Export filename prefix.

show_buttons

Logical. Include Copy/CSV/Excel export buttons.


Sync Missing Abstracts Back to Zotero API

Description

Scans a Zotero group library (or specific collections) for top-level items missing abstracts, fetches them from external APIs, sanitizes formatting, and writes them back to Zotero.

Usage

sync_missing_abstracts_to_zotero(
  group_id,
  api_key,
  collections = NULL,
  force_overwrite = FALSE,
  email_contact = Sys.getenv("POLITE_EMAIL"),
  providers = list(epmc = fetch_abstract_epmc, crossref = fetch_abstract_crossref,
    openalex = fetch_abstract_openalex)
)

Arguments

group_id

Character or Numeric. The Zotero Group ID.

api_key

Character. A Zotero API key with write access to the group.

collections

Character vector (optional). One or more Zotero folder/collection names. If NULL (default), scans the entire group library.

force_overwrite

Logical. If TRUE, re-fetches and overwrites pre-existing abstracts. Defaults to FALSE.

email_contact

Character. Contact email used for polite external API pools. Defaults to environment variable POLITE_EMAIL.

providers

Named list of provider functions passed to external APIs.

Value

A named list containing summary statistics of the sync operation and details on any unresolvable items.


Export RIS Entries to File

Description

Writes a character vector of RIS records to a file.

Usage

write_ris(ris_data, file)

Arguments

ris_data

Character vector of RIS records (e.g. from fetch_ris_from_crossref).

file

Path to the destination file.

Value

The file path invisibly.

See Also

fetch_ris_from_crossref()


Convert Zotero Item Data to Simplified Plain-Text APA 7 Format

Description

Parses Zotero JSON items across articles, books, chapters, reports, and webpages, enforcing APA 7th rules without rich text (no italics or bolding).

Usage

zotero_to_apa(item)

Arguments

item

List. A single raw item element from the Zotero JSON API.

Value

A single-row data frame with standardized bibliographic columns.