Skip to main content

GET /api/r/[name]

Retrieve a font pairing or individual font configuration from the registry.

Path Parameters

name
string
required
The registry item name. Can be a pairing name (e.g., minimal, brutalist) or font name (e.g., inter, roboto).The .json extension is optional and will be automatically stripped if provided.

Resolution Logic

The API searches for registry items in the following order:
  1. Pairings directory with exact name: /registry/pairings/{name}.json
  2. Pairings directory without pairing- prefix: /registry/pairings/{name-without-prefix}.json
  3. Fonts directory: /registry/fonts/{name}.json
This allows flexible naming:
  • /api/r/minimal → finds pairings/minimal.json
  • /api/r/pairing-minimal → finds pairings/minimal.json
  • /api/r/inter → finds fonts/inter.json

Query Parameters

Override CSS properties for specific HTML elements in font pairings. Query parameters are ignored for individual font requests.

Parameter Format

Parameters follow the pattern: {selector}-{property}={value} Supported Selectors:
  • h1, h2, h3, h4, h5, h6 — Heading levels
  • body — Body text
  • code — Inline code
  • pre — Code blocks
Supported Properties:
{selector}-size
string
Font size (e.g., 2rem, 18px, 1.5em)
{selector}-weight
string
Font weight (e.g., 400, 700, bold)
{selector}-family
string
Font family (e.g., Inter, var(--font-custom))
{selector}-lh
string
Line height (e.g., 1.6, 1.8, 2)Aliases: line-height
{selector}-ls
string
Letter spacing (e.g., -0.02em, 0.05em)Aliases: letter-spacing

Example Query Parameters

?h1-size=3rem&h1-weight=800&body-lh=1.8
This will:
  • Set H1 font size to 3rem
  • Set H1 font weight to 800
  • Set body line height to 1.8

Response

Success
object
Returns either a pairing schema or font schema depending on the requested item.
Error
object
error
string
Error message describing why the request failed

Cache Headers

Without Query Parameters

Cache-Control: public, max-age=86400, s-maxage=86400
Responses are cached for 24 hours (86400 seconds) by browsers and CDNs.

With Query Parameters

Cache-Control: no-cache
Dynamic responses with overrides are not cached to ensure customizations are always applied.

Examples

Fetch Default Pairing

curl https://www.fonttrio.xyz/api/r/minimal

Fetch with Overrides

curl "https://www.fonttrio.xyz/api/r/brutalist?h1-size=3.5rem&body-lh=1.7"

Fetch Individual Font

curl https://www.fonttrio.xyz/api/r/inter

Error Handling

try {
  const response = await fetch('https://www.fonttrio.xyz/api/r/nonexistent');
  
  if (!response.ok) {
    const error = await response.json();
    console.error(error.error);
    // "Registry item \"nonexistent\" not found"
    return;
  }
  
  const data = await response.json();
  // Process data...
} catch (err) {
  console.error('Network error:', err);
}

Implementation Details

The endpoint is implemented in Next.js as a dynamic route handler: Source: app/api/r/[name]/route.ts:8 Key behaviors:
  • Strips .json extension if provided in the URL
  • Searches pairings directory first, then fonts directory
  • Handles pairing- prefix automatically
  • Applies CSS overrides from query parameters only to matching selectors
  • Returns 404 if no matching registry item is found

See Also

Pairing Schema

Detailed schema for font pairing responses

Font Schema

Schema for individual font configurations

Build docs developers (and LLMs) love