feat: Open Data API — public read-only API with keys and quotas (#1060) - #1095
Merged
Anuoluwapo25 merged 4 commits intoAug 27, 2026
Merged
Conversation
api_keys stores only SHA-256 hashes — plaintext shown once at creation. Usage tracked per key per endpoint per day for tier quotas (free 1000/day, partner 10k/day).
…ain#1060) - X-API-Key middleware: rejects missing/malformed/revoked keys with 401, records usage per endpoint per day, enforces tier quota with 429 + Retry-After until UTC midnight - five read-only endpoints: course catalog, aggregate stats, leaderboard, treasury flows, credential verification — all versioned from day one - privacy by construction: k>=5 bucket suppression on every aggregate, leaderboard exposes handles only (raw wallet addresses hashed out), controllers select explicit safe columns so identity columns can't ride along even if a query changes later
All five /v1/public routes with ApiKeyAuth security scheme.
12 tests: missing/malformed/unknown/revoked keys, quota boundary with 429 + Retry-After and next-day reset, per-endpoint usage counters, k<5 bucket suppression on stats and leaderboard, pagination stability, and an identity-leak scan asserting no email/kyc/raw-address shapes in any response body across endpoints.
Contributor
Author
|
@Anuoluwapo25 PR is ready for your review. It closes #1060 ; five public read-only endpoints under a versioned /api/v1/public path, API keys stored hash-only with tiered daily quotas, and privacy handled as the core requirement (k>=5 suppression everywhere, no identity columns ever selected). |
7 tasks
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.
Closes #1060
Summary of Changes
Adds a public, read-only, API-key-authenticated surface under
/api/v1/publicso third parties can self-serve LearnVault data: course catalog, aggregate platform stats, learner leaderboard, treasury flows and credential verification. Keys are shown once at creation and stored only as SHA-256 hashes; per-tier daily quotas keep the endpoint honest. Privacy is treated as the core of the issue — k-anonymity suppression on every aggregate, explicit safe-column selection on identity-adjacent queries.What Changed
api_keys+api_key_usage): hash-only key storage, usage tracked per key per endpoint per day. (The issue sketched this as migration 030, but 030–033 were already taken in this repo — numbered 034 instead.)X-API-Key): missing/malformed/unknown/revoked keys all get 401; usage is recorded per endpoint per day; tier quotas (free = 1,000/day, partner = 10,000/day) return429with aRetry-Afterheader counting down to UTC midnight. Quota headers ship on every response.GET /courses— published catalog, page/limit paginationGET /stats— active learners, completions, LRN distributed, scholarships fundedGET /leaderboard— ranked public handles only; raw wallet addresses never leaveGET /treasury— daily inflow/outflow aggregates over a periodGET /credentials/:id/verify— validity + course slug + issue date, no holder identityTesting / Local Verification
12 new tests in
open-data.routes.test.ts:Full server suite: 654 passing vs 642 at base; same 16 pre-existing failures as base, untouched.