DDiwigo API

Color Contrast Checker API (WCAG)

WCAG 2 contrast ratio between a text colour and a background, with AA/AAA results.

What is it?

The Diwigo contrast API computes the WCAG 2 contrast ratio between a text colour and a background, and tells whether it passes AA and AAA.

It answers with JSON and is included in the free plan: 10,000 requests per API key and per month.

Example request

GET https://landing.diwigo.com/api/?key=YOUR_API_KEY&contrast=777777&bg=ffffff

Parameters

ParameterDescription
keyYour API key (required)
contrastText colour (hex)
bgBackground colour (hex, default ffffff)

Example response

{
  "ratio": 4.48,
  "AA": { "normal_text": false, "large_text": true },
  "AAA": { "normal_text": false, "large_text": false },
  "best_text_on_background": "#000000"
}

Code examples

cURL
curl "https://landing.diwigo.com/api/?key=YOUR_API_KEY&contrast=777777&bg=ffffff"
JavaScript
const res = await fetch("https://landing.diwigo.com/api/?key=YOUR_API_KEY&contrast=777777&bg=ffffff");
const data = await res.json();
console.log(data);
PHP
<?php
$response = file_get_contents("https://landing.diwigo.com/api/?key=YOUR_API_KEY&contrast=777777&bg=ffffff");
$data = json_decode($response, true);
print_r($data);
Python
import requests

response = requests.get("https://landing.diwigo.com/api/?key=YOUR_API_KEY&contrast=777777&bg=ffffff")
print(response.json())

Use cases

  • Check brand colours for accessibility
  • Pick black or white text for any background
  • Audit design systems automatically

Colour contrast: questions and answers

What does the Colour contrast API do?

The Diwigo contrast API computes the WCAG 2 contrast ratio between a text colour and a background, and tells whether it passes AA and AAA.

How do I call the Colour contrast API?

Send a GET request to https://landing.diwigo.com/api/?key=YOUR_API_KEY&contrast=777777&bg=ffffff with your own API key instead of YOUR_API_KEY. It answers with JSON.

Is the Colour contrast API free?

Yes, it is included in the free plan: 10,000 requests per API key and per calendar month, shared by all Diwigo endpoints. Higher limits are available on request.