API Documentation

Overview

The Transparify API allows you to programmatically restore transparent backgrounds from image pairs. Send two images (one on white background, one on black) and receive the result with a recovered alpha channel.

Base URL: https://transparify.app/api/v1

Authentication

All API requests require a Bearer token. Create an API key in your dashboard.

Authorization: Bearer trns_xxxxxxxxxxxxxxxx

POST /api/v1/restore

Restore the alpha channel from a white/black image pair.

Request

ParameterTypeRequiredDescription
white_imageFileYesImage on white background
black_imageFileYesImage on black background
formatStringNopng (default) or webp
qualityIntegerNo1-100, WebP only (default: 90)

Each image must be under 20MB. Both images must have identical dimensions.

Response

On success, returns the processed image as binary data.

HeaderDescription
Content-Typeimage/png or image/webp
X-Processing-Time-MsServer processing time in milliseconds
X-Remaining-CallsRemaining API calls for the billing period

Code Examples

curl

curl -X POST https://transparify.app/api/v1/restore \
  -H "Authorization: Bearer trns_your_api_key" \
  -F "white_image=@white.png" \
  -F "black_image=@black.png" \
  -F "format=png" \
  -o result.png

Python

import requests

url = "https://transparify.app/api/v1/restore"
headers = {"Authorization": "Bearer trns_your_api_key"}

with open("white.png", "rb") as w, open("black.png", "rb") as b:
    response = requests.post(
        url,
        headers=headers,
        files={
            "white_image": ("white.png", w, "image/png"),
            "black_image": ("black.png", b, "image/png"),
        },
        data={"format": "png"},
    )

if response.status_code == 200:
    with open("result.png", "wb") as f:
        f.write(response.content)
    print(f"Processing time: {response.headers['X-Processing-Time-Ms']}ms")
    print(f"Remaining calls: {response.headers['X-Remaining-Calls']}")
else:
    print(f"Error: {response.json()}")

Node.js

import fs from "fs";

const form = new FormData();
form.append("white_image", new Blob([fs.readFileSync("white.png")]), "white.png");
form.append("black_image", new Blob([fs.readFileSync("black.png")]), "black.png");
form.append("format", "png");

const response = await fetch("https://transparify.app/api/v1/restore", {
  method: "POST",
  headers: { Authorization: "Bearer trns_your_api_key" },
  body: form,
});

if (response.ok) {
  const buffer = Buffer.from(await response.arrayBuffer());
  fs.writeFileSync("result.png", buffer);
  console.log("Processing time:", response.headers.get("X-Processing-Time-Ms"), "ms");
  console.log("Remaining calls:", response.headers.get("X-Remaining-Calls"));
} else {
  console.error("Error:", await response.json());
}

Go

package main

import (
	"bytes"
	"fmt"
	"io"
	"mime/multipart"
	"net/http"
	"os"
)

func main() {
	body := &bytes.Buffer{}
	writer := multipart.NewWriter(body)

	for _, f := range []struct{ field, path string }{
		{"white_image", "white.png"},
		{"black_image", "black.png"},
	} {
		file, _ := os.Open(f.path)
		defer file.Close()
		part, _ := writer.CreateFormFile(f.field, f.path)
		io.Copy(part, file)
	}
	writer.WriteField("format", "png")
	writer.Close()

	req, _ := http.NewRequest("POST", "https://transparify.app/api/v1/restore", body)
	req.Header.Set("Authorization", "Bearer trns_your_api_key")
	req.Header.Set("Content-Type", writer.FormDataContentType())

	resp, _ := http.DefaultClient.Do(req)
	defer resp.Body.Close()

	if resp.StatusCode == 200 {
		out, _ := os.Create("result.png")
		defer out.Close()
		io.Copy(out, resp.Body)
		fmt.Println("Processing time:", resp.Header.Get("X-Processing-Time-Ms"), "ms")
		fmt.Println("Remaining calls:", resp.Header.Get("X-Remaining-Calls"))
	}
}

Error Handling

Errors return JSON with an error field:

StatusMeaning
400Bad request (missing files, invalid format, dimension limit exceeded)
401Invalid or missing API key
404User not found
422Image processing failed (dimension mismatch, corrupt images)
429Rate limit or monthly quota exceeded
500Internal server error

Rate Limits & Quotas

PlanCalls/MonthRate LimitMax Image Size
Free5010/min2048x2048
Pro ($9/mo)1,00060/min4096x4096
Business ($29/mo)10,000200/min8192x8192

Rate limit responses include a 429 status code. Monthly quotas reset on the 1st of each month.

Ready to integrate?

Create API Key