HEX to RGB API Documentation¶
Overview¶
The HEX to RGB API converts a hexadecimal color code into its corresponding RGB (Red, Green, Blue) representation.
It supports both 3-digit and 6-digit HEX formats, with or without the leading #.
Example conversions: - #FF0080 → { "r": 255, "g": 0, "b": 128 } - F08 → { "r": 255, "g": 0, "b": 136 }
This API operates synchronously and accepts input only in Body Mode.
Endpoint (POST)¶
POST https://api.apidatatools.com/hex-to-rgb-api
Headers¶
| Header | Type | Required | Description |
|---|---|---|---|
Content-Type | application/json | Yes | Must be application/json |
x-api-key | string | Yes | Your API key for authentication |
x-source-type | string | Optional | Defaults to body. Only body mode is supported for this tool. |
Accepted File Extensions¶
This tool does not support file or URL input modes.
Only JSON body input is accepted.
Input Example (Body Mode)¶
{
"hex": "#FF0080"
}
Alternate valid inputs:
{ "hex": "FF0080" }
{ "hex": "F08" }
Input Example (URL Mode)¶
Not applicable. This tool does not support URL-based input.
Input Example (File Mode)¶
Not applicable. This tool does not support file-based input.
Example Request¶
Synchronous (Body Input)¶
curl -X POST "https://api.apidatatools.com/hex-to-rgb-api" \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"hex": "#FF0080"}'
Asynchronous (Remote File URL)¶
Not applicable.
Asynchronous (Input File)¶
Not applicable.
Example Response¶
Successful (Body Mode)¶
Status Code: 200 OK
{
"status": "success",
"request_id": "a1b2c3d4-5678-90ef-ghij-klmnopqrstuv",
"preview": "{\n \"r\": 255,\n \"g\": 0,\n \"b\": 128\n}"
}
Async Job Accepted¶
Not applicable. This tool does not create asynchronous jobs.
Error Handling¶
Possible Errors¶
| Error Code | HTTP Status | Message | Example Details |
|---|---|---|---|
INVALID_JSON | 400 | Input must be valid JSON. | { "message": "Expecting value: line 1 column 1 (char 0)" } |
MISSING_HEX_VALUE | 400 | JSON must contain a 'hex' field. | { "input_keys": [] } |
EMPTY_HEX_VALUE | 400 | HEX value cannot be empty. | — |
INVALID_HEX_FORMAT | 400 | HEX must be 3 or 6 hex characters (with or without #). | { "hex_input": "ZZZZZZ" } |
HEX_TO_RGB_FAILED | 400 | Failed to convert HEX to RGB. | { "message": "invalid literal for int() with base 16: ..." } |
PAYLOAD_TOO_LARGE | 413 | Request body exceeds plan limit. | { "message": "Request body exceeds XKB limit for your plan." } |
UNKNOWN_FUNCTION | 404 | Unsupported API endpoint. | — |
INTERNAL_ERROR | 500 | Failed to process your request. | — |
Example Error Response¶
Status Code: 400 Bad Request
{
"status": "error",
"error": "INVALID_HEX_FORMAT",
"request_id": "a1b2c3d4-5678-90ef-ghij-klmnopqrstuv",
"details": {
"message": "HEX must be 3 or 6 hex characters (with or without #).",
"hex_input": "ZZZZZZ"
}
}
Async Job Status¶
Not applicable. This tool does not support asynchronous job processing.
Notes for Developers¶
- This API only supports Body Mode input with JSON payloads.
- The
hexfield is mandatory and must be a valid 3- or 6-digit hexadecimal string. - The response includes a
request_idfor traceability and logging. - The output is always returned as a JSON object containing the RGB values.
- No file or URL-based processing is available for this endpoint.