mode:lightordarkcolors:accent,background,text(hex)typography: detected headings (h1–h4) andpwithfontFamily,fontFallbacks,fontSize,fontWeight,lineHeight,letterSpacingelementSpacing:xs,sm,md,lg,xlshadows:sm,md,lg,xl,innercomponents: detected button variants (primary,secondary,link) andcardwith full computed CSSfontLinks: Google or@font-facefont files keyed by family, with downloadable URLs per weight
Integrate Context.dev's Design System API in your app
Prerequisites
-
A Context.dev API key. Sign up at context.dev/signup, copy the key from the dashboard (prefix
ctxt_secret_), and export it: -
An SDK (optional). Install for your language, or skip the install and call directly with
curl:
Extract the full styleguide
GET /web/styleguide takes in a domain (or a webpage URL) and returns the website’s full design system.
Request Parameters
| Parameter | Type | Description |
|---|---|---|
domain | string | Domain to extract the styleguide from (e.g. vercel.com). |
directUrl | string | A specific URL to fetch the styleguide from directly, bypassing domain resolution (e.g. https://stripe.com/pricing). |
maxAgeMs | integer | Max cache age before a hard refresh. Defaults to 7776000000 (90 days). Clamped to [86400000, 31536000000] (1 day – 1 year). |
timeoutMS | integer (1000–300000) | Abort with a 408 if the request exceeds this many milliseconds. Max 300000 (5 min). |
Response
| Field | Type | Description |
|---|---|---|
status | string | "ok" on success. |
domain | string | Normalized domain that was processed. |
code | integer | HTTP status code. |
styleguide.mode | string | "light" or "dark": the page’s primary color mode. |
styleguide.colors | object | accent, background, text: all hex strings. |
styleguide.typography.headings | object | h1, h2, h3, h4: each has fontFamily, fontFallbacks[], fontSize, fontWeight, lineHeight, letterSpacing. |
styleguide.typography.p | object | Body text: same shape as a heading entry. |
styleguide.elementSpacing | object | xs, sm, md, lg, xl: CSS length strings (typically px). |
styleguide.shadows | object | sm, md, lg, xl, inner: full box-shadow declarations. "none" when no shadow at that tier. |
styleguide.fontLinks | object | Keyed by font family name. Each entry has type (google or custom), files (weight → URL), optional category (Google only), optional displayName (custom only). Omitted when no family resolves to Google or @font-face URLs. |
styleguide.components.button | object | Three variants: primary, secondary, link. Each variant has:
|
styleguide.components.card | object |
|
Extract just the fonts
GET /web/fonts takes a domain (or a direct URL) and returns only the typography subset: every font family the site uses, with weights, fallbacks, usage counts, and downloadable file URLs.
Request Parameters
| Parameter | Type | Description |
|---|---|---|
domain | string | Domain to extract fonts from (e.g. vercel.com). Normalized automatically. |
directUrl | string (URI) | A specific URL to fetch fonts from directly, bypassing domain resolution. |
maxAgeMs | integer | Max cache age before a hard refresh. Defaults to 7776000000 (90 days). Clamped to [86400000, 31536000000] (1 day – 1 year). |
timeoutMS | integer (1000–300000) | Abort with a 408 if the request exceeds this many milliseconds. Max 300000 (5 min). |
Response
| Field | Type | Description |
|---|---|---|
status | string | "ok" on success. |
domain | string | Normalized domain that was processed. |
code | integer | HTTP status code. |
fonts[] | array | One entry per font family on the page, ordered by usage. |
fonts[].font | string | Primary face (first family in the computed stack). |
fonts[].uses[] | array | CSS selectors or element types where this font is used. |
fonts[].fallbacks[] | array | Fallback families from the computed stack. |
fonts[].num_elements | number | Element count using this font. |
fonts[].num_words | number | Word count rendered in this font. |
fonts[].percent_elements | number | Share of all elements using this font. |
fonts[].percent_words | number | Share of all words rendered in this font. |
fontLinks | object | Optional. Same shape as styleguide.fontLinks: keyed by family with type, files, optional category and displayName. Omitted when no family resolves to Google or @font-face URLs. |
Handle errors
A non-2xx response returns an{ message, error_code, status } envelope. The common ones:
| Status | error_code | Meaning | What to do |
|---|---|---|---|
| 400 | INPUT_VALIDATION_ERROR | Missing both domain and directUrl, or both were supplied | Pass exactly one. |
| 401 | UNAUTHORIZED | API key missing, invalid, or deleted | Re-check the env var and the dashboard. |
| 408 | REQUEST_TIMEOUT | Page didn’t render before timeoutMS (or 5 min default) | Retry once with backoff; the second hit usually succeeds. |
| 500 | INTERNAL_ERROR | Transient server error | Retry once with backoff; if it persists, contact support. |
domain and directUrl looks like:
Use cases
- Build faster, brand-aware onboarding flows
- Build branded email templates from a website
- Generate branded marketing assets at scale
Next steps
Prefetch for Faster Response
Hide cold-hit latency from your users.
Handle Rate Limits
Backoff strategies, client cache, and prefetch fallbacks.
Best Practices
Caching, error handling, and key hygiene.
Troubleshooting
Status codes, retry patterns, and common errors.