apyhub
Back

Color Contrast & Conversion API

What it does

Color Contrast Checker compares a foreground and background color and returns the contrast ratio plus WCAG pass flags. Send two color values in the request body as foreground and background, and use the response to verify accessibility before you ship a UI.

The /design/contrast endpoint returns ratio from 1 to 21, along with aa, aaLarge, and aaa booleans. If the input is invalid, you get an error message instead of a contrast result. That makes it straightforward to plug into design systems, component libraries, or automated checks for button labels, charts, and other text-on-color combinations.

Color Contrast Checker also includes /design/color-convert for translating colors between hex, rgb, and hsl. Provide a hex string or RGB channel values in the request body, and get back normalized hex, rgb, and hsl values. Use it when you need to accept one format from a design tool and store or display another in your app.

▣ ENDPOINT 01 / 02
POST
WCAG Color Contrast Checker
https://api.eu.apyhub.com/freedailypro/color-contrast-conversion-api/design/contrast

QUICKSTART

GUIDE

Quickstart

Compare a foreground and background color for contrast by sending both hex values in the request body.

curl -X POST "https://api.eu.apyhub.com/freedailypro/color-contrast-conversion-api/design/contrast" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"foreground":"#000000","background":"#ffffff"}'

What you'll get back

The live response to the request above:

{
  "tool": "Contrast checker client and server side from freedailypro",
  "ratio": 21,
  "aa": true,
  "aaa": true,
  "aaLarge": true
}
TRY ITLIVE · 10 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*

About this endpoint

What it does

Checks whether two colors have enough contrast to be readable, using the WCAG accessibility guidelines. Send a foreground (text) color and a background color as hex codes, and get back the contrast ratio from 1 to 21 and whether it passes WCAG AA, AAA and AA for large text. Use it in design tools, theme builders and accessibility audits.

Request Body

ParameterTypeMandatoryDescription
foregroundStringYesForeground color as a hex code, e.g. #000 or #000000. rgb() and color names are not supported.
backgroundStringYesBackground color as a hex code, e.g. #fff or #ffffff. rgb() and color names are not supported.

Response

A successful call returns a JSON object with these fields:

ParameterTypeDescription
toolStringName of the tool that produced the response.
ratioNumberContrast ratio between the two colors, from 1 to 21.
aaBooleantrue if the ratio meets WCAG AA for normal text (4.5 or higher).
aaaBooleantrue if the ratio meets WCAG AAA for normal text (7 or higher).
aaLargeBooleantrue if the ratio meets WCAG AA for large text (3 or higher).
errorStringError message. Present only when the input is invalid, e.g. "Invalid hex color".

If a color is not a valid hex code, the API returns {"error":"Invalid hex color"}.

▣ ENDPOINT 02 / 02
POST
Hex, RGB & HSL Color Converter
https://api.eu.apyhub.com/freedailypro/color-contrast-conversion-api/design/color-convert

QUICKSTART

GUIDE

Quickstart

Convert a color by sending the RGB or hex values in a JSON body.

curl -X POST "https://api.eu.apyhub.com/freedailypro/color-contrast-conversion-api/design/color-convert" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"hex":"#1e90ff"}'

What you'll get back

The live response to the request above:

{
  "tool": "Color converter client and server side from freedailypro",
  "hex": "#1e90ff",
  "rgb": {
    "r": 30,
    "g": 144,
    "b": 255
  },
  "hsl": {
    "h": 210,
    "s": 100,
    "l": 55.9
  }
}
TRY ITLIVE · 10 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*

About this endpoint

What it does

Converts a color between hex, RGB and HSL. Send either a hex code (such as #FF5733) or r, g and b values from 0 to 255, and get the same color back in all three formats. If both are sent, hex is used. Use it in design tools, theme builders and CSS generators.

Request Body

ParameterTypeMandatoryDescription
bNumberNoBlue channel value. Must be between 0 and 255.
gNumberNoGreen channel value. Must be between 0 and 255.
rNumberNoRed channel value. Must be between 0 and 255.
hexStringNoHex color string.

Response

A successful call returns a JSON object with these fields:

ParameterTypeDescription
toolStringName of the tool that produced the response.
hexStringColor as a hex code, e.g. #FF5733.
rgbObjectColor as RGB values.
rgb.rNumberRed channel, 0–255.
rgb.gNumberGreen channel, 0–255.
rgb.bNumberBlue channel, 0–255.
hslObjectColor as HSL values.
hsl.hNumberHue in degrees, 0–360.
hsl.sNumberSaturation in percent, 0–100.
hsl.lNumberLightness in percent, 0–100.
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.