Color Palette API
Description
Generate a color palette of up to 6 different colors based on your input parameters. If no seed parameters are provided, the endpoint will generate random seed values.
Endpoint
> GET https://api.jsonrepo.com/v1/compute/generator/colorpalette
Headers
Field | Description |
---|---|
api_key | Required Your API Key |
Parameters
Field | Type | Description |
---|---|---|
color | String | Optional Seed HEX color A random seed will be used if none provided Example: #E6D690 |
size | Integer | Optional Number of colors the palette should consist of Default: 5 Range: 4 <= size <= 6 |
randomness | Integer | Optional The randomness factor Default: 50 Range: 20 <= randomness <= 80 |
How it works:
This function generates a palette by relating colors to each other based on the seed
color
luminosity &randomness
parameter. Because of this, it is important to understand that using extremecolor
values such as#FFFFFF
(all white) or#000000
(all black) will result in a less than ideal palette. The endpoint won't have much to use in terms of color information. It is therefore recommended that you increase therandomness
factor when using such extreme values as input.
Color Sorting:
The palette returned will be sorted according to color Luma. Sorting a color palette 100% accurately is actually very difficult as collapsing a 3 variable output into a one dimensional list is a lossy process.
Cohesion:
For the best possible palette cohesion,
size
of 4 or 5 is recommended. This minimizes the noise and allows for better color picking.
Response
A successful request will result in a populated payload
field with the expected output.
A failed request will result in an error output as detailed in Error Rules. If the endpoint validation fails due to missing, badly formatted or invalid parameters, the endpoint will return HTTP code 400
along with a message
detailing the error.
See the examples section for more information.
Request
- Curl
// Create a palette without a seed
curl -G \
https://api.jsonrepo.com/v1/compute/generator/colorpalette \
-H "api_key: {YOUR_API_KEY_HERE}"
// Create a 4 color palette based on a seed color
curl -G \
https://api.jsonrepo.com/v1/compute/generator/colorpalette \
-H "api_key: {YOUR_API_KEY_HERE}" \
--data-urlencode "color=#660EB9" \
--data-urlencode "randomness=70" \
--data-urlencode "size=4"
Success Response
{
"http_code": 200,
"http_message": "Ok",
"message": "Successful execution",
"payload": {
"palette": {
"base_color": "#660EB9",
"colors": [
"#e6cffb",
"#b36ef4",
"#7b27c1",
"#643488",
"#660EB9"
]
}
}
}
Error Response Examples
// Request with an invalid HEX seed `color` value
{
"http_code": 400,
"http_message": "Bad Request",
"message": "Malformed request: `color` parameter is not a valid hex color value.",
"payload": []
}
// Request with `randomness` set to 100
{
"http_code": 400,
"http_message": "Bad Request",
"message": "Malformed request: `randomness` parameter must be a number between 20 and 80. Default is 50.",
"payload": []
}