Color Name to RGB API¶
Overview¶
Convert a color name to its red, green, and blue components. The request is synchronous and accepts a JSON body containing a color value.
Endpoint¶
POST https://api.apidatatools.com/colorname-to-rgb-api
Authentication¶
Include your API key in the x-api-key header:
x-api-key: YOUR_API_KEY
Input modes¶
This endpoint supports body mode only. Requests are processed synchronously.
Headers¶
| Header | Type | Required | Default / values | Description |
|---|---|---|---|---|
x-api-key | string | Yes | Your API key | Authenticates the request. |
x-source-type | string | No | Defaults to body; use body for this endpoint. | Selects the input source type. |
Header names are case-insensitive.
Request body¶
Send a JSON object with a color key.
| Field | Required | Description |
|---|---|---|
color | Yes | Color name to look up. Leading and trailing whitespace are trimmed, and the value is converted to lowercase before lookup. |
Example:
{
"color": "red"
}
curl example¶
curl -X POST "https://api.apidatatools.com/colorname-to-rgb-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: body" \
--data '{"color":"red"}'
Success response¶
A successful response has HTTP status 200 and includes:
| Field | Description |
|---|---|
request_id | Identifier for the request. |
status | success when the conversion completes. |
preview | A string containing a formatted JSON object with the r, g, and b components for the requested color. |
The component values depend on the color name supplied. The preview field is serialized JSON, so its value is a string rather than a nested JSON object.
Error handling¶
Errors use an envelope containing status, error, request_id, and details.message. Additional fields may appear in details.
| HTTP status | Error code | Cause |
|---|---|---|
| 400 | INVALID_JSON | The request body is not valid JSON. |
| 400 | MISSING_COLOR_NAME | The JSON object does not contain a color key. |
| 400 | EMPTY_COLOR_NAME | The supplied color value is empty after trimming. |
| 400 | UNKNOWN_COLOR_NAME | The color name is not recognized. The error may include available color names in details. |
| 400 | EMPTY_BODY | The request body is empty. |
| 400 | INVALID_BODY_ENCODING | The request body could not be decoded. |
| 400 | INVALID_SOURCE_TYPE | The x-source-type value is not recognized. |
| 401 | UNAUTHORIZED | Authentication is missing or invalid. |
| 404 | USER_NOT_FOUND | The authenticated user could not be found. |
| 404 | UNKNOWN_FUNCTION | The requested endpoint is not supported. |
| 413 | PAYLOAD_TOO_LARGE | The request body exceeds the limit for the plan. |
| 429 | QUOTA_EXCEEDED | The plan’s request quota has been exhausted. |
| 429 | RATE_LIMITED | The request rate limit has been exceeded. |
| 500 | PLAN_NOT_FOUND | The plan configuration could not be found. |
| 500 | INTERNAL_ERROR | An unexpected error occurred while processing the request. |
Notes¶
- Body-size limits, quotas, and rate limits depend on the plan. See tool limits.
- Color names are matched against the endpoint’s available color-name database; this reference does not enumerate that database.