Authentication
All API requests require a valid API key passed in the Authorization header as a Bearer token.
Rate Limit
120 requests per minute
Endpoints
1 endpoint available
Overview
Generate a palette of visually distinct colours with the iwanthue algorithm, the same one the web page uses. It spreads the colours apart so they are easy to tell from each other, which suits chart series and category labels. Colours are returned as hex strings. The endpoint accepts GET with query parameters or POST with a JSON body.
Notes
- Without a
seedevery call returns a different palette. With aseed, the same seed and settings always return the same palette. countis 2-20.qualityis 1-100; higher values take more iterations to space the colours out.clusteringpicks the algorithm: "force-vector" (default) or "k-means".
Endpoints
POST
https://opentools.ca/api/v1/tools/colour-palette-generatorGenerate a palette of distinct colours. GET with the same fields as query parameters also works.
Request Body
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
| count | number | Optional | Number of colours, 2-20Default: 5 |
| clustering | string Enum: force-vector, k-means | Optional | Clustering algorithmDefault: force-vector |
| seed | string | Optional | Optional seed, up to 100 characters, for repeatable results |
| quality | number | Optional | Quality, 1-100Default: 50 |
Response Example
{
"success": true,
"count": 5,
"clustering": "force-vector",
"quality": 50,
"seed": "opentools",
"colours": [
"#ef3142",
"#7cda4a",
"#c854da",
"#01ccbe",
"#823a5a"
]
}Error Codes
400
Bad Request - Count, quality or clustering is out of range or invalid401
Unauthorized - Invalid or missing API key403
Forbidden - API key is inactive or expired, or the request IP is not allowed429
Too Many Requests - Rate limit exceeded500
Internal Server ErrorCode Examples
curl -X POST https://opentools.ca/api/v1/tools/colour-palette-generator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"count": 5,
"seed": "opentools"
}'
# GET works too
curl "https://opentools.ca/api/v1/tools/colour-palette-generator?count=8&clustering=k-means" \
-H "Authorization: Bearer YOUR_API_KEY"Rather use it in your browser? Open the Colour Palette Generator
