{
  "openapi": "3.1.1",
  "info": {
    "title": "Color Converter \u0026 Gamut Mapper (OKLCH, Lab, P3) API",
    "version": "1.0.0",
    "summary": "Convert any CSS color to HEX, RGB, HSL, Lab, LCH, OKLab, OKLCH and Display P3.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://luminacolorconverter.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Convert any CSS color to HEX, RGB, HSL, Lab, LCH, OKLab, OKLCH and Display P3.",
        "description": "Paste a HEX code, CSS named color or any CSS Color 4 function. Get every color space, sRGB and Display P3 gamut checks, the CSS gamut-mapped HEX instead of naive clipping, WCAG contrast against white and black, and the nearest CSS named colors by CIEDE2000.\n\nMethodology:\n- Parse the color with CSS Color 4 syntax: HEX (3, 4, 6 or 8 digits), the 148 named colors, rgb(), hsl(), hwb(), lab(), lch(), oklab(), oklch() and color() with srgb, srgb-linear, display-p3, a98-rgb, prophoto-rgb, rec2020, xyz-d50 and xyz-d65. The keyword none counts as zero.\n- Convert through CIE XYZ (D65) with the matrices of the CSS Color 4 sample code. Lab and LCH use the D50 white with the Bradford adaptation, as in CSS. OKLab and OKLCH follow Ottosson (2020).\n- A color is in a gamut when every encoded channel lies within 0–1 (tolerance 0.000075). Out-of-gamut colors are mapped with the CSS Color 4 binary search: reduce OKLCH chroma at constant lightness and hue until clipping changes the color by less than one just-noticeable difference (deltaEOK 0.02). The plainly clipped HEX is shown for comparison.\n- HSL, HWB, RGB and the WCAG contrast ratios describe the mapped 8-bit sRGB color. Nearest named colors are ranked by CIEDE2000 in CSS Lab.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "lumina_color_converter",
        "x-owner-app": "lumina",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LuminaColorConverterInput"
              },
              "examples": {
                "example1": {
                  "summary": "A vivid OKLCH green outside sRGB",
                  "value": {
                    "color": "oklch(0.7 0.25 145)",
                    "nearest": 5
                  }
                },
                "example2": {
                  "summary": "A deep teal HEX code",
                  "value": {
                    "color": "#164E63",
                    "nearest": 3
                  }
                },
                "example3": {
                  "summary": "A CSS named color",
                  "value": {
                    "color": "rebeccapurple",
                    "nearest": 3
                  }
                },
                "example4": {
                  "summary": "Display P3 red",
                  "value": {
                    "color": "color(display-p3 1 0 0)",
                    "nearest": 3
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LuminaColorConverterResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "LuminaColorConverterInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "color": {
            "title": "CSS color (HEX, name, rgb(), hsl(), hwb(), lab(), lch(), oklab(), oklch() or color())",
            "type": "string",
            "maxLength": 200,
            "default": "oklch(0.7 0.25 145)"
          },
          "nearest": {
            "title": "Nearest CSS named colors to list",
            "type": "integer",
            "minimum": 1,
            "maximum": 10,
            "default": 5
          }
        },
        "required": []
      },
      "LuminaColorConverterResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "input",
              "parsedSpace",
              "alpha",
              "named",
              "hex",
              "clippedHex",
              "inSrgb",
              "inDisplayP3",
              "mappingDeltaEOK",
              "rgb",
              "hsl",
              "hwb",
              "lab",
              "lch",
              "oklab",
              "oklch",
              "xyzD65",
              "xyzD50",
              "displayP3",
              "css",
              "contrastWhite",
              "contrastBlack",
              "nearestNamed"
            ],
            "properties": {
              "input": {
                "type": "string"
              },
              "parsedSpace": {
                "type": "string"
              },
              "alpha": {
                "type": "number"
              },
              "named": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "hex": {
                "type": "string"
              },
              "clippedHex": {
                "type": "string"
              },
              "inSrgb": {
                "type": "boolean"
              },
              "inDisplayP3": {
                "type": "boolean"
              },
              "mappingDeltaEOK": {
                "type": "number"
              },
              "rgb": {
                "type": "array",
                "items": {
                  "type": "integer"
                },
                "minItems": 3,
                "maxItems": 3
              },
              "hsl": {
                "type": "array",
                "items": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "minItems": 3,
                "maxItems": 3
              },
              "hwb": {
                "type": "array",
                "items": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "minItems": 3,
                "maxItems": 3
              },
              "lab": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "minItems": 3,
                "maxItems": 3
              },
              "lch": {
                "type": "array",
                "items": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "minItems": 3,
                "maxItems": 3
              },
              "oklab": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "minItems": 3,
                "maxItems": 3
              },
              "oklch": {
                "type": "array",
                "items": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "minItems": 3,
                "maxItems": 3
              },
              "xyzD65": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "minItems": 3,
                "maxItems": 3
              },
              "xyzD50": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "minItems": 3,
                "maxItems": 3
              },
              "displayP3": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "minItems": 3,
                "maxItems": 3
              },
              "css": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "hex",
                  "rgb",
                  "hsl",
                  "hwb",
                  "lab",
                  "lch",
                  "oklab",
                  "oklch",
                  "displayP3"
                ],
                "properties": {
                  "hex": {
                    "type": "string"
                  },
                  "rgb": {
                    "type": "string"
                  },
                  "hsl": {
                    "type": "string"
                  },
                  "hwb": {
                    "type": "string"
                  },
                  "lab": {
                    "type": "string"
                  },
                  "lch": {
                    "type": "string"
                  },
                  "oklab": {
                    "type": "string"
                  },
                  "oklch": {
                    "type": "string"
                  },
                  "displayP3": {
                    "type": "string"
                  }
                }
              },
              "contrastWhite": {
                "type": "number"
              },
              "contrastBlack": {
                "type": "number"
              },
              "nearestNamed": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "name",
                    "hex",
                    "deltaE2000"
                  ],
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "hex": {
                      "type": "string"
                    },
                    "deltaE2000": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}