Pixel Harmony

Pixel Harmony API Reference

Overview

Pixel Harmony extracts color palettes from images and PDFs using AI. Each color gets a semantic role (primary, background, accent, etc.), WCAG contrast scores, and ready-to-paste CSS/SCSS/JS exports.

Base URL: https://pixelharmony.app  ·  Version: v1

Note: All API requests must be authenticated. The web app at / is free to use interactively.

Authentication

Pass your API key in the Authorization header on every request.

Authorization: Bearer ph_your_api_key_here

API keys start with ph_. Keep yours secret — treat it like a password.

Example with curl

curl -X POST https://pixelharmony.app/api/analyze-image \
  -H "Authorization: Bearer ph_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "base64": "<base64-encoded-image>",
    "mediaType": "image/png",
    "brandName": "Acme Corp"
  }'

Errors

StatusMeaning
401Missing or malformed Authorization header
403Invalid or revoked API key
400Bad request — missing required field
500Claude could not parse colors from the input

Error responses always include an error string field.

{ "error": "Missing or invalid Authorization header. Use: Bearer <api_key>" }

POST /api/analyze-image

POST /api/analyze-image

Extracts 5–7 dominant colors from an image. Assigns each a semantic role and returns WCAG contrast scores plus CSS/SCSS/JS export code.

Request body

FieldTypeRequiredDescription
base64stringYesBase64-encoded image data (no data URL prefix)
mediaTypestringNoMIME type — default image/jpeg. Accepts image/png, image/gif, image/webp
brandNamestringNoUsed to name variables in exported code (e.g. acme_corp)

Example response

{
  "colors": [
    {
      "hex": "#1A3A5C",
      "name": "Deep Navy",
      "usage": "primary",
      "wcag": {
        "vs_white": 10.54,
        "vs_white_level": "AAA",
        "vs_black": 1.99,
        "vs_black_level": "Fail"
      }
    },
    ...
  ],
  "exports": {
    "css": ":root {\n  --primary: #1A3A5C;\n  ...\n}",
    "scss": "$primary: #1A3A5C;\n...",
    "js": "export const acme_corpColors = { \"primary\": \"#1A3A5C\", ... };"
  }
}

POST /api/analyze-pdf

POST /api/analyze-pdf

Extracts brand colors from a PDF document (brand guides, decks, style docs). Returns the same structure as /api/analyze-image.

Request body

FieldTypeRequiredDescription
base64stringYesBase64-encoded PDF data
brandNamestringNoUsed to name export variables

GET /api/status

GET /api/status

Health check. No authentication required.

{ "status": "ok", "version": "1.0.0" }

Color Object

Every color in the colors array has these fields:

FieldTypeDescription
hexstringHex color value e.g. #1A3A5C
namestringDescriptive name e.g. Deep Navy
usagestringSemantic role: primary, secondary, accent, background, text, surface, border
wcagobjectWCAG contrast scores (see below)

WCAG Scores

Each color includes contrast ratios against white and black, with the WCAG 2.1 level.

FieldDescription
vs_whiteContrast ratio against #FFFFFF
vs_white_levelAAA (≥7), AA (≥4.5), AA Large (≥3), Fail
vs_blackContrast ratio against #000000
vs_black_levelSame scale

Exports

The exports object contains ready-to-use code in three formats:

KeyFormatUse case
cssCSS custom propertiesPaste into any stylesheet
scssSCSS variablesSass/SCSS projects
jsES module exportReact, Vue, Node.js design tokens