Decoding a Barcode to a Sale UUID
Decoding a Barcode to a Sale UUID
Lightspeed Retail (X-Series) receipts include a Code 128C barcode that encodes the sale's UUID. The barcode is represented as a 40-digit decimal string and can be decoded back to the original UUID.
How it works
The encoding is a base conversion:
- The sale's UUID hyphens are stripped → 32-character hex string
- Parsed as base-16 → big integer
- Converted to base-10 decimal → left-padded to 40 digits
Decoding simply reverses this process.
Example
| Value | |
|---|---|
| Barcode (40-digit) | 0245627979572117920329262531130524296091 |
| Sale UUID | b8ca3a65-0183-11e4-fbb5-39f7fce5e39b |
Input:
0245627979572117920329262531130524296091Output:b8ca3a65-0183-11e4-fbb5-39f7fce5e39b
Decoding with Python
As a one-liner:
python3 -c "b='0245627979572117920329262531130524296091'; h=format(int(b),'032x'); print(f'{h[0:8]}-{h[8:12]}-{h[12:16]}-{h[16:20]}-{h[20:32]}')"Decoding with Node.js
As a one-liner:
node -e "const h=BigInt('0245627979572117920329262531130524296091').toString(16).padStart(32,'0');console.log([h.slice(0,8),h.slice(8,12),h.slice(12,16),h.slice(16,20),h.slice(20,32)].join('-'))"Looking up the sale
Once you have the UUID, use it to retrieve the sale via the API:
GET /api/{version}/sales/{uuid}
curl -H "Authorization: Bearer {token}" \
https://{domain_prefix}.retail.lightspeed.app/api/{version}/sales/b8ca3a65-0183-11e4-fbb5-39f7fce5e39bSee Sales 101 for more details on the sale object.
Updated about 9 hours ago
