Guides

Material Palette JSON API

Two read-only endpoints serve the classic Material Design colors and every primary and accent palette as JSON. No API key, any origin can call them (CORS is open), and responses are cached for a day.

All colors

GET https://www.materialpalette.com/api/colors.json

Returns the 19 color families with every shade (50 to 900, and A100 to A700 where they exist) as uppercase hex.

A palette

GET https://www.materialpalette.com/api/palettes/{primary}/{accent}.json

Returns the palette's roles (with the same names as the Android XML download), both color families and download links. For example, https://www.materialpalette.com/api/palettes/indigo/pink.json:

{
  "name": "Indigo and Pink",
  "url": "https://www.materialpalette.com/indigo/pink",
  "roles": {
    "primary": "#3F51B5",
    "primary_dark": "#303F9F",
    "primary_light": "#C5CAE9",
    "accent": "#FF4081",
    "icons": "#FFFFFF",
    "primary_text": "#212121",
    "secondary_text": "#757575",
    "divider": "#BDBDBD"
  },
  "primary": { "key": "indigo", "name": "Indigo", "shades": { "50": "#E8EAF6", … } },
  "accent": { "key": "pink", "name": "Pink", "shades": { … } },
  "downloads": { "css": "…", "sass": "…", "less": "…", "svg": "…", "xml": "…", "polymer": "…" }
}

Color keys

red, pink, purple, deep-purple, indigo, blue, light-blue, cyan, teal, green, light-green, lime, yellow, amber, orange, deep-orange, brown, grey, blue-grey. Primary and accent must be different colors for the palette page, but the API accepts any pair.

Example

const res = await fetch('https://www.materialpalette.com/api/palettes/teal/amber.json');
const { roles } = await res.json();
document.documentElement.style.setProperty('--primary', roles.primary);
document.documentElement.style.setProperty('--accent', roles.accent);

Please link back to materialpalette.com if you use it in a public project.