Skip to content

Open API

Five free endpoints, no signup, no key, CORS-enabled. Same data as the site: the 24-bit space, 32,258 named colors, 11,386 standard swatches and 161 Chinese traditional colors.

Endpoints at a glance

Every endpoint is CORS-enabled - fetch directly from the browser or Node.js.

GET/api/color/e63946

Color profile: 10 formats + nearest named colors + matches across 8 standard systems + traditional matches + 6 harmonies + contrast

Parameters

hexColor value: 3 or 6 hex digits (e63946 or e63)

Example request

curl "https://www.yanseku.com/api/color/e63946"

Example response

{
  "hex": "e63946",
  "formats": {
    "rgb": { "r": 230, "g": 57, "b": 70 },
    "hsl": { "h": 355.5, "s": 77.6, "l": 56.3 },
    "hsv": { "h": 355.5, "s": 75.2, "v": 90.2 },
    "cmyk": { "c": 0, "m": 75.2, "y": 69.6, "k": 9.8 },
    "xyz": { "x": 0.352, "y": 0.2019, "z": 0.0784 },
    "lab": { "L": 52.06, "a": 65.72, "b": 34.14 },
    "oklch": { "L": 0.612, "c": 0.208, "h": 22.2 },
    "webSafe": "ff3333",
    "css": { "rgb": "rgb(230, 57, 70)", "hsl": "hsl(355.5, 77.6%, 56.3%)" }
  },
  "named": {
    "closest": { "name": "Paint the Town Red", "hex": "e63045", "deltaE": 1.34, "exact": false },
    "nearest": [ { "name": "Red Radish", "hex": "ee3344", "deltaE": 1.36, "exact": false } ]
  },
  "standards": [
    { "system": "ncs", "systemName": "NCS (Natural Color System)", "code": "NCS S 0570-Y90R", "name": "NCS S 0570-Y90R", "hex": "e6373f", "deltaE": 1.69, "exact": false },
    { "system": "munsell", "systemName": "Munsell (Re-renotation)", "code": "7.5R 6/16", "name": "7.5R 6/16", "hex": "dd3743", "deltaE": 2.02, "exact": false }
  ],
  "traditional": [
    { "name": "火红", "hex": "ff2d51", "cat": "红", "deltaE": 4.88, "exact": false },
    { "name": "银红", "hex": "f05654", "cat": "红", "deltaE": 5.89, "exact": false }
  ],
  "harmony": [
    { "type": "complementary", "colors": ["e63946", "39e6d9"] },
    { "type": "split-complementary", "colors": ["e63946", "39e683", "399de6"] }
  ],
  "contrast": {
    "onWhite": { "ratio": 4.17, "levels": { "aaNormal": false, "aaLarge": true, "aaaNormal": false, "aaaLarge": false } },
    "onBlack": { "ratio": 5.04, "levels": { "aaNormal": true, "aaLarge": true, "aaaNormal": false, "aaaLarge": true } },
    "bestText": "#000000"
  }
}

GET/api/scheme?hex=e63946&mode=triadic

Harmony scheme: six rules around your base color

Parameters

hexColor value: 3 or 6 hex digits (e63946 or e63)
modeHarmony mode, default complementary. Options: complementary / split-complementary / triadic / tetradic / analogous / monochromatic

Example request

curl "https://www.yanseku.com/api/scheme?hex=e63946&mode=triadic"

Example response

{
  "hex": "e63946",
  "mode": "triadic",
  "count": 3,
  "colors": ["e63946", "46e639", "3946e6"]
}

GET/api/contrast?fg=ffffff&bg=e63946

Contrast check: WCAG ratio + AA/AAA levels + best text color

Parameters

fgForeground hex, e.g. ffffff
bgBackground hex, e.g. e63946

Example request

curl "https://www.yanseku.com/api/contrast?fg=ffffff&bg=e63946"

Example response

{
  "fg": "ffffff",
  "bg": "e63946",
  "ratio": 4.17,
  "label": "AA Large",
  "levels": { "aaNormal": false, "aaLarge": true, "aaaNormal": false, "aaaLarge": false },
  "bestText": "#000000"
}

GET/api/random?count=5

Random colors from the curated name pool, up to 10

Parameters

countHow many colors, 1-10, default 1

Example request

curl "https://www.yanseku.com/api/random?count=5"

Example response

{
  "count": 3,
  "colors": [
    { "name": "Sea Foam Green", "hex": "c2e4d0" },
    { "name": "Deep Koamaru", "hex": "333366" },
    { "name": "Laser Lemon", "hex": "ffff66" }
  ]
}

Open data downloads

Beyond the API - take the whole library with you. CSV format (UTF-8, header row), ready for data analysis, machine learning and design-system research. Field names are in the header; datasets update with every build.

Color names derive from meodai/color-names (MIT) and the xkcd Color Survey; brand colors from simple-icons open data; Chinese traditional colors from zerosoul/chinese-colors and zhongguose.com; standard swatch values are computer-simulated conversions - verify against physical swatches for production. Follow the respective upstream licenses.

source: standard = official swatch; community = community-named color; traditional = Chinese traditional color

Free public endpoint - please be reasonable (≤ 60 req/min suggested).