GET /api/colors
Retrieve a complete list of all available colors extracted from the wallpaper collection. Use this endpoint to discover which colors you can filter by when requesting wallpapers.This endpoint fetches color data from a GitHub repository file (
tags.json) and extracts all unique colors from the wallpaper metadata. Colors are returned with their names and corresponding hex values.Query parameters
This endpoint does not accept any query parameters.Response
Returns an array of color objects.Name of the color (e.g.,
darkslategray, black, blue)Hexadecimal color code (e.g.,
#2F4F4F, #000000)Error responses
Error message describing what went wrong
- GitHub configuration is missing (GITHUB_REPO_OWNER or GITHUB_REPO_NAME)
- Failed to fetch the tags.json file from GitHub
- Invalid response format from GitHub API
- Any other server error occurs
Examples
Example response
Example error response
How colors are extracted
The endpoint retrieves colors through the following process:- Fetches
tags.jsonfrom the configured GitHub repository - Decodes the base64-encoded file content
- Parses the JSON data
- Iterates through all wallpaper entries
- Collects colors from the
colorsarray of each entry - Removes duplicates using a Set
- Maps color names to hex values using a predefined color map
- Returns an array of unique colors with their hex codes
Color mapping
The endpoint includes a color mapping function that converts color names to hex codes. Currently supported colors include:darkslategray: #2F4F4Fblack: #000000
#000000 (black). The color map can be extended by updating the getColorHex function in the source code.
Using colors with other endpoints
Once you retrieve the available colors, you can use them to filter wallpapers:Requirements
This endpoint requires the following environment variables to be configured:NEXT_PUBLIC_GITHUB_ACCESS_TOKEN- GitHub personal access tokenNEXT_PUBLIC_GITHUB_REPO_OWNER- GitHub repository ownerNEXT_PUBLIC_GITHUB_REPO_NAME- GitHub repository name
tags.json file at the root level with wallpaper metadata including color information.