Powershell Script - Officeworks Stock Level API Query

Hi guys, this is a small Powershell script I wrote that will check stock levels of an item across Officeworks stores within a state. Using info originally provided by thydzik.

Nothing fancy, (just a bit of mental exercise), it cycles through the Officeworks store query API grabbing stock levels and then displays them along with the store phone number.
Script is pretty self-explanatory, you can add more stores to the state arrays if/when they're available (not necessary any more - Thanks Pippyyy).

Here's a screenshot: https://files.ozbargain.com.au/upload/8952/61218/2018-08-13_...

Added GUI, fetches store list from OW: CheckOW-GUI.zip @ Box

Contains the script and a shortcut to run it, you can run it from a Powershell window if you want but you'll probably need to run it with -noprofile -executionpolicy bypass (due to being marked internet zone in the ADS).

Nothing is written to the system, it grabs URLs and outputs to the console, someone can probably fancy it up a bit with a GUI or various output formats.

You can also run it from Linux or Mac if you install Powershell, there shouldn't be anything Windows specific.

Enjoy … or not.

Related Stores

Officeworks
Officeworks

Comments

  •  

    Nice work!

  • +3 votes

    Nice!
    I had no idea they had a public API.

    If I have time after next week, might smash together a web page for this and run it in an Azure Function.

  •  

    Good job on the script. I was always too lazy to write my own script for it. Interesting to see how many of the expensive phones each store stocks. Seems to be a trend where the bogan suburbs have bugger all and the cashed up suburbs have more.

  • +1 vote

    Thanks guys, I was also thinking of having it load the Officeworks Store List and parse the source to keep the arrays updated, save manually editing it.

    Be interesting to find other stores have a similar API we can get access to.

  •  

    yay i feel like i work at officeworks

    •  

      Now to pull their buy price >:D

      •  

        once you know the product ID you pass it to this:

        https://www.officeworks.com.au/webapp/wcs/stores/servlet/OWG...

        •  

          I keep getting told the system is unavailable no matter what product ID I use.

        •  

          @4wd: Hmmm. Are you using the product ID, not the Product Code?

          I'm trying to find a way to get the Product ID from the Product Code

          I.e One product is "JBCNCPA4CT" which when searched for looks for a value "189107"

          https://www.officeworks.com.au/webapp/wcs/stores/servlet/OWG...

        •  

          A bit more snooping around and a few assumptions being made, you can get the price using

          https://www.officeworks.com.au/webapp/wcs/stores/servlet/OWG...

          https://www.officeworks.com.au/webapp/wcs/stores/servlet/OWG...

        •  

          With even more snooping around. To search for a product by Keywords use

          <OfficeworksUrl>/shop/AjaxCategoryNavigationResultsBusinessView?searchTerm=<SEARCHTERM>&pageSize=99999

          Then search in the products array for all items.
          This will give you the Name, and the product number amongst all other kinds of things.

          <OfficeWorksUrl>/shop/AutoSuggestView?catalogId=10551&langId=-1&showHeader=false&coreName=MC_10001_CatalogEntry_en_US&serverURL=http://owprodsolrw.officeworks.internal:3737/solr/MC_10001_CatalogEntry_en_US&storeId=10151&format=json&term=<SEARCHTERM>"

          And, my friend, you can have a "Did you mean: " searchbox!

          drops mic

          EDIT:
          picks up mic
          Added pageSize to topmost query to remove pagination :P
          carefully places mic back down

        •  

          Gahhh, testing in browser kinda screws up results due to sessions I think. For the previous post, the AjaxCategory….pageSize=99999 requires a "&storeId=10151" on the end to work in powershell.

          <OfficeworksUrl>/shop/AjaxCategoryNavigationResultsBusinessView?searchTerm=<SEARCHTERM>&pageSize=99999&storeId=10151

        •  

          @Pippyyy:

          DUH! Yes, I was using the Product Code :/

          Just having a play around to add the price to the output.

        •  

          If you want to know anything about any kind of related product:

          https://www.officeworks.com.au/shop/ProductSearchView?catalo...

          Took me a while to dig this. Should be enough to make any kind of querying tool for you to expand upon. In the mean time, I'm hitting JB, Target, BigW and other electronic stores to see what they can do :p

  •  

    Updated original post, added v2 which grabs the stores from the link Pippyyy provided - you got the option of stock levels in all stores now.

    If you do all stores they're all mixed together, just the way it comes from OW, I'll look at sorting it later.

  • +2 votes

    Awesome stuff. I wouldn't take this as a certainty that there's stock actually available. Faulty's count, unsent but written on stock, etc. I'd still call in advance if it was something like 1.

  • +1 vote

    Updated the OP, now has a simple GUI.

  •  

    This is great. I reckon a phone app would be cool. Like for when you're in-store you'd literally be able to see the numbers as a customer rather than asking a Team Member initially.

  • +2 votes

    Can't edit the original post so here's the newer version.

    Changes:
    Grabs the price, description, and whether it's In-Store-Only, displaying it in the GUI. (Thanks Pippyyy)

    Screenshot: https://files.ozbargain.com.au/upload/8952/61686/ow_stock_ch...

    CheckOW-GUI.zip @ Box

    •  

      Hahaha!!! Wow! Nice work! I'm glad I can help. It's looking so nice!

      • +1 vote

        Haven't got a round tuit but I was going to change the TextBox's to RichTextBox's so I could use Bold, colours, etc.

        •  

          I've never really messed around with RichTextBoxes before. For GUI with powershell backends I use WPF but I barely use powershell anymore as I have moved to C#/ASP.NET for all my GUI programming haha.
          I find simple designs are the best.

  • +2 votes

    Small update to the script, noticed that it gave unreasonably high stock levels for items, (ie. 704 of the Seagate 4TB external when their website showed nil), so I've made an arbitrary limit of 300, anything above that is listed as N/A.

    Get it here: CheckOW-GUI @ Box.com

    Screenshot: https://files.ozbargain.com.au/upload/8952/61686/ow_stock_ch...

    Previous links are unlikely to work.

    • +2 votes

      This is very cool! Thanks for making it.

      I noticed the same issue with high stock numbers on items they don't seem to have and by looking at the json it returns I think I've found the issue.

      For example: BRMFCL2713 comes up on your powershell script with 17 in a bunch of stores that claim they don't have any.

      When looking at the JSON itself is shows clickAndCollectQuantity: 17 which is where that number is coming from.

      For stores that actually have stock there is an additional property, inStoreQuantity, which shows the real number.

      Compare the following:
      https://www.officeworks.com.au/catalogue-app/api/availabilit... (has 4 in stock as at time of writing)
      https://www.officeworks.com.au/catalogue-app/api/availabilit... (has non in stock)

      •  

        Hi, sorry, completely missed your post - I'll have a look at updating it a bit.
        Probably rename the Stock column to CnC and create another column for InStore stock.

        Edit: Actually, the API link I'm using is different to yours, eg.

        The API link I use:
        https://api.officeworks.com.au/v2/availability/store/W306/?p...

        [
          {
            "partNumber": "COCM01WH",
            "options": [
              {
                "type": "inStore",
                "qty": 35,
                "site": "W319",
                "availableDate": "2020-08-25"
              },
              {
                "type": "clickAndCollect",
                "qty": 35,
                "site": "W319",
                "availableDate": "2020-08-27",
                "isQuickCollectAvailable": false
              }
            ]
          }
        ]
        

        Compared to the one you used:
        https://www.officeworks.com.au/catalogue-app/api/availabilit...

        [
          {
            "sku": "COCM01WH",
            "thirtyDayAccountEnabled": false,
            "deliveryType": "standard",
            "deliveryQuantity": 214,
            "deliveryEstimation": "Estimated on Monday, August 31, 2020",
            "shipFromStore": false,
            "isQuickCollectAvailable": false,
            "clickAndCollectQuantity": 35,
            "collectEstimation": "Estimated collection on Thursday, August 27, 2020",
            "inStoreQuantity": 35,
            "fulfilledBySupplier": false,
            "rangedRetail": true,
            "rangedOnline": true,
            "storeLocation": "377 Glen Huntly Road, Elsternwick",
            "storeName": "Elsternwick Officeworks",
            "storeContactNumber": "(03) 9519 7600"
          }
        ]
        

        The InStore/InStoreQuantity JSON value is completely dropped in either output if there is no stock in store.

        This worked fine as long as there was stock in store as I just referenced options.qty[0] because it's value was always first, (CnC would be options.qty[1]). However, when they drop that object the CnC value then becomes options.qty[0] … a trifle annoying but easily fixed by checking for options.type[0] = 'inStore'.

  •  

    thanks for sharing!

    •  

      (ignore me)

  • +3 votes

    Updated the PowerShell to cater for nil stock in store and added a column for CnC - almost all the time they will be the same number unless the store is out of stock, (as in the screenshot for Cairns and Capalaba).

    Screenshot

    CheckOW-GUI.zip

    Previous versions have been removed from Box.com

  •  

    thanks @4wd - great script