Contrast Checker API
WCAG contrast ratio between two colours, with AA and AAA results.
POST /api/v1/tools/contrast-checkerMCP contrast_checkerDesign & ColourCheck the contrast ratio between text and background colours against WCAG 2.x AA and AAA for normal and large text, with a live preview of both.
Input
Send these as a JSON object. Unknown fields are rejected.
- foreground
- Text colour, e.g. #767676 or rgb(118 118 118). (string, required)
- background
- Background colour, e.g. #ffffff. (string, required)
curl https://pithlab.com/api/v1/tools/contrast-checker \n -H "Authorization: Bearer $PITHLAB_KEY" \n -H "Content-Type: application/json" \n -d '{"foreground":"#767676","background":"#ffffff"}'Example response
{
"ok": true,
"result": {
"ratio": 4.542224959605253,
"ratioText": "4.54",
"ok": true,
"foreground": {
"r": 118,
"g": 118,
"b": 118,
"a": 1
},
"background": {
"r": 255,
"g": 255,
"b": 255,
"a": 1
},
"checks": {
"aaNormal": true,
"aaLarge": true,
"aaaNormal": false,
"aaaLarge": true,
"uiComponents": true
},
"notes": []
}
}