Chase is only 20 months old, but he eats a lot… Well, he got a fat father, who can I blame… - -|||

Baby formula is always a hard thing to get in Australia as the producer is not able to supply enough to all Asian countries… (No blame here…)

Not many ways that we can get the formula:

So do it in golang with basic operations…

  1. Find API for checking the stock level
  2. Call API to get result
  3. Sort JSON data
  4. Operate with data

Find API

Web page:

By clicking the Check stock in our stores to find out if it’s purchasable.

With Chrome Dev Tool, the API url can be found out here:

Call API

Call API with golang by using http.Get:

package main

import (

func main() {
	// get stock status for item 7211 around Hornsby area from API call:
	// Latitude & Longitude = Hornsby
	// 7211 = Atapmil pro-futura Toddler Formula Stage 3 900g
	// Max = maximum number of stores information as return

	resp, err := http.Get("")
	if err != nil {

	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)



      "AddressLine1":"Westfield Shopping Centre, 236 Pacific Highway",
      "Phone":"(02) 9450 6712",
          "OpenHour":"6:00 AM - 10:00 PM",
          "TradingHourForDisplay":"Mon: 0600-2200"
          "OpenHour":"6:00 AM - 10:00 PM",
          "TradingHourForDisplay":"Tue: 0600-2200"
          "OpenHour":"6:00 AM - 10:00 PM",
          "TradingHourForDisplay":"Wed: 0600-2200"
          "OpenHour":"6:00 AM - 10:00 PM",
          "TradingHourForDisplay":"Thu: 0600-2200"
          "OpenHour":"6:00 AM - 10:00 PM",
          "TradingHourForDisplay":"Fri: 0600-2200"
          "OpenHour":"6:00 AM - 10:00 PM",
          "TradingHourForDisplay":"Sat: 0600-2200"
          "OpenHour":"6:00 AM - 10:00 PM",
          "TradingHourForDisplay":"Sun: 0600-2200"
          "OpenHour":"6:00 AM - 10:00 PM",
          "TradingHourForDisplay":"Mon: 0600-2200"
        "Coffee Shop",
        "Sushi Bar",
        "Pick up",
        "eBay Online Order Collection",
        "EziBuy Online Order Collection",
        "Click and Collect"

Analysis Data

To analysis JSON data, we need to declare the data structure based on JSON result first:

type product_store_level []struct {
	Store struct {
		Division     string      `json:"Division"`
		StoreNo      string      `json:"StoreNo"`
		Name         string      `json:"Name"`
		AddressLine1 string      `json:"AddressLine1"`
		AddressLine2 interface{} `json:"AddressLine2"`
		Suburb       string      `json:"Suburb"`
		State        string      `json:"State"`
		Postcode     string      `json:"Postcode"`
		Latitude     string      `json:"Latitude"`
		Longitude    string      `json:"Longitude"`
		GeoLevel     string      `json:"GeoLevel"`
		Distance     string      `json:"Distance"`
		Phone        string      `json:"Phone"`
		TradingHours []struct {
			Day                   string `json:"Day"`
			OpenHour              string `json:"OpenHour"`
			TradingHourForDisplay string `json:"TradingHourForDisplay"`
		} `json:"TradingHours"`
		Facilities []string `json:"Facilities"`
	} `json:"Store"`
	ListPrice            int     `json:"ListPrice"`
	InstoreListPrice     int     `json:"InstoreListPrice"`
	SalePrice            int     `json:"SalePrice"`
	InstoreSalePrice     int     `json:"InstoreSalePrice"`
	CUPListPrice         float64 `json:"CUPListPrice"`
	InstoreCUPListPrice  float64 `json:"InstoreCUPListPrice"`
	CUPSalePrice         float64 `json:"CUPSalePrice"`
	InstoreCUPSalePrice  float64 `json:"InstoreCUPSalePrice"`
	HideWasSavedPrice    bool    `json:"HideWasSavedPrice"`
	IsRanged             bool    `json:"IsRanged"`
	IsInStock            bool    `json:"IsInStock"`
	IsForCollection      bool    `json:"IsForCollection"`
	IsForDelivery        bool    `json:"IsForDelivery"`
	IsForExpress         bool    `json:"IsForExpress"`
	IsSpecial            bool    `json:"IsSpecial"`
	IsAvailable          bool    `json:"IsAvailable"`
	InstoreIsAvailable   bool    `json:"InstoreIsAvailable"`
	IsPurchasable        bool    `json:"IsPurchasable"`
	InstoreIsPurchasable bool    `json:"InstoreIsPurchasable"`
	IsOnSpecial          bool    `json:"IsOnSpecial"`
	InstoreIsOnSpecial   bool    `json:"InstoreIsOnSpecial"`
	IsNew                bool    `json:"IsNew"`

Then use json encoder to help analysis data:

var r product_store_level

err = json.Unmarshal(body, &r)
if err != nil {

for _, i := range r[0:] {
    if i.IsPurchasable {
        fmt.Println(i.Store.Suburb, "有货!")

Inside the if part, we can simply put more actions: like email, sms, etc… to notify users.

Anyway, by using AWS lambda + SNS service, we are able to get the notification easily…

It’s a good start with golang from useful project, family side… ~ at least Chase got formula…