Random Color
GEThttps://api-colors.dataandapis.com/v1/colors/random
Random Color is an endpoint of the Colors API. Name, convert and check contrast for any color, with 31,919 curated names and WCAG math.
Send your key in the X-Api-Key header. Each call costs 1 token; a free key includes 500 tokens a month.
Request
Query parameters
| Parameter | Example | |
|---|---|---|
| bestof | true | Optional |
Example request
curl
curl "https://api-colors.dataandapis.com/v1/colors/random?bestof=true" \
-H "X-Api-Key: YOUR_API_KEY"Node.js
const res = await fetch("https://api-colors.dataandapis.com/v1/colors/random?bestof=true", {
headers: { "X-Api-Key": process.env.DATAANDAPIS_KEY },
});
const data = await res.json();Python
import os, requests
r = requests.get(
"https://api-colors.dataandapis.com/v1/colors/random?bestof=true",
headers={"X-Api-Key": os.environ["DATAANDAPIS_KEY"]},
)
data = r.json()Example response
Example response{
"ok": true,
"color": {
"hex": "#c27f38",
"name": "Ginger Beer",
"is_bestof": true,
"is_css": false,
"rgb": {
"r": 194,
"g": 127,
"b": 56
},
"hsl": {
"h": 31,
"s": 55.2,
"l": 49.02
},
"hsv": {
"h": 31,
"s": 71.13,
"v": 76.08
},
"cmyk": {
"c": 0,
"m": 34.54,
"y": 71.13,
"k": 23.92
},
…
Show full response
Example response
{
"ok": true,
"color": {
"hex": "#c27f38",
"name": "Ginger Beer",
"is_bestof": true,
"is_css": false,
"rgb": {
"r": 194,
"g": 127,
"b": 56
},
"hsl": {
"h": 31,
"s": 55.2,
"l": 49.02
},
"hsv": {
"h": 31,
"s": 71.13,
"v": 76.08
},
"cmyk": {
"c": 0,
"m": 34.54,
"y": 71.13,
"k": 23.92
},
…{
"ok": true,
"color": {
"hex": "#c27f38",
"name": "Ginger Beer",
"is_bestof": true,
"is_css": false,
"rgb": {
"r": 194,
"g": 127,
"b": 56
},
"hsl": {
"h": 31,
"s": 55.2,
"l": 49.02
},
"hsv": {
"h": 31,
"s": 71.13,
"v": 76.08
},
"cmyk": {
"c": 0,
"m": 34.54,
"y": 71.13,
"k": 23.92
},
"luminance": 0.269,
"is_dark": false
}
}
