Skip to content
lorenzoFabbriPublic

About

R package to access ORCiD.

Topics

Resources

Code of conduct

Contributing

Stars

7 stars

Watchers

0 watching

Forks

Repository files navigation

orcidtr

Lifecycle: active CRAN status R-CMD-check codecov Buy Me a Coffee

Overview

orcidtr reads public data from ORCID records through the ORCID public API (version 3.0) and returns it as data.table objects. It covers every section of a record and the registry search. It takes over from rorcid, which rOpenSci has archived and which has not been updated since 2021.

The public API needs no account or token, so every function works as soon as the package is installed.

What is ORCID?

ORCID (Open Researcher and Contributor ID) gives each researcher a persistent identifier, the ORCID iD, and a record that links it to their professional activities. A record can list employment history, education, publications, funding, peer reviews and more, and the researcher decides which items are public.

Installation

Install the released version from CRAN:

install.packages("orcidtr")

Or the development version from GitHub:

# install.packages("pak")
pak::pak("lorenzoFabbri/orcidtr")

Quick start

Fetching one section

Every section of a record has its own function. It takes an ORCID iD, with or without dashes or an https://orcid.org/ prefix, and returns one row per item; a section the researcher has left empty gives a zero-row table with the same columns. The examples use the record of Josiah Carberry, a fictitious researcher whose record ORCID keeps for demonstrations.

library(orcidtr)

# Employment and education
employments <- orcid_employments("0000-0002-1825-0097")
educations <- orcid_educations("0000-0002-1825-0097")

# Publications and other works
works <- orcid_works("0000-0002-1825-0097")
works[type == "journal-article", .(title, publication_date, doi)]

# Funding and peer reviews
funding <- orcid_funding("0000-0002-1825-0097")
reviews <- orcid_peer_reviews("0000-0002-1825-0097")

# Biographical data
person <- orcid_person("0000-0002-1825-0097")
bio <- orcid_bio("0000-0002-1825-0097")
keywords <- orcid_keywords("0000-0002-1825-0097")

# Other affiliations
distinctions <- orcid_distinctions("0000-0002-1825-0097")
memberships <- orcid_memberships("0000-0002-1825-0097")

Fetching a whole record

orcid_fetch_record() sends one request per section and returns a named list. By default it fetches employments, educations, works, funding and peer reviews.

record <- orcid_fetch_record("0000-0002-1825-0097")
names(record)
record$works

# Only some sections
record <- orcid_fetch_record(
  "0000-0002-1825-0097",
  sections = c("works", "employments")
)

Fetching many records

orcid_fetch_many() fetches one section for several iDs and binds the rows; the orcid column says which record each row came from.

orcids <- c("0000-0002-1825-0097", "0000-0003-1419-2405", "0000-0003-4757-117X")
all_works <- orcid_fetch_many(orcids, section = "works")

all_works[type == "journal-article" & !is.na(doi)]

Searching the registry

orcid_search() takes named fields and combines them with AND; values with spaces are quoted for you. orcid_doi() finds the records that list a DOI. orcid() takes a raw Solr query, in which you quote multi-word values yourself. The total number of matches is in the found attribute.

# By name
results <- orcid_search(family_name = "Carberry", given_name = "Josiah")

# By affiliation
results <- orcid_search(affiliation_org = "Stanford University", rows = 20)

# By DOI
results <- orcid_doi("10.1371/journal.pone.0025995")

# Raw Solr query
results <- orcid('family-name:Smith AND affiliation-org-name:"Harvard University"')
attr(results, "found")

Supported data

Employment and education

Function Returns API endpoint
orcid_employments() Employment history /employments
orcid_educations() Education history /educations

Other affiliations

Function Returns API endpoint
orcid_distinctions() Distinctions and awards /distinctions
orcid_invited_positions() Invited positions /invited-positions
orcid_memberships() Memberships /memberships
orcid_qualifications() Qualifications /qualifications
orcid_services() Service /services
orcid_research_resources() Research resources /research-resources

Works and other activities

Function Returns API endpoint
orcid_works() Publications, datasets, preprints and other works /works
orcid_funding() Grants and other funding /fundings
orcid_peer_reviews() Peer reviews /peer-reviews
orcid_activities() Summaries of every activity section in one request /activities

Biographical data

Function Returns API endpoint
orcid_person() Name, biography, keywords, URLs and country in one row /person
orcid_bio() Biography /biography
orcid_keywords() Keywords /keywords
orcid_researcher_urls() Researcher URLs /researcher-urls
orcid_external_identifiers() External identifiers such as Scopus author IDs /external-identifiers
orcid_other_names() Other names /other-names
orcid_address() Country /address
orcid_email() Public email addresses (usually none) /email

Search, batch and status functions

Function Returns API endpoint
orcid() Matches for a Solr query /expanded-search
orcid_search() Matches for named fields /expanded-search
orcid_doi() Records listing a DOI /expanded-search
orcid_fetch_record() Several sections of one record One request per section
orcid_fetch_many() One section of several records One request per record
orcid_ping() "OK" when the API is up /status

Tokens and rate limits

The public API serves all public data without a token, and no function reads one from the environment. You can pass a /read-public token through the token argument of any function, but it returns the same data: it only raises the number of reads ORCID allows per day. A token never reveals more of a record, because data with limited visibility is served only by the Member API, which this package does not use.

ORCID limits both the requests per second and the reads per day. The vignette (vignette("orcidtr")) gives the current figures, taken from ORCID’s API limits page. orcidtr sends requests one after another and tries each up to three times when ORCID answers 429 or 503, so ordinary batches need no extra handling. If you rerun an analysis often, save the results with saveRDS() instead of fetching them again.

A token is worth getting only for batches large enough to reach the anonymous daily quota. To get one, register a public API client in the developer tools of your ORCID account, then exchange its client ID and secret:

library(httr2)

token <- request("https://orcid.org/oauth/token") |>
  req_headers(Accept = "application/json") |>
  req_body_form(
    client_id = "YOUR-CLIENT-ID",
    client_secret = "YOUR-CLIENT-SECRET",
    grant_type = "client_credentials",
    scope = "/read-public"
  ) |>
  req_perform() |>
  resp_body_json()

works <- orcidtr::orcid_works("0000-0002-1825-0097", token = token$access_token)

If you keep the token in .Renviron, pass it explicitly with token = Sys.getenv("ORCID_TOKEN"). The package never picks it up on its own, because the public API rejects an invalid token even though it needs none, so a stale one would break every call.

Acknowledgments

The rorcid package, by Scott Chamberlain and rOpenSci, brought ORCID to R first. Parts of this package were written with Claude Code (Anthropic); the author has reviewed and tested all of it.

License

MIT © Lorenzo Fabbri

About

R package to access ORCiD.

Topics

Resources

Code of conduct

Contributing

Stars

7 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages