ADS is a lightweight R package for interacting with the NASA Astrophysics Data System (ADS) API. It lets you fetch citation metrics and formatted references for papers stored in your ADS libraries and produce publication-quality visualisations of your citation record.
# install.packages("remotes")
remotes::install_github("asgr/ADS")| Package | Role |
|---|---|
| httr | HTTP requests to the ADS API |
| foreach | Iteration over paper lists |
| magicaxis | Enhanced plotting utilities |
All functions that talk to the ADS API require a personal API token.
- Log in at https://ui.adsabs.harvard.edu.
- Go to Account → Settings → API Token.
- Copy the token and pass it as the
Authorisationargument (or store it as an environment variable, e.g.ADS_TOKEN).
library(ADS)
library(httr)
token <- Sys.getenv("ADS_TOKEN") # or paste your token directly
# ── 1. Fetch bibcodes from an ADS library ─────────────────────────────────────
resp <- ADS_library(library = "-I4xxWbuR_-7f2b77Te36Q", Authorisation = token)
papers <- unlist(content(resp)$documents)
# ── 2. Retrieve citation metrics ──────────────────────────────────────────────
m <- ADS_metrics(papers = papers, Authorisation = token)
# ── 3. Print a summary (total cites, H-index, per-paper breakdown) ────────────
print(m)
# Total: 4321
# H-Index: 32
#
# 2015PASA...32...33R 512 2341
# ...
# ── 4. Plot a citation bar chart ──────────────────────────────────────────────
plot(m)
# ── 5. Export formatted references ────────────────────────────────────────────
ex <- ADS_export(papers = papers[1:3], Authorisation = token)
print(ex)
# ── 6. Open a paper in the browser ────────────────────────────────────────────
ADS_goto("2015PASA...32...33R")| Function | Description |
|---|---|
ADS_library() |
Fetch the list of bibcodes in an ADS library |
ADS_metrics() |
Retrieve citation/read metrics for a set of papers |
print.ADS_metrics() |
Print total cites, H-index, and per-paper summary |
plot.ADS_metrics() |
Bar chart of citations coloured by read count |
ADS_export() |
Export formatted citation strings for a set of papers |
print.ADS_export() |
Print the formatted citation strings |
get_ADS_info() |
Extract a specific metric from an ADS_metrics object |
ADS_goto() |
Open a paper's ADS abstract page in the default browser |
Full documentation is available via ?<function_name> once the package is installed.
The plot.ADS_metrics method draws a bar chart where:
- bars are sorted in decreasing citation order,
- bar colour encodes the total read count (blue = few reads → green → red = many reads),
- a red dashed line marks the H-index.
Example output (ASGR library):
The repository includes a GitHub Actions workflow (.github/workflows/ads_metrics.yml) that runs exec/check_metrics.R on a schedule. It fetches the latest metrics for two ADS libraries and saves PNG plots to the data/ folder.
To use this in your own fork:
- Add your ADS API token as a repository secret named
ADS_TOKEN. - Update the library IDs in
exec/check_metrics.Rto point to your own ADS libraries.
LGPL-3 © Aaron Robotham
