# Color Brightness Calculator API

> Color Brightness Calculator checks hex color brightness to classify values as light, dark, or medium, returning RGB components. Paid plans add WCAG contrast ratios, luminance scores, and recommended text colors.

**Endpoint:** `GET https://api.apiverve.com/v1/colorbrightness`  
**Category:** Reference Data  
**Cost:** 1 credit per call  
**Canonical page:** https://apiverve.com/marketplace/colorbrightness

## Overview

A color brightness API that tells you whether a hex color is light or dark before you put text on it. Send a hex value and get back its RGB channels, is_light and is_dark flags, and a brightness category on a six-step scale from very dark to very light. The calculation applies the WCAG 2.0 relative luminance formula, so the answer lines up with how accessibility checkers measure color.

Designers and front-end developers use it to pick a text color for user-chosen backgrounds, to theme badges and avatars generated from brand colors, and to audit a palette for color contrast and accessibility before release.

The Free plan returns the RGB breakdown, the light and dark flags and the brightness category. Paid plans add the luminance value itself, perceived brightness and YIQ scores, contrast ratios against white and black, pass or fail flags for WCAG AA and AAA with each, and a recommended text color that picks whichever of black or white reads better on that background.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl "https://api.apiverve.com/v1/colorbrightness?hex=FF5733" \
  -H "x-api-key: YOUR_API_KEY"
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `hex` | string | Yes | Hex color value (with or without # prefix). hexColor |

## Response fields

- `hex` — string · Hexadecimal color value provided in the request
- `rgb` — object · RGB color components: red, green, blue values
  - `rgb.r` — number · Red component value between 0 and 255
  - `rgb.g` — number · Green component value between 0 and 255
  - `rgb.b` — number · Blue component value between 0 and 255
- `luminance` — number · Relative luminance calculated using WCAG 2.0 formula · (premium)
- `perceived_brightness` — number · Perceived brightness score from 0 to 255 · (premium)
- `yiq` — number · YIQ color space brightness value for brightness analysis · (premium)
- `is_light` — boolean · True when black text contrasts better than white on this color (luminance about 0.179 or above)
- `is_dark` — boolean · True when white text contrasts better than black on this color; the opposite of is_light
- `brightness_category` — string · Brightness classification: very dark, dark, medium-dark, medium-light, light or very light; the dark buckets are exactly the colors that get white text
- `recommended_text_color` — string · Recommended text color for optimal contrast and readability · (premium)
- `contrast_ratio_with_white` — number · WCAG contrast ratio calculation between color and white · (premium)
- `contrast_ratio_with_black` — number · WCAG contrast ratio calculation between color and black · (premium)
- `wcag_aa_compliant_with_white` — boolean · Whether color meets WCAG AA contrast requirements with white · (premium)
- `wcag_aa_compliant_with_black` — boolean · Whether color meets WCAG AA contrast requirements with black · (premium)
- `wcag_aaa_compliant_with_white` — boolean · Whether color meets WCAG AAA contrast requirements with white · (premium)
- `wcag_aaa_compliant_with_black` — boolean · Whether color meets WCAG AAA contrast requirements with black · (premium)

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "hex": "#FF5733",
    "rgb": {
      "r": 255,
      "g": 87,
      "b": 51
    },
    "luminance": 0.2832,
    "perceived_brightness": 131,
    "yiq": 133.13,
    "is_light": false,
    "is_dark": true,
    "brightness_category": "dark",
    "recommended_text_color": "#FFFFFF",
    "contrast_ratio_with_white": 3.15,
    "contrast_ratio_with_black": 6.66,
    "wcag_aa_compliant_with_white": false,
    "wcag_aa_compliant_with_black": true,
    "wcag_aaa_compliant_with_white": false,
    "wcag_aaa_compliant_with_black": false
  }
}
```

## Use cases

- **Web Accessibility** — Ensure WCAG compliance by calculating contrast ratios for text and background colors
- **UI Design** — Determine appropriate text colors for backgrounds based on brightness calculations
- **Theme Development** — Automatically select light or dark text based on background color brightness
- **Color Analysis** — Analyze color brightness and categorize colors for design systems and palettes

## SDKs

- **npm** — `npm install @apiverve/colorbrightness` (https://www.npmjs.com/package/@apiverve/colorbrightness)
- **NuGet** — `dotnet add package APIVerve.API.ColorBrightnessCalculator` (https://www.nuget.org/packages/APIVerve.API.ColorBrightnessCalculator)
- **Source** — https://github.com/apiverve/colorbrightness-api

## More

- Full reference: https://docs.apiverve.com/ref/colorbrightness
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
