Colour Palette Generator

Colour Palette Generator API

Design

Generate harmonious colour palettes with customizable options.

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 seed every call returns a different palette. With a seed, the same seed and settings always return the same palette.
  • count is 2-20. quality is 1-100; higher values take more iterations to space the colours out.
  • clustering picks the algorithm: "force-vector" (default) or "k-means".

Endpoints

POST
https://opentools.ca/api/v1/tools/colour-palette-generator
Generate a palette of distinct colours. GET with the same fields as query parameters also works.

Request Body

Content-Type: application/json

ParameterTypeRequiredDescription
count
number
OptionalNumber of colours, 2-20Default: 5
clustering
string
Enum: force-vector, k-means
OptionalClustering algorithmDefault: force-vector
seed
string
OptionalOptional seed, up to 100 characters, for repeatable results
quality
number
OptionalQuality, 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 invalid
401
Unauthorized - Invalid or missing API key
403
Forbidden - API key is inactive or expired, or the request IP is not allowed
429
Too Many Requests - Rate limit exceeded
500
Internal Server Error

Code 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"

Ready to get started?

Create an API key to start using the Colour Palette Generator API.

Rather use it in your browser? Open the Colour Palette Generator