BlogRSS Feed

Jarrett Streebin

Buy Stamps from the Command Line!

by Jarrett Streebin

Did you know you can buy stamps from your command line? Just open your Terminal and paste the following (on Mac):

curl https://www.easypost.com/api/postage/buy \
  -u {YOUR API KEY}: \
  -d 'to[name]=Dr Steve Brule' \
  -d 'to[street1]=388 Townsend St' \
  -d 'to[street2]=Apt 20' \
  -d 'to[city]=San Francisco' \
  -d 'to[state]=CA' \
  -d 'to[zip]=94107' \
  -d 'from[name]=Jarrett Streebin' \
  -d 'from[phone]=3238550394' \
  -d 'from[street1]=310 Granelli Ave' \
  -d 'from[city]=Half Moon Bay' \
  -d 'from[state]=CA' \
  -d 'from[zip]=94019' \
  -d 'parcel[weight]=1.0' \
  -d 'parcel[predefined_package]=Letter' \
  -d 'carrier=USPS' \
  -d 'service=First'

Boom! There's your 46 cent stamp minus the trip to the post office. Just copy the URL in the response.

Now, try updating the addresses to real ones. Is that the postage you were looking for?

Want to try it for real now? Sign up for an account, load it with credit, then use your real API key.

Need to ship a box? Just remove -d 'parcel[predefined_package]=Letter' and add dimensions. It's always a good idea to do it with a Test API key first, to make sure you're getting the postage you want.

If you really want to get fancy, check out the awesome CLI one of our users wrote!

Let us know if you have any questions!