Making Your First Request to the Palettes API
Every API endpoint accepts a color via query params in the same format to make the API as easy to use as possible.
Request Paramaters
These parameters apply to every API endpoint.
Required parameters
- Name
color
- Type
- string
- Description
The color(s) to be used in the requst. This can be hsl, rgb, or hex.
The color parameter can be in any of the following formats:
- Name
hex
- Type
- string
- Description
Can be "#FAFAFA" or "FAFAFA" or "fafafa"
- Name
hsl
- Type
- string
- Description
Can be "hsl(0, 0%, 98%)"
- Name
rgb
- Type
- string
- Description
Can be "rgb(250, 250, 250)"
Making a request
curl "https://palettespro.com/api/v1/<ENDPOINT>?color=<COLOR_VALUE>"
In some cases, an endpoint may accept multiple colors. In these cases, you can send your colors as an array of colors. For example, if you wanted to blend two colors, you could send the following request:
Color Array Example
/api/v1/blend-colors?color=FAFAFA&color=000000
Response
All of the endpoint will return colors in one or more of these formats:
- Name
hex
- Type
- string
- Description
The Hexadecimal color value with the # symbol.
- Name
hsl
- Type
- object
- Description
The HSL color value object.
- Name
h
- Type
- integer
- Description
The hue value.
- Name
s
- Type
- integer
- Description
The saturation value.
- Name
l
- Type
- integer
- Description
The lightness value.
- Name
rbg
- Type
- object
- Description
The RGB color value object. This object contains the following properties:
- Name
r
- Type
- integer
- Description
The red value.
- Name
g
- Type
- integer
- Description
The green value.
- Name
b
- Type
- integer
- Description
The blue value.
Response
{
"hex": "#00ffff",
"hsl":
{
"h": 180,
"s": 100,
"l": 50
},
"rgb":
{
"r": 0,
"g": 255,
"b": 255
}
}
Encoding your requests
Always remember to encode your requests. For example, if you're using JavaScript, you can use the encodeURIComponent() function to encode your query string parameters. If you're using Python, you can use the urllib.parse.quote() function to encode your query string parameters. Encoding ensures that special characters in the URL, like # for hex colors or parentheses in rgb() and hsl() functions, do not interfere with the URL's structure.
Color Format Conversion Examples
// JavaScript Example: Encoding a Hexadecimal Color
const hexColor = encodeURIComponent("#87CEEB");
const url = "https://palettespro.com/api/colors/blend?color=${hexColor}";
// Use fetch or another method to send the request