API Documentation

Seamlessly integrate AI-powered print generation into your application while maintaining full control over every print, transforming thermal printing into a versatile, touchable experience.

v0.0.1 Last updated: January 26, 2025

Getting Started

https://app.printercow.com/api

This is the base URL for the print API. All requests should be made to this URL.

API Reference

GET (SOON)

/magic

Submit raw data for printing. The AI model will automatically figure out how to fill the template. If not template is provided at all it will choose the best one. Whyt GET request? Because most LLMs are able to make a simple GET request as function call. Soon your voice assistant can just print stuff for you.

const response = await fetch(
  '/magic?text=' + YOUR_DATA_TEXT +
  '&printerId=' + YOUR_PRINTER_ID +
  '&templateId=' + YOUR_TEMPLATE_ID +
  '&token=' + process.env.PRINTERCOW_KEY,
  {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
    },
  }
);
POST

/print

Submit a template for printing. Requires valid Printercow API key.

const response = await fetch('/print', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${process.env.PRINTERCOW_KEY}`
  },
  body: JSON.stringify({
    printerId: "prt_XU...", // which printer to use
    templateId: "tpl_JG...", // which template to use
    params: data, // data for the template
  })
});

Example Parameters for a Template

// data variable
[
  {
    "uuid": "questionText", // UUID is defined in the template
    "params": {
      "text": "how tall is the Mount Everest?",
      ...  // Look into the template for more parameters like fontSize, width, ...
    },
  },
  {
    "uuid": "answerText",
    "params": {
      "text": "Reaching an elevation of 29,032 feet (8,849 meters), Mount Everest is the highest mountain in the world.",
    },
  }
]

The template follows a strict JSON structure with predefined UUIDs for different parameters.

Error Handling

Common Issues

  • 403 Forbidden: Invalid API key
  • 402 Payment Required: Insufficient credits
  • 400 Bad Request: Invalid parameters