Skip to content

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.

Last updated: February 14, 2025

Getting Started

All API requests should be directed to our base URL:

This is the central endpoint for all printing operations and management requests.

API Endpoints

GET /magic

Submit raw data for printing. The AI model will automatically choose and fill in the appropriate template.
If no template is provided, it selects the best match.

Why GET?
Most LLMs can easily make a GET request as a function call, enabling seamless integration with voice assistants and other services.

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

POST /print

Submit a template for printing. This endpoint requires a valid Printercow API key.
Include the printer ID, template ID, and the necessary parameters in your request.

js
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
  })
});

Template Parameters

The data for a template must adhere to a strict JSON structure with predefined UUIDs for different parameters.

Example:

json
[
  {
    "uuid": "questionText", // UUID defined in the template
    "params": {
      "text": "How tall is Mount Everest?",
      // Additional parameters (e.g., fontSize, width) can be added here.
    }
  },
  {
    "uuid": "answerText",
    "params": {
      "hidden": true, // This will hide the element
      "text": "Mount Everest stands at 29,032 feet (8,849 meters), making it the highest mountain in the world."
    }
  }
]

Error Handling

When interacting with the API, you might encounter errors such as:

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

WARNING

Ensure you are using a valid API key and providing all required parameters correctly.

Additional Information

For more details and advanced usage, please visit our API documentation portal.
If you need assistance, contact our support team at hello@printercow.com.


Enjoy integrating Printercow's innovative printing capabilities into your application!