Unofficial GOOJPRT PT-210 SDK
A Python driver for the 58 mm thermal printer that the vendor forgot to document.
Not affiliated with, endorsed by, or supported by GOOJPRT. Reverse-engineered from packet captures, sweat, and a little bit of thermal paper.
AIDD — AI Driven Development This project was written using AI-assisted development. The architecture, implementation, and documentation were produced through iterative collaboration with AI coding assistants (GitHub Copilot / Claude). Human judgment directed the design; AI did the heavy lifting.
What is this?
The GOOJPRT PT-210 is a compact 58 mm Bluetooth thermal printer sold under various white-label brands. GOOJPRT provides no official SDK, no protocol documentation, and no support for third-party integration. This library fills that gap.
It was created to enable reliable programmatic printing — text, barcodes, QR codes, bitmap images — from Python, without depending on proprietary Android apps or undocumented firmware quirks. The protocol was reverse-engineered from Bluetooth packet captures.
Full documentation: goojprt-pt210-sdk.readthedocs.io
Features
- BLE (Bluetooth Low Energy) — async, cross-platform (macOS, Windows, Linux)
- SPP (classic RFCOMM) — synchronous, Linux only
- Text printing — native ESC/POS code pages or bitmap rendering via Pillow (supports full Unicode and diacritics)
- QR codes — built-in ESC/POS QR generation
- PDF417 barcodes — pure-Python renderer, no native deps
- Image printing — any PIL image, with optional Floyd–Steinberg dithering
- TOML templates — declarative print layouts for receipts, labels, and tickets
- Code-page probe — built-in tool to test which firmware code pages actually work
Installation
There are two variants of the package:
| Variant | What you get | Install extra |
|---|---|---|
| SDK only (default) | goojprt Python package + goojprt CLI |
(none) |
| SDK + Server | everything above + goojprt-server — a FastAPI HTTP print server with live dashboard and REST API |
[server] |
pip
# SDK only
pip install goojprt-pt210-sdk
# SDK + HTTP print server
pip install "goojprt-pt210-sdk[server]"
uv
# SDK only
uv add goojprt-pt210-sdk
# SDK + HTTP print server
uv add "goojprt-pt210-sdk[server]"
Latest from GitHub (development)
# SDK only
pip install git+https://github.com/filipseedy/goojprt-pt210-sdk.git
# SDK + HTTP print server
pip install "git+https://github.com/filipseedy/goojprt-pt210-sdk.git#egg=goojprt-pt210-sdk[server]"
Editable install for local development
git clone https://github.com/filipseedy/goojprt-pt210-sdk.git
cd goojprt-pt210-sdk
# SDK only
pip install -e .
# SDK + HTTP print server
pip install -e ".[server]"
Requirements: Python 3.14+. Core dependencies (bleak, Pillow, pdf417) are installed automatically. The [server] extra adds FastAPI, Uvicorn, Jinja2, Rich, and Pydantic.
Quick start
import asyncio
from goojprt import GoojPrtPT210
async def main() -> None:
printer = GoojPrtPT210()
await printer.connect_ble("XX:XX:XX:XX:XX:XX")
await printer.initialize()
await printer.print_text("Hello, world!")
await printer.feed(3)
await printer.disconnect()
asyncio.run(main())
The session helper connects, initialises and always disconnects, also when printing fails:
async with GoojPrtPT210.ble("XX:XX:XX:XX:XX:XX") as printer:
await printer.print_text("Hello, world!")
await printer.feed(3)
(GoojPrtPT210.spp(...) does the same for classic Bluetooth with a plain with.)
Print bitmap text (full Unicode / diacritics)
await printer.print_text_image(
"Příliš žluťoučký kůň\núpěl ďábelské ódy",
font_size=28,
)
Lines wider than the paper are word-wrapped (wrap=False to turn that off).
Print an image
from PIL import Image
from goojprt.rendering.image_print import prepare_image
await printer.print_image(prepare_image(Image.open("photo.jpg"))) # scaled down to the paper
await printer.print_image(prepare_image(Image.open("logo.png"), fit="width", dither=False))
fit="shrink" (the default) never makes the picture wider than the paper, "width" fills the paper, "none" keeps the source size and cuts off whatever is wider.
Print darker or lighter
await printer.initialize()
await printer.set_density("dark") # or "light", "normal", or a heating time 0-255
The presets are uncalibrated starting points, and whether a given unit honours ESC 7 has not been verified.
Print a QR code
await printer.print_qr("https://example.com", size=5)
Print a PDF417 barcode
await printer.print_pdf417("1234567890ABCDEF", columns=5, scale=2)
CLI
# Find the printer (on macOS the "address" is a UUID), then keep it in the environment
goojprt --scan
export GOOJPRT_ADDRESS=XX:XX:XX:XX:XX:XX # optional: the address argument can then be left out
# BLE demo print
goojprt XX:XX:XX:XX:XX:XX
# Native text with Czech diacritics: calibrate once, then print (see "Native Czech" below)
goojprt XX:XX:XX:XX:XX:XX --calibrate
goojprt XX:XX:XX:XX:XX:XX --print-text "Příliš žluťoučký kůň"
# Bitmap text with antialiasing
goojprt XX:XX:XX:XX:XX:XX --print-image "Příliš žluťoučký kůň"
# An image file, scaled down to the paper, printed darker
goojprt XX:XX:XX:XX:XX:XX --print-file photo.jpg --density dark
# PDF417 barcode
goojprt XX:XX:XX:XX:XX:XX --pdf417 "data"
# Print from a TOML template
goojprt XX:XX:XX:XX:XX:XX --template receipt.toml --var name=John
# Probe which code pages actually work on your unit
goojprt XX:XX:XX:XX:XX:XX --test
Run goojprt --help for all options.
Preview without a printer
--preview OUT.png renders --template, --print-image, --print-file and --pdf417 into a PNG instead of printing, so layouts can be built without wasting paper (and without an address):
goojprt --template examples/receipt.toml --var shop="Corner Shop" --var total=12.50 --preview receipt.png
Everything drawn as a bitmap appears exactly as it would print — the preview is checked pixel for pixel against the real raster stream. Native ESC/POS text (text items, print_text), separator lines and QR codes are produced by the printer firmware and cannot be rendered; they show up as dashed notes with their content, and the command reports how many there were.
In Python, printer.connect_preview() attaches the same recorder to any facade, and the server offers POST /api/preview/{text,pdf417,ekg,grid,image} which return the PNG (header X-Preview-Native-Commands counts the unrenderable parts). Previews never touch the print queue or the printer.
printer = GoojPrtPT210()
preview = printer.connect_preview()
await printer.print_text_image("Příliš žluťoučký kůň")
preview.save("preview.png")
Two text paths
| Path | Method | Diacritics | Speed |
|---|---|---|---|
| Native ESC/POS | print_text |
Depends on firmware | Fast |
| Bitmap (Pillow) | print_text_image |
Always correct | Slower |
If diacritics appear as garbage, switch to print_text_image. Use --test (or probe_charsets()) to test your specific unit.
Characters that the chosen encoding cannot represent are printed as ? (and a warning is logged) rather than being sent as UTF-8, which the printer would render as garbage.
Native Czech (or any language) without bitmaps
Bitmap text always works, but native text is faster and much smaller on the wire. Which ESC t table prints your language correctly differs from unit to unit, and many cheap printers boot in a double-byte (Chinese) mode in which bytes ≥ 0x80 are half of a character, so a table can look wrong even after ESC t. Find the right combination once:
goojprt XX:XX:XX:XX:XX:XX --calibrate
It prints the Czech test sentence once per candidate — tables 18 (cp852), 45 (cp1250), 39 (iso8859-2) and 16, each with and without FS . (cancel Chinese mode) — labelled A–H, asks which line shows the sentence exactly and saves the answer (--calibrate-pick LETTER saves without printing, --calibrate-text uses your own sentence). After that:
goojprt XX:XX:XX:XX:XX:XX --print-text "Příliš žluťoučký kůň úpěl ďábelské ódy"
goojprt XX:XX:XX:XX:XX:XX --template examples/native-text-czech.toml
Both use the saved profile on their own (--profile FILE / --no-profile override it; the file lives in $GOOJPRT_PROFILE or ~/.config/goojprt/profile.toml). Each line is printed natively when the table can show it and rendered as a bitmap only when it cannot (a euro sign in cp852), so nothing ever comes out as garbage.
In Python the same is three lines, and print_text then needs no encoding=:
await printer.use_codepage(CodePage.PC852) # FS . + ESC t 18, remembers the codec
await printer.print_text("Příliš žluťoučký kůň") # native, cp852
await printer.print_text_auto("Cena 5 € za kus") # native where possible, bitmap for the euro line
The profile is sent again with every initialize() and after reconnects. Templates have a codepage item for the same thing, text items take auto = true, the server's text jobs take "auto": true and use a profile given with --profile / GOOJPRT_PROFILE. If nothing looks right, print_text_image always works.
TOML templates
Define a print layout in a .toml file:
[[items]]
type = "text"
text = "Receipt — {{date}}"
bold = true
align = "center"
[[items]]
type = "qr"
data = "https://example.com/{{order_id}}"
[[items]]
type = "feed"
lines = 4
Variables like {{date}}, {{time}}, {{expire_24h}}, {{password_12}} are built-in. Pass custom variables with --var KEY=VALUE.
Item types: text, text_image, image, qr, pdf417, grid, ekg, line, feed, cut, charset, chinese_mode, codepage, density. A codepage item (code_page = "PC852") switches to a native code page and makes text items encode for it. An image item (path is relative to the template file, plus fit, scale, align, dither, …) prints a logo; it is opened before the printer is touched, so a missing file fails before any paper is used. Ready-to-run samples are in examples/: a receipt with a logo, a guest Wi-Fi voucher with a QR code, and a native-text experiment.
How the printer talks
- BLE: the primary UUIDs (
49535343-…) are Microchip's Transparent UART service (BM70/RN4870 modules): GATT writes go to the module, which forwards them over a UART to the printer MCU. There is no flow control, so the SDK writes in small chunks with a pause in between and waits after every raster strip. Some firmware uses the0000ff00service family instead; both are tried. - Protocol: plain ESC/POS —
ESC @,GS ! n,GS ( k(QR),GS v 0(raster, sent in 24-row strips),DLE EOT n/GS I nfor status and identification (answers arrive on the notify characteristic, if the unit has one). Seegoojprt.statusfor decoding the status bytes. - Concurrency: writes are serialised, so a status query from another task can never land in the middle of a print job.
Observed on one unit (PT-210_DF5B: manufacturer GEZHI, model PT2D-V1.0, firmware PT-210-8008) — other units or firmware may differ:
- It lists five services, among them both UUID families (
49535343-fe7d-…and0000ff00-…). Write to49535343-8841-…; the answers to status and identification queries come back on49535343-1e4d-…, the notify characteristic of the same service, within 25–45 ms. The0000ff01notify characteristic of the other family stays silent, which is why the SDK pairs the notify characteristic with the write characteristic's service. DLE EOT 1–4answer one byte each (0x16online,0x12for "no cover / paper / error");GS r 1andESC vanswer too.GS I 1–3return single ID bytes (0x60,0x03,0x08),GS I 65–68return text (firmware version, manufacturer, model, serial number),GS I 97returns14 00 00 0f. Nothing else inGS I 0–127answers.- The negotiated write-without-response payload is 237 bytes, so the 182/192-byte chunks fit. On subscribing,
0000ff03announces01 04and02 b6 00(0xB6 = 182) and is silent while printing, so it is not a flow-control channel; pacing stays open-loop. There is no Battery service.
The pacing is conservative. If your unit keeps up, print faster by lowering the pause (and raise it again if you see missing lines):
await printer.connect_ble("XX:XX:XX:XX:XX:XX", chunk_delay=0.02)
Upgrading
TextSize.DOUBLE_HEIGHT,DOUBLE_WIDTHandDOUBLE_BOTHnow produce 1×2, 2×1 and 2×2 characters as their names say. They used to send0x11,0x20and0x31(2×2, 3×1, 4×2), so existing output withsize=will look different.print_text/text_to_bytesreplace unencodable characters with?instead of switching the whole string to UTF-8.- Images wider than the paper are now scaled down (
fit="shrink") instead of having their right part cut off when printed. Anything that already fitted — including callers that compensate withscale≈ 384 / width — prints exactly as before;fit="none"restores the old behaviour for wide images. - Bitmap text (
print_text_image,text_imageitems,render_text_image) word-wraps lines wider than the paper instead of running them off the edge. Lines that fit are unchanged; passwrap=Falsefor the old behaviour. print_text()encodes with the codec of the active code page (afterset_charset,apply_profileoruse_codepage) when noencoding=is given; without one it is GB2312 as before.texttemplate items and the server's text jobs follow the same rule, andinitialize()re-sends an applied profile.- The BLE transport subscribes to the notify characteristic of the write characteristic's service. Units that expose both UUID families used to be subscribed to a characteristic that never answers, so status, battery and identification queries returned nothing.
commands.energy()raisesValueErroroutside 0–255 instead of wrapping the value around.numpyis no longer needed: bitmap printing used to fail withModuleNotFoundErroron a plainpip install.
Documentation
Full API reference, architecture notes, and examples are at:
goojprt-pt210-sdk.readthedocs.io
License
MIT. See LICENSE for details.
Metadata
Release files for goojprt-pt210-sdk 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| goojprt_pt210_sdk-0.1.3.tar.gz | 223.2 kB | With provenance | Details for goojprt_pt210_sdk-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| goojprt_pt210_sdk-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for goojprt_pt210_sdk-0.1.3-py3-none-any.whl |
Total release size: 332.1 kB
Release files / goojprt_pt210_sdk-0.1.3.tar.gz
| Download URL | goojprt_pt210_sdk-0.1.3.tar.gz |
|---|---|
| Size | 223.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
93af43271d33de42ac6d1c9a172c32233f35f23797d125e49ec7af983b75ea81
|
|
BLAKE2b-256 checksum How to use checksums |
db07e5641c6fab718ee50e59cca9d10c5f6a896a21b1f734a9122861e9925cf3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logRelease files / goojprt_pt210_sdk-0.1.3-py3-none-any.whl
| Download URL | goojprt_pt210_sdk-0.1.3-py3-none-any.whl |
|---|---|
| Size | 108.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
416ef55331376fb5ba16724e3810211b7b4986205730f84c0fc0e7043203e0d6
|
|
BLAKE2b-256 checksum How to use checksums |
989d58e526a5f332d53f5aea775bfd12ad331255a71677406929b677e47e16bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logSecurity for goojprt-pt210-sdk 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for goojprt_pt210_sdk-0.1.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.