OOZOU
與我們聯繫
Back to TIL
shell

Check for IKEA item availability

October 13, 2020

If you're waiting for an IKEA item to restock, here's a practical solution to stay updated automatically. This guide explains how to use a shell script to check IKEA's stock availability and get notified when your desired item is back in stock.

IKEA's inventory updates frequently, and certain popular items can sell out quickly. This script eliminates the hassle of manually checking the stock repeatedly. By automating the process, you can focus on other tasks and still be among the first to know when the item is available.

Overview

This shell script works on any *NIX-based system with curl installed. It uses IKEA's API to check item availability and notifies you via Slack when the item is available. The flexibility of this script makes it a perfect tool for shoppers who want to secure in-demand products without constant manual effort.

IKEA API Response

To check an item's availability, use the following API endpoint, replacing th with your country code:

<https://www.ikea.com/th/en/iows/catalog/availability/S99067497>

For example, in Thailand, IKEA has two stores near OOZOU's office. This script is configured to check availability at either of these stores.

The response from the API includes details about the stock status in specific stores. By parsing this response, the script identifies whether the item is available, making it a highly efficient solution.

The Script

#!/usr/bin/env bash

url="https://www.ikea.com/th/en/iows/catalog/availability/$1"

# This is the string that we want to see changed
string="0"

while true; do
  # Get the API response and return as string
  text=$(curl -s "$url")

  # Get a count of how many times the substring matches
  count=`grep -o "$string" <<< "$text" | wc -l`

  # If less than 2, then it's available!
  if (( $count < 2 )); then
    echo "AVAILABLE, yay.";
    # Notify us via Slack
    curl -X POST --data-urlencode "payload={\"channel\": \"…\", \"username\": \"ikea\", \"text\": \"Item $1 is now available at IKEA.\", \"icon_emoji\": \":shooping_bags:\"}" https://hooks.slack.com/services/…
    break
  else
    # If not available, sleep for 30s
    echo "$1 not in stock"
    sleep 30
  fi
done

How to Use

  1. Save the script as check.sh and make it executable:
chmod +x check.sh<br>
  1. Run the script by passing the IKEA item ID as an argument:
./check.sh S99067497
  1. Replace the Slack webhook URL and channel details with your own.

This straightforward process ensures you can monitor item availability with minimal effort. It's particularly useful if you frequently shop at IKEA and want to avoid missing out on high-demand products.

Key Features

  • API Integration: Uses IKEA's API to fetch real-time stock data.
  • Slack Notifications: Sends instant alerts to your chosen Slack channel.
  • Customisable: Adjust the script for different country codes, item IDs, or notification methods.
  • Time-Saving: Automates stock monitoring, freeing you from repetitive checks.
  • User-Friendly: The script is simple to configure and run, even for beginners.

Tips

  • Ensure you have curl installed on your system.
  • Modify the sleep interval (default: 30 seconds) based on your preference.
  • For Slack notifications, create and use your own Slack webhook URL.
  • Test the script with a sample item ID to ensure it's working correctly before relying on it for high-priority items.

Monitoring IKEA stock manually can be time-consuming and tedious. With this script, you can stay informed without constant effort, ensuring you don't miss out on the items you need. Whether it's furniture, home accessories, or any other IKEA product, this tool is a must-have for savvy shoppers. Happy shopping!

More on shell

shellDecember 8, 2020

Run incognito/private commands for Bash and Zsh

Simply put a space before the command and it won't be saved to ~/.bash\_history. E.g. qrencode -o out.png "Some secret text"

shellOctober 22, 2020

Upgrade postgres database with homebrew

To upgrade postgres you can run

shellOctober 13, 2020

Amazon AWS S3 CLI copy with set perms

Open term (or equivalent) and paste the following:

有專案構想嗎?

我們很樂意聆聽您正在打造的產品。

開始對話hello@oozou.com
OOZOU Logo

曼谷 · 新加坡 · 香港

X
Facebook
Instagram
LinkedIn

服務

  • Web 開發
  • AI 與生成式 AI 解決方案
  • 行動應用程式開發
  • 資料分析與工程
  • UI/UX 設計與產品設計
  • 數位轉型

公司

  • 關於我們
  • 職涯
  • 部落格
  • 白皮書
  • 案例研究
  • Today I Learned
  • 聯繫我們

更多

  • 產業
  • 索取報價
  • 合作夥伴網絡
© 2026 OOZOU. 版權所有。
隱私政策行為準則反賄賂反貪腐政策