Skip to content

Latest commit

 

History

History
84 lines (52 loc) · 3.99 KB

cdn-api.md

File metadata and controls

84 lines (52 loc) · 3.99 KB

CDN, API and mirrors

Serve icons from a CDN or consume the static manifest.

Back to the README.

CDN

Use any icon directly without installing:

<!-- From thesvg.org -->
<img src="https://thesvg.org/icons/github/default.svg" width="32" height="32" alt="GitHub" />

<!-- From jsDelivr -->
<img src="https://cdn.jsdelivr.net/gh/glincker/thesvg@main/public/icons/github/default.svg" width="32" height="32" alt="GitHub" />

URL pattern: https://thesvg.org/icons/{slug}/{variant}.svg

API

thesvg ships as a fully static site, served from a CDN. There is no dynamic API; instead, two pre-built JSON manifests cover every use case. Search, filter, and pagination happen on the client.

Base URL: https://thesvg.org

Endpoint Description
GET /api/registry.json Full icon manifest (slug, title, aliases, categories, hex, url, variant keys)
GET /api/categories.json Category list with counts
GET /icons/{slug}/{variant}.svg Raw SVG file (e.g. /icons/openai/default.svg)
# Fetch the manifest once, filter client-side
curl "https://thesvg.org/api/registry.json" | jq '.icons[] | select(.slug | contains("openai"))'

# Then pull the SVG you want
curl "https://thesvg.org/icons/openai/default.svg"

Mirrors

For high-traffic apps, use jsDelivr (free, GitHub-backed) instead of hitting thesvg.org directly:

https://cdn.jsdelivr.net/gh/glincker/thesvg@main/src/data/icons.json
https://cdn.jsdelivr.net/gh/glincker/thesvg@main/public/icons/{slug}/{variant}.svg

src/data/icons.json is the source-of-truth manifest (the same data that builds /api/registry.json, with full per-icon fields including license and dateAdded).

You can also clone the repo (~30 MB) and self-host. The codebase is MIT-licensed; individual brand icons remain trademarks of their respective owners (see LEGAL.md).

A gated, token-based API is on the roadmap at api.thesvg.org for advanced features (search relevance, usage analytics, webhooks). Until then, the static manifest above is the supported integration path.

Variant dimensions

Each variant's viewBox size is published so you can skip wide art without fetching the SVG. /api/variant-meta.json is { total, icons: { [slug]: { [variant]: { width, height, viewBox, aspectRatio } } } }:

curl -s "https://thesvg.org/api/variant-meta.json" | jq '.icons.vercel.wordmark'
# { "width": 262, "height": 52, "viewBox": "0 0 262 52", "aspectRatio": 5.038 }

Sizes are viewBox units, not pixels, and differ per variant. Artwork type (symbol, wordmark, combination) will follow after curation.

Verifying the registry

Official builds publish /api/registry.json.sig (base64 Ed25519 over the exact served bytes) and /api/icons-full.json.sig. The public key is /.well-known/thesvg-registry.pub. Verify with pnpm exec tsx scripts/verify-registry.ts <registry url|path> (fetches <registry>.sig; pass a third argument for a key path), or with openssl 3:

base64 -d registry.json.sig > sig.bin
openssl pkeyutl -verify -pubin -inkey thesvg-registry.pub -rawin -in registry.json -sigfile sig.bin

Maintainers: scripts/gen-registry-keys.ts creates the keypair. THESVG_REGISTRY_SIGNING_KEY takes a PEM or base64 PKCS8 private key; THESVG_CANARY_SECRET enables copy-detection markers (scripts/check-canary.ts).

Self-hosting

You can also clone the repo (~30 MB) and self-host for your own use. The icon library and tooling are MIT-licensed; the website's design and code fall under the thesvg Site License, which allows a public mirror or fork only if the thesvg logo stays visible in the main navigation and links back to thesvg.org. Individual brand icons remain trademarks of their respective owners (see LEGAL.md).

A gated, token-based API is on the roadmap at api.thesvg.org for advanced features (search relevance, usage analytics, webhooks). Until then, the static manifest above is the supported integration path.