ONDC Search Trends Analysis with Node Js & Beckn Protocol Server

Utkarsh Mehta
2 min readJun 26, 2022

To demonstrate the ondc-node package & build a small POC I choose search trends analysis.

So to run this demo, you will need the protocol-server.

Clone the repo
> git clone https://github.com/beckn/protocol-server
> npm i

Generate Public/Private key pairs by running the following command in the root directory,

> npm run generate-keys

The keys will be printed on the console, we will need these in the next step.

Go to the config folder and default.yaml file with the following content.

Now in the default.yaml file, add a valid MongoDB connection URL, Public key & Private key.

Now the protocol server is ready to start the server by running the following,

> npm run start

The next step is to run ondc-node-demo.

Clone the repo
> git clone https://github.com/ukrocks007/ondc-node-demo
> npm iRun the service
>npm run start

This service acts as a Gateway by providing a /lookup API endpoint and It also implements buyer and seller side endpoints as well.

Basically, it implements the missing infrastructure to make sure that this demo works.

And now for the last step,

Clone demo repo
> git clone https://github.com/ukrocks007/ondc-search-analytics
> npm iStart the server
> npm run start

Now open http://localhost:4554/ in your browser.

So as there are no search requests the stats won’t show up.

Now we will call in the /init API of the ondc-node-demo service running at http://localhost:9988/.

You can use the curl command
> curl http://localhost:9988/init
Or use PostmanI personally used
> watch -n 1 curl http://localhost:9988/init
This commands keeps on sending /init get request every 1 second

Once the requests start coming in the stats will show up on the front-end.

Thank you, I hope this was helpful.

--

--