Skip to content

feat: add optional Semantic Scholar API key support - #62

Open
adamdaw wants to merge 1 commit into
anoopkcn:masterfrom
adamdaw:pr/semantic-scholar-api-key
Open

feat: add optional Semantic Scholar API key support#62
adamdaw wants to merge 1 commit into
anoopkcn:masterfrom
adamdaw:pr/semantic-scholar-api-key

Conversation

@adamdaw

@adamdaw adamdaw commented May 13, 2026

Copy link
Copy Markdown

What

Adds an optional API key field for Semantic Scholar. When set, the key is sent as an x-api-key header on all S2AG API requests. When empty (the default), requests are unauthenticated — no change in behaviour for existing users.

Why

Unauthenticated requests to the Semantic Scholar API are rate-limited. Users who have obtained a free API key (available at semanticscholar.org/product/api) have no way to use it with the plugin today.

Changes

  • src/types.tssemanticScholarApiKey: string added to ReferenceMapSettings
  • src/constants.ts — defaults to ''
  • src/apis/s2agAPI.tsapiKeyHeaders() helper; apiKey param added to all five S2AG functions; header is a no-op spread when key is empty
  • src/data/viewManager.ts — passes settings.semanticScholarApiKey at all five call sites
  • src/settings/settings.tsx — password-type text input under a new "Semantic Scholar API" section at the top of settings

Notes

  • No breaking changes; default is empty string, so all existing behaviour is preserved
  • Key is stored in Obsidian's data.json alongside all other plugin settings — never in source

Thread an optional semanticScholarApiKey setting through all five
S2AG API functions. Key is sent as x-api-key header when set;
requests fall back to unauthenticated when empty.

Changes:
- types.ts: add semanticScholarApiKey to ReferenceMapSettings
- constants.ts: default semanticScholarApiKey to ''
- s2agAPI.ts: apiKey param on all 5 functions; header injected via
  apiKeyHeaders() helper (spread is a no-op when key is empty)
- viewManager.ts: pass settings.semanticScholarApiKey at all 5 call sites
- settings.tsx: password-type text input under new API section
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