there's no real API per se, just file format. Here's an example theme file attached.
Themes list bare minimum colors needed to make a theme, with all other missing colors derived but overridable. The absolute bare minimum (in v2) is bg, fg, text, link, also cRed, cBlue, cOrange, cGreen are optional.
There are several versions of theme format, all of them are JSON:
v2: current format, for colors you should look into "colors" property of theme object. there are also radii which is used to define roundness of elements/avatars
v1s: older format but similar to v2, has some names changed (v2 tried to clear up confusion), v2 text = v1s fg, v2 fg = v1s btn.
v3: future, will be backward compatible, there at least plans to make "accent" color which essentially will replace "link" for most part, so that you can change links colors without changing other link-colored elements
v1: this one is completely different and instead of an object uses an array. Colors are defined in following order:
0: not a color, just a readable theme name
--- following colors are technically optional
v1 is how themes were defined on instance in /static/styles.json (technically part of PleromaFE), there are still some around
v1s is how said themes were stored in localstorage and how they were exported into file when clicking "export theme". For files there's filed _pleroma_theme_version, if it's not present - assume it's v1s if it's an object.
Instance provides the aforementioned /static/styles.json ( https://git.pleroma.social/pleroma/pleroma-fe/blob/develop/static/styles.json
) which is an object with keys being machine-friendly name of theme and value being either theme itself (v1 only right now, don't remember if v2 is supported) or a string pointing to theme file, this is used to provide some built-in theme presets to the user. Each instance also has configuration at /api/statusnet/config.json (also has a fallback for relevant data at /static/config.json ) in which pleroma-fe uses property at site.pleromafe.theme which is the machine-friendly name of the theme to be used by default when user hasn't selected any theme yet.
hope that made any sense.
there's also a site someone made to host some user-created themes https://plthemes.vulpes.one/pleroma_theme(37).json