SDK e CLI
SDK e CLI Printags per l'API
Chiamate l'API Printags da Node.js, Python o dalla riga di comando. Un pacchetto printags su npm, un altro su PyPI.
Installazione
Node.js 18 o superiore. Il pacchetto contiene l'SDK e il comando printags.
npm install printags
SDK per Node.js
Ogni metodo corrisponde a un'operazione del documento OpenAPI, con il nome stesso dell'operazione. Gli errori sono oggetti PrintagsError con lo stato HTTP e il codice di errore dell'API.
import { Printags } from "printags";
const printags = new Printags({ apiKey: process.env.PRINTAGS_API_KEY });
const { orders } = await printags.listOrders("@me", { perPage: 10 });
// A draft prints and charges nothing until it is validated.
// The idempotency key makes a retry safe: the same key returns the order already created.
const { orderId } = await printags.createOrder("@me", {
isDraft: true,
reference: "Order-2026-001",
shipTo: { name: "Jean Dupont", phone: "+33612345678", email: "[email protected]",
address: { addressLine1: "12 rue de la Paix", city: "Paris", postcode: "75002", countryCode: "FR" } },
items: [{ productId: "ntag213_pvccard_white", quantity: 10, printingVisuals: [fileId],
nfc: { type: "uri", content: "https://example.com/jean" } }]
}, { idempotencyKey: "order-2026-001" });SDK per Python
Python 3.9 o superiore, una sola dipendenza (httpx). Le stesse operazioni, in snake_case (list_orders, create_order). Gli errori sono PrintagsError, con una sottoclasse per stato (NotFoundError, RateLimitError…).
# pip install printags
import os, uuid
from printags import Printags
printags = Printags(api_key=os.environ["PRINTAGS_API_KEY"])
page = printags.list_orders("@me", per_page=10)
# A draft prints and charges nothing until it is validated.
# The idempotency key makes a retry safe: the same key returns the order already created.
order = printags.create_order("@me", {
"isDraft": True,
"reference": "Order-2026-001",
"shipTo": {"name": "Jean Dupont", "phone": "+33612345678", "email": "[email protected]",
"address": {"addressLine1": "12 rue de la Paix", "city": "Paris", "postcode": "75002", "countryCode": "FR"}},
"items": [{"productId": "ntag213_pvccard_white", "quantity": 10, "printingVisuals": [file_id],
"nfc": {"type": "uri", "content": "https://example.com/jean"}}],
}, idempotency_key=str(uuid.uuid4()))Riga di comando
Le stesse operazioni da un terminale o da uno script. L'output è JSON.
export PRINTAGS_API_KEY=sk_test_... export PRINTAGS_SANDBOX=1 npx printags statuses npx printags carriers --to-country FR npx printags orders list --per-page 5 npx printags orders create --file order.json --idempotency-key order-2026-001
Sandbox
Una chiave di test (sk_test_...) crea ordini di prova che non vengono addebitati né fabbricati. Con l'opzione sandbox, l'SDK e la CLI usano sandbox-api.printags.com, che accetta solo chiavi di test: una chiave reale viene rifiutata prima che qualsiasi richiesta lasci la vostra macchina.
Risorse
- Documentazione dell'API (docs.printags.com)
- Documento OpenAPI (JSON)
- Codice sorgente su GitHub (printags/printags-js)
- Pacchetto Python su PyPI (printags)
- Codice sorgente dell'SDK Python su GitHub (printags/printags-python)
- Integrazione dell'API REST
- Server MCP di Printags
- Skill per agenti su GitHub (printags/agent-skills)
Domande
SDK e CLI: le vostre domande
Esiste un SDK ufficiale di Printags?
Sì, due: il pacchetto npm printags per Node.js 18 o superiore (SDK e riga di comando, senza dipendenze) e il pacchetto PyPI printags per Python 3.9 o superiore. L'API è una normale API REST descritta da un documento OpenAPI, quindi qualsiasi linguaggio può chiamarla.
Posso provare l'SDK senza ordinare carte vere?
Sì. Usate una chiave di test (sk_test_...) con l'opzione sandbox: gli ordini creati sono ordini di prova, non addebitati né fabbricati.
Con quale licenza è pubblicato il pacchetto?
MIT. Il codice sorgente è su GitHub: printags/printags-js e printags/printags-python.