Read a USB shipping scale over HTTP
A USB scale is plugged into a machine on a packing bench, and the thing that needs the weight is your server. The PrintSocket agent already reports that machine's hardware, so the weight is one authenticated GET away.
Read the weight
Scales are discovered and reported by the agent, exactly like printers. You never create one. List what a device can see, or read one directly:
curl "https://api.printsocket.com/v1/scales?device_id=dev_7hk2m" \
-H "Authorization: Bearer sk_test_..."
{
"id": "scl_9d3f2",
"object": "scale",
"device_id": "dev_7hk2m",
"system_name": "Mettler Toledo PS60",
"state": "online",
"reading": {
"weight_grams": 1234,
"stable": true,
"captured_at": "2026-07-29T14:02:08Z"
}
}
Calling it from JavaScript
From Node, or any server-side runtime, it is a fetch:
const res = await fetch(
"https://api.printsocket.com/v1/scales/scl_9d3f2",
{ headers: { Authorization: `Bearer ${process.env.PRINTSOCKET_KEY}` } },
);
const scale = await res.json();
const fresh = Date.now() - Date.parse(scale.reading.captured_at) < 5000;
if (scale.state === "online" && scale.reading.stable && fresh) {
buyPostage(scale.reading.weight_grams);
}
Not from the browser. That key authenticates your whole account, and anything in front-end JavaScript is readable by anyone who opens the network tab. If a page in the packing station's browser needs the weight, put an endpoint on your own server that reads the scale and returns just the number, and let the page call that.
Three fields decide whether a reading is usable
-
stateisonlineoroffline, and a scale is offline whenever its device is. An offline scale can still carry an old reading. -
stableis whether the scale had settled. A parcel still being set down readsfalse, and that number is not the one to buy postage against. -
captured_atis when the agent last saw a reading. A report without a fresh reading keeps the previous one, so this is the field that tells you a weight is five seconds old rather than five minutes.
Read the weight on demand, at the moment you need it, which is usually the moment before buying a label. Do not cache it against an order.
What this does not do
- Scales emit no webhook events. There is nothing to subscribe to and no push. Poll when you need a number, which is the access pattern a packing bench has anyway.
- It is read-only telemetry. There is no tare, no zero, no unit change, no calibration through the API. Those are buttons on the scale.
-
Scales carry no
metadata, so you cannot hang your own identifiers on one. Filter bydevice_idand identify the bench that way. - Weight is reported in grams. Converting to whatever your carrier wants is your side.
The rest of the packing bench
The same agent, on the same machine, is also how you print the label once you have the weight: see the ZPL label printing API. Enrollment covers both at once, because the agent reports every printer and scale the machine can see. The full resource reference is under devices, printers and scales.