Can we print tickets with an API?

Hello, I’m trying to print payment tickets from my website. I have a front-end in Nuxt.js and a back-end in Express.js.

I was thinking of getting the IP of the printer and ordering it to print the ticket, but I don’t see how I can do that at all.

I looked into it and didn’t find much. Do you have any ideas on how I can print payment tickets from a website?

If you mean locally, to your printer, you need the computer running the server to be local, as in on the same local network as the printer.

I don’t know how to do it on Windows, but on Linux:

  • if there’s one printer, and it’s the default printer, can just use lp to order it to print a file.
  • if you need to see what printers are on the network (so that you can pick the one you need) before running that, you can use lpstat

In Node, can just spawn a command to run that.


However, that requires your server be running from your location on a static IP address. If it’s deployed somewhere remote, then you’d still need a server running at your location on a static IP address, but it could just expose an HTTP endpoint that, when you posted something to it from your application, would run the above and print out the ticket.

Some printers can kinda expose a remote endpoint anyway, so that they can allow you (for example) to use an app on your phone to print from anywhere. There may be some way to make use of that API if it exists, but it’s entirely dependent on the manufacturer (and the specific printer they manufactured). eg I had one where you could email things to that printer’s specific address and it would print them. So given a situation like yours, I could trigger an email send in the Express app