The EasyPost API provides an easy way to programatically create shipments and postage labels. This project demonstrates combining the EasyPost APIs with PrintNode to easily print out any labels generated with your EasyPost account.
The application provides a minimal web application that can be hosted on any computer, and will remotely send ZPL labels to any PrintNode enabled printer.
- A Windows or Mac computer running Ruby Bundler (it must be able to run the PrintNode client)
- Some type of printer that supports ZPL files (we used a Zebra ZP450)
- An EasyPost account
- A PrintNode account
PrintNode has clear documentation on getting your printer set up so if you encounter any issues, refer there for more details.
- Download and install the PrintNode client
- Plug in your printer
- On OSX we manually added our printer with the below steps:
- Open a terminal and run
lpinfo -v | grep usb
to find your plugged in printer. It should return a line that looks something like:direct usb://Zebra%20Technologies/ZTC%20ZP%20450-200dpi?serial=XXXXXXXXXXXX
- Run
lpadmin -p raw_zebra -E -v usb://Zebra%20Technologies/ZTC%20ZP%20450-200dpi?serial=XXXXXXXXXXXX
in your terminal to install the printer with the nameraw_zebra
. You will need to replace theusb://Zebra%20Technologies/ZTC%20ZP%20450-200dpi?serial=XXXXXXXXXXXX
with what the previous command returned for you. - Once this is all set, you should see a new entry on your PrintNode Printers list
- Open a terminal and run
- Check out this repo and
cd
into the project directory - Copy or rename the sample.env to .env, and fill in values for
- Run
bundle install
- Run
rackup
- The application should be up and running at http://localhost:9292/
Occasionally, our printer would be showing up on PrintNode, but would fail to print files. In these situations, a quick power cycle of the printer took care of any issue.
If you still run into problems, you can try removing your printer and re-adding
it. If you're on OSX and followed the instructions above, just run
lpadmin -x raw_zebra
to remove the printer.
If you aren't seeing any labels, make sure you have bought some postage on EasyPost! You can walk through the EasyPost Getting Started Guide using your test API Key and you won't be charged.