feat: add optional Semantic Scholar API key support - #62
Open
adamdaw wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an optional API key field for Semantic Scholar. When set, the key is sent as an
x-api-keyheader 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.ts—semanticScholarApiKey: stringadded toReferenceMapSettingssrc/constants.ts— defaults to''src/apis/s2agAPI.ts—apiKeyHeaders()helper;apiKeyparam added to all five S2AG functions; header is a no-op spread when key is emptysrc/data/viewManager.ts— passessettings.semanticScholarApiKeyat all five call sitessrc/settings/settings.tsx— password-type text input under a new "Semantic Scholar API" section at the top of settingsNotes
data.jsonalongside all other plugin settings — never in source