Detect Main Image Color API

Detect the main color of an image. The API returns a list of colors and their hex codes. The API supports images in the following formats: JPEG, PNG, and GIF.

The detected colors are given in hex code and their specific and main color (color family) names.

GET
https://api.apileague.com/detect-color

Parameters

NameExampleDescription
url
s r q
https://fastly.picsum.photos/id/63/5000/2813.jpg?hmac=HvaeSK6WT-G9bYF_CyB2m1ARQirL8UMnygdU9W6PDvM The url of the image for which the colors should be detected.
api-key
s r q
abcd1234Your API key.
Example Request and Response
GET
https://api.apileague.com/detect-color?url=https%3A%2F%2Ffastly.picsum.photos%2Fid%2F63%2F5000%2F2813.jpg%3Fhmac%3DHvaeSK6WT-G9bYF_CyB2m1ARQirL8UMnygdU9W6PDvM
[
    {
        "hex_code": "#b01c20",
        "specific_color": "Firebrick",
        "main_color": "Red"
    },
    {
        "hex_code": "#bfaf9a",
        "specific_color": "Thistle Green",
        "main_color": "Green"
    },
    {
        "hex_code": "#36180d",
        "specific_color": "Brown Pod",
        "main_color": "Brown"
    }
]
 Copy Codecurl -X GET 'https://api.apileague.com/detect-color?url=https%3A%2F%2Ffastly.picsum.photos%2Fid%2F63%2F5000%2F2813.jpg%3Fhmac%3DHvaeSK6WT-G9bYF_CyB2m1ARQirL8UMnygdU9W6PDvM' \ -H 'x-api-key: myapikey'

Headers

Response Headers:

  • Content-Type: application/json
  • X-API-Quota-Request: The number of tokens used by the request
  • X-API-Quota-Used: The number of tokens used in total today
  • X-API-Quota-Left: The number of tokens left today (depends on your plan)

Frequently Asked Questions

What image formats are supported?

The API supports common image formats including JPEG, PNG, and GIF.

Does it return the exact color or a general color name?

The API returns both the specific hex code of the detected color and the general "main color" family (e.g., Red, Blue, Green) it belongs to.

Can I use this for sorting images by color?

Yes, by using the "main color" returned by the API, you can easily categorize and sort images based on their dominant color family.

How is the Detect Main Image Color API different from the Search Images API?

The Detect Main Image Color API analyzes an uploaded or linked image to find its dominant color, whereas the Search Images API allows you to find images based on keywords or color filters.

Questions? Need Help? Ask Away

Quotas

Calling this endpoint costs
2 tokens