DEV Community

Cover image for Postman Collection: I Give You Best Price
Amruth Pillai
Amruth Pillai

Posted on

Postman Collection: I Give You Best Price

I Give You Best Price

Looking to buy something soon? Make sure you get the best price.

Disclaimer: I recently started working at Postman, and this post is in an attempt to explore what the app can do and it's abilities in terms of automation.

Introduction

This is a simple collection that you can run/monitor to search for a specific product on various e-commerce websites (made for Indian markets) and shows you a graph of all the prices, along with where you get the product the cheapest.

It also sends you a slack notification at the end with information about the daily deal.

Test Run

Try the collection right here by clicking on the button and running on Postman. Be sure to create an environment before you start :)

Run in Postman

Workflow

For example, I've been looking to buy a simple keyboard for my secondary PC that my dad works on. I've been looking at the Dell KB216 for some time now, but just looking for the best deal.

I've set up the collection as shown below to look for the Dell KB216 on various websites.

Amazon - Dell KB216

Each request has an associated Test Script along with it to be able to scrape the data off of the HTML body. Here's the test script for Amazon India.

const $ = cheerio.load(responseBody);
const firstProductElement = $('.s-result-item').first();
const priceElement = firstProductElement.find('.a-price-whole');
const price = parseFloat(priceElement.text());

pm.test("Amazon has returned a valid price", function () {
    pm.expect(price).to.be.a('number');
    pm.environment.set("amazon_price", price);
});
Enter fullscreen mode Exit fullscreen mode

Going through individual websites like Flipkart, Snapdeal, Shopclues and eBay, it collects the price information and stores it as environment variables in the workspace.

Finally, using Postman's Visualize Tab, I draw up a chart courtesy of Charts.js and pit against the prices from all the sites.

Price Graph

This eventually sends out a notification on a Slack Channel that I've made specifically for this purpose.

Slack Notification

As you can see here, over the course of waiting just a single day, I've saved ₹100. Do this over and over again, and you'll be a millionaire in no time! :)

That's my time, hope you found this useful!

Top comments (3)

Collapse
 
pujux profile image
Julian Pufler

Cool idea!

Collapse
 
amruthpillai profile image
Amruth Pillai

Thank you very much! :)

Collapse
 
geekbro profile image
Geek

It's a great idea to save some cost from online purchase. I tried running it. It didn't work as expected. Maybe it needs some revamping now?