Skip to content

GET /links: serve the corpus's link table - #16

Merged
rkrug merged 2 commits into
devfrom
claude/links-endpoint
Dec 1, 2026
Merged

rkrug merged 2 commits into
devfrom
claude/links-endpoint

Conversation

@rkrug

@rkrug rkrug commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

What

  • prepare_corpus() reads links/ next to the corpus (STANDARD.md §7) into a links table. Rows repeated across partitions are kept once, missing standard columns are added as NULL, and a corpus without a link table gets an empty one. The link files are part of the cache key, and .api_build_version is bumped to 8.
  • New route GET /links, shaped like OpenAlex's /links. Records come back as stored, so every relation the source wrote is served. For an openalexImportZenodo corpus that includes relations with no OpenAlex type (link_type null, DataCite name in relation).
  • Filters (parsed locally, since OpenAlex's /query does not translate /links):
    • origin and target: any ID form, DOIs in any form, other identifiers as stored (link_key() macro with an R twin);
    • link_type: short name or full URL;
    • relation: any case;
    • origin_in_corpus and target_in_corpus: true or false;
    • |, ! and null work as for works.
  • group_by on link_type, relation and the two flags; sort, select and paging also work. No work has to be named.
  • /corpus reports links, the number of links.
  • Docs: NEWS, README, the vignette's new section "Links", CLAUDE.md.

A corpus from openalexPro has an empty link table, so /links returns no records there. Filling it is openalexPro/openalexPro#100.

Tests

  • test-links.R: a project with corpus_jq plus a link table holding OpenAlex-typed and Zenodo-style rows, repeated in two partitions. It covers filters, ID and DOI forms, null, OR, NULL-safe negation, group_by, paging, select, sort, errors, the empty table, link_key() agreeing in SQL and R, and HTTP.
  • Full suite passes with NOT_CRAN=true; devtools::check(vignettes = FALSE): 0 errors, 0 warnings, 0 notes.

🤖 Generated with Claude Code

rkrug and others added 2 commits November 30, 2026 17:15
Reads links/ next to the corpus (STANDARD.md §7) into a links table and
serves it shaped like OpenAlex's /links, with all link types, relations
and columns the source wrote. Filters origin, target, link_type,
relation and the *_in_corpus flags are parsed locally; group_by, sort,
select and paging. /corpus reports the number of links.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
openalexPro 0.20.0 writes links/ into the project folder too; reading
the whole folder picked up the link table, which has no id column.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rkrug
rkrug merged commit 19b7263 into dev Dec 1, 2026
5 checks passed
@rkrug
rkrug deleted the claude/links-endpoint branch December 1, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant