Skip to content

RGB to CSS Color Name API Documentation

Overview

This API converts an RGB color value into the closest CSS color name.
It accepts a JSON body containing red, green, and blue components and returns the nearest CSS color name.

Base URL:
https://api.apidatatools.com/rgb-to-css-color-api


Endpoint (POST)

POST https://api.apidatatools.com/rgb-to-css-color-api

This endpoint performs a synchronous conversion of RGB values to the nearest CSS color name.


Headers

Header Description Required Example
Content-Type Must be application/json Yes application/json
x-source-type Defines input mode. Only body is supported for this tool. Optional body
x-api-key Your API key for authentication Yes abcd1234xyz

Accepted File Extensions

This tool does not support file or URL input modes.
Only body mode is available.


Input Example (Body Mode)

{
  "r": 255,
  "g": 0,
  "b": 128
}

Example Request

Synchronous (Body Input)

POST https://api.apidatatools.com/rgb-to-css-color-api

Headers:

Content-Type: application/json
x-source-type: body
x-api-key: YOUR_API_KEY

Body:

{
  "r": 255,
  "g": 0,
  "b": 128
}


Example Response

Successful (Body Mode)

Status Code: 200 OK

{
  "status": "success",
  "request_id": "b3f8e9a2-7c1d-4c8a-9e12-5f3c1a9b2d4f",
  "preview": "{\n  \"name\": \"deeppink\"\n}"
}

Error Handling

Possible Errors

Error Code HTTP Status Message Example
INVALID_JSON 400 Input must be valid JSON. {"status":"error","error":"INVALID_JSON","request_id":"...","details":{"message":"Input must be valid JSON."}}
MISSING_RGB_VALUES 400 JSON must contain r, g, b keys. {"status":"error","error":"MISSING_RGB_VALUES","request_id":"...","details":{"input_keys":["r"]}}
INVALID_RGB_NUMBER 400 r, g, b must be numeric values. {"status":"error","error":"INVALID_RGB_NUMBER","request_id":"...","details":{"values":{"r":"a","g":0,"b":255}}}
RGB_OUT_OF_RANGE 400 RGB values must be between 0 and 255. {"status":"error","error":"RGB_OUT_OF_RANGE","request_id":"...","details":{"r":300,"g":0,"b":0}}
NO_COLOR_MATCH 400 Unable to determine closest color. {"status":"error","error":"NO_COLOR_MATCH","request_id":"...","details":{"message":"Unable to determine closest color."}}
EMPTY_BODY 400 Request body is empty. {"status":"error","error":"EMPTY_BODY","request_id":"...","details":{"message":"Request body is empty."}}
PAYLOAD_TOO_LARGE 413 Request body exceeds plan limit. {"status":"error","error":"PAYLOAD_TOO_LARGE","request_id":"...","details":{"message":"Request body exceeds limit."}}
UNKNOWN_FUNCTION 404 Unsupported API endpoint. {"status":"error","error":"UNKNOWN_FUNCTION","request_id":"...","details":{"message":"Unsupported API endpoint."}}
INTERNAL_ERROR 500 Failed to process your request. {"status":"error","error":"INTERNAL_ERROR","request_id":"...","details":{"message":"Failed to process your request"}}

Async Job Status

This tool does not support asynchronous operations (url or file modes).
No job status endpoint applies.


Notes for Developers

  • This API only supports body mode input.
  • Input must be valid JSON containing numeric RGB values between 0 and 255.
  • The response always includes a request_id for tracking.
  • The output is a JSON object with the closest CSS color name.
  • No file upload or remote URL processing is available for this tool.
  • Ensure proper error handling for malformed JSON or invalid RGB ranges.
  • The API is stateless and synchronous; each request is processed immediately.