Free API keys; Raw file URLs stay open
Free API keys; Raw file URLs stay open
Supersedes the 2026-09-23 version of this ADR (PR #956, "Paid API access for DataHub-owned datasets"). That version required a key for all programmatic access, moved Dataset files to a private bucket and gave anonymous visitors a preview slice. This version keeps Raw file URLs public, makes keys free and optional, and leaves limits and pricing to later phases.
Terms are defined in CONTEXT.md. Build plan:
docs/plans/2026-10-14-reference-api-implementation.md (PR #962; beads epic
datahub-next-nbl).
Context
Most of what people get from datahub.io is programmatic and anonymous: about 136k script requests a month to Raw file URLs, a quarter of them for reference data, some from business systems on daily schedules. We cannot see, contact or sell to any of them. Raw file URLs give the full data, so paying gets nothing a free Consumer lacks.
The hypothesis (product plan, datahub/notes/datahub-api-plan.md): a basic Reference
Data API with free keys, plus a gentle Quota on Raw file URLs, will get the heaviest
Consumers to register. Once we know who they are, we can price for businesses.
Sudden limits would break real apps, and callers behind one shared IP would share one limit. So we first measure (caller IPs, logged since 2026-11-18), then attribute usage to keys, then nudge.
Decision
-
Accounts and sign-up. Sign-in with GitHub, Google or an email magic link. Sign-ins with the same provider-verified email link to one Account (for GitHub, only its verified primary email). Sign-ups, closed since 2026-09-08, reopen with this change.
-
Publishing stays Team-only; nothing is removed. Only the Team (
User.role = ADMIN) creates Publications and Datasets and uses the CLI (PRs #974, #978). Third-party Publications created earlier stay live and editable by their owners. -
API keys are free. Several named keys per Account, sharing one counter; at most 10 active. Prefix
dhk_. We store the sha256 hash, a short display prefix, a label, last-used and revoked timestamps; no tier. Issuing a key needs a verified email. Keys are separate from CLI tokens (dh_,UserCliToken), which stay Team-only. -
How a key is sent.
Authorization: Bearer dhk_…, or?apiKey=dhk_…for URL-only clients (Google Sheets, Excel, Power BI). -
Phase 1: a key only attributes usage. On Raw file URLs a key ties the request to an Account (
nbl.9). There is no Quota and nothing is refused. Raw file URLs stay public 302 redirects to the public R2 bucket. A Rate limit (per-minute burst cap,nbl.10) will apply; if its Redis store is down, requests go through. -
Phase 2 (sketch,
nbl.15): Quotas on Raw file URLs. A monthly Quota per keyless caller and a higher one per Account, on DataHub-owned publications only, with numbers set from the H1 report. Signed-in browser sessions have no Quota. DataHub's own dataset pages are exempt by an Origin/Referer check; it can be faked and we accept that for a soft limit. Crawlers get no exemption. Rollout: notice headers, then announced Brownouts (1 hour, then 1 day), then full refusal. Every refusal links to getting a key. Keys stay free. -
Phase 3 is out of scope until the gates pass: pricing, paid plans and key enforcement on the API. The API has a Rate limit and no Quota until pricing. API usage and Raw-file-URL usage are counted separately.
-
Events.
api_key_created,api_key_revoked.account_createdcarries the sign-upmethod(github,google,email) and an optionalref. "Get a free key" links go to/login?ref=<source>;refis kept in a cookie so the Account and its key can be tied to what prompted them (H2).file_accessedgainsaccount_idandapi_key_id.
Considered options
- Key required for all programmatic access, private bucket, short-TTL presigned
URLs, anonymous preview slice (the 2026-09-23 version, PR #956). Rejected. The
7 Oct 2026 meeting chose to keep Raw file URLs open up to a Quota: abrupt refusal
breaks the business callers we want to convert. #956's key core (the
ApiKeytable, router, key-management UI) is reused; its private bucket, sign-up gate, preview slice, dashboard rework and removal of third-party publishing are dropped. - Paid tiers from the start. Rejected for now. Willingness to pay is unproven and the H1 count may show few business callers. Pricing waits for the gates.
- Removing third-party Publications. Rejected. They stay; only new publishing is Team-only.
- Proxy or Worker in front of Raw file URLs. Not decided. Redirect, Vercel proxy or
Cloudflare Worker is a separate planning session (
nbl.2). The 302 stays until then. - Monetising Crawlers (pay-to-crawl). Not pursued.
Consequences
- Nothing breaks for existing Consumers in phase 1. The cost is that a key gives a
Consumer no benefit yet; the sign-up page (
/login?ref=) and Settings say the API is coming and that keys will get higher limits on Raw file URLs. - A 302 to a public bucket cannot enforce anything: a caller can keep the R2 URL and
skip DataHub. Phase 2 limits are soft by design; the
nbl.2session decides whether that is enough. - Free keys are tied to an Account with a verified email and capped at 10 active per Account, sharing one counter, so farming keys does not raise a caller's limits.
refandmethodlet us measure H2 (heavy Consumers register when nudged).
Premium datasets
Unchanged and out of scope. Premium full files are sold for a one-time fee and delivered from a separate private store; their Raw file URLs serve only the free sample. An API key does not grant access to a purchased premium dataset. How premium data (for example the gated postal-code countries) is priced on the API is not decided.
Still open
- Quota numbers, anonymous and per Account, from the H1 report (
nbl.5). - Raw file serving: redirect, Vercel proxy or Cloudflare Worker (
nbl.2). - Reference datastore: data model, match quality, history (
nbl.1). - Pricing, paid plans and key enforcement on the API (phase 3), after the gates: mid November (H1 count) and mid January (H2, H3).