Generate E-waybill API integration

Tushar Kale TK
3 min readApr 2, 2021

--

Step by step process to generate e-waybill in NodeJS application.

Hello, I recently implemented an e-waybill API in my web application. Here I am sharing the process involved in integration.

  1. Register for e-waybill API service on governments e-waybill portal https://ewaybill.nic.in/ while registration of API you have to choose one provider from the list.
  2. After registration of API service, the service provider will share some credentials for accessing API including API_URL, Public Key(.pem file), Subscription Key(string), Authentication URL, Username, and Password.
  3. By using the above credentials you need to hit two API using post methods. One for authentication and the second for generation of e-waybill.
  4. For authentication API requests you need to add the GSTIN and Subscription key in the header.
  5. Inside the authentication API body, you need to send JSON object including the following keys action, username, encrypted password and encrypted APP_KEY (Random 32 character string) also store nonencrypted APP_KEY for decryption of SEK.
  6. For the encryption of password and APP_KEY sample, Java and .net code is provided in the documentation. I am sharing the encryption function in NodeJs.

7. After calling Authentication API successfully you will receive two strings Authtoken and encoded SEK in response. You need to decrypt SEK using nonencrypted APP_KEY. These keys are valid for 6 hours but better to generate a new Authtoken and SEK for each e-waybill generation.

8. Create an e-waybill JSON object by using the rules provided in the documentation. Encrypt that JSON object by decrypted SEK by using the following encryption technique.

9. After encrypting the object you are ready to call the API for an e-waybill generation. Add GSTIN, Authtoken, and Subscription Key in the header. In the body, you need to add a JSON object including keys like action and data. Data will contain the encrypted e-waybill object.

10. Hit API with POST method. If this API call is successful then it will return encrypted e-waybill data in response.

11. You need to decrypt received data by the above decryption function using decrypted SEK. After decryption you need to convert that data from base64 to string further that string will be converted into a JSON object. You will get a clear understanding by checking the code statement mentioned below.

12. Lastly after successful decryption of data you will get an e-waybill number, e-waybill date, validity date.

Finally, Generate a PDF of the e-waybill by using the above details including QR code. QR code must contain a string including E-waybill number, our GSTN, date, and time created in the following format NO/GSTIN/DD/MM/YYYY HH:MM:SS AM.

Spread this post if you find the above information useful.

Thanks !!

> Tushar Kale

--

--

Tushar Kale TK
Tushar Kale TK

Written by Tushar Kale TK

Enthusiastic Software Developer. Specialised in both frontend and backend. Ready to help people to solve their problems in all aspects of web development.

Responses (3)