REST API Tutorial

EasyPost : A Shipping API Using Nodejs

Summary of learning

This tutorial help to access EasyPost API using Nodejs Client Library.The EasyPost is simple shipping API.The provides you more flexibility and control over your parcel shipping and logistics processes.

This tutorial help to access EasyPost API using Nodejs Client Library.The EasyPost is simple shipping API.The provides you more flexibility and control over your parcel shipping and logistics processes.

I am using nodejs to access EasyPost shipping API.You can sign up for an account at https://easypost.com. The Authentication and identification of the EasyPost API is done by providing an API Key on every request as your Basic Auth username. API Keys give full read/write access to your account and can disable it on the dashboard’s API Keys Page.

The API is secured using TLS v1.2 for all communication with this API.The API request without API Key will be failed. EasyPost provides two types of API Key: Test and Production. You can test all the EasyPost functionality using your Test key, for free, immediately after signing up.

How To Install EasyPost

npm install --save @easypost/api

How To Create Client

const api = new Api("yourkey", {
timeout: 120000,
baseUrl: "https://api.easypost.com/v2/",
useProxy: false,
});
  • timeout : Time in MS that should fail requests.
  • baseUrl :Change the base URL that the API library uses. Useful if you proxy requests from a front-end through a server.
  • useProxy :Disable using the API key. Useful if you proxy requests from a front-end through a server.

You can also use middle-ware with client using superagentMiddleware and requestMiddleware with above client.

The full source Code –

//index.js
const Easypost = require('@easypost/api');
 const api = new Easypost("Your APi Key", {
   timeout: 120000,
   baseUrl: "https://api.easypost.com/v2/",
   useProxy: false,
 });
 const parcel = new api.Parcel({
   length: 9,
   width: 6,
   height: 2,
   weight: 10,
 });
parcel.save().then(console.log);

You can more information from official Docs.

If you have requirements that needs our attentioN

Please feel free to contact us

We would love to hear from you

Share with your network

Facebook
Twitter
LinkedIn
WhatsApp
Email

This tutorial is intended to cover all the essentials steps and insights to understand EasyPost : A Shipping API Using Nodejs

Genislab Technologies

Learn further