Steam Deck has been a game-changer for portable PC gaming enthusiasts. However, getting your hands on a refurbished model can be tricky due to limited availability. To solve this problem, I developed a Python-based Steam Deck Availability Checker designed to monitor the stock of refurbished Steam Decks on the European market.
This blog post explores the technical aspects of the project, provides useful code snippets, and invites fellow programmers to contribute.
Project Overview
The Steam Deck Availability Checker is a Python script that automates the monitoring of stock availability from Steam’s store. It uses the ntfy notification service to alert users in real-time when a unit becomes available.
This project is an excellent example of using simple built-in Python libraries and APIs to solve a real-world problem effectively.
How It Works
The script follows a straightforward workflow:
- It queries the Steam API periodically to check stock status.
- If stock is detected, it triggers a notification via ntfy.
- It repeats the process indefinitely when added to cron.
Here’s the main logic in a nutshell:
from urllib.request import urlopen
# Set this
ntfy_url = "ntfy.sh/YOUR_NTFY_URL"
# We need a timeout to prevent script from hanging
timeout = 8
def parse_availability(data: bytes) -> bool:
parsed = " ".join(f"{c:02X}" for c in data)
not_available = "08 00 10 00"
return parsed != not_available
def is_available(id_: str) -> bool:
url = (
"api.steampowered.com/IPhysicalGoodsService/"
"CheckInventoryAvailableByPackage/v1?origin="
f"https://store.steampowered.com&input_protobuf_encoded={id_}"
)
with urlopen(f"https://{url}", timeout=timeout) as response:
data = response.read()
return parse_availability(data)
def notify(name: str) -> None:
message = f"Version {name} is now available!"
print(message)
with urlopen(f"https://{ntfy_url}", data=str.encode(message), timeout=timeout):
pass
if __name__ == "__main__":
# Uncomment to test the notifier
# notify("TEST")
# Refurbished 64GB in Europe, tested in Poland
if is_available("COGVNxICUEw="):
notify("64GB")
Running the script
- Have any recent Python version installed. No additional modules are required.
- Set
ntfy_urlin the script to your own URL. Go to ntfy and obtain one. I definitely recommend installing the app on your iOS/Android phone.
For Windows Server, you may need to add ntfy.sh and api.steampowered.com to trusted sites in IE settings.
Conclusion
The Steam Deck Availability Checker demonstrates how simple Python scripts can solve practical problems. It’s an excellent project for anyone looking to build something useful while learning about APIs, notifications, and Python automation.
Feel free to check out the GitHub repository for the complete code, contribute to the project, or customize it to suit your needs.
Happy coding!
SOCIAL SHARE CARD GENERATOR