Recently, I decided to create a database of all the games I own on Steam — not just a simple list, but something I could sort, search, and even track my playtime with. I didn’t want anything overly complicated or online — just something simple I could run locally on my computer, where I could:
- See all my Steam games
- Track how long I’ve played each one
- Know when I last played them
- Sort or search through them however I like
Obviously I did not wish to have to manually put in data for 600+ Steam games into a database, and I also wanted a fast method of updating this data when required.
Step 1: Setting Up XAMPP
To run a database and PHP scripts on my computer, I installed a free tool called XAMPP. It acts as a local server, letting you run websites and databases on your own PC without needing to go online.
Once XAMPP was installed, I opened its Control Panel and started two services:
- Apache – to run PHP scripts
- MySQL – to handle my database
![]() |
XAMPP Control Panel |
Step 2: Creating My Database
With MySQL running, I opened phpMyAdmin, which is a browser-based interface for managing databases (available at http://localhost/phpmyadmin once Apache is active).
Inside phpMyAdmin, I:
- Created a new database called steam_collection
- Made a table called games
- Added columns for:
- game_id (the unique number Steam gives each game)
- name (the game’s title)
- playtime_forever (how long I’ve played the game in total)
- playtime_2weeks (how long I’ve played it in the past 2 weeks)
- last_played (the last date I launched it)
Step 3: Accessing My Steam Library
Steam doesn’t automatically give you your library data — but it does offer a Web API, which lets you retrieve your own data.
To retrieve this data I:
- Signed in at Steam’s Developer site
- Requested a free API key
- Found my SteamID64 (a long number that identifies your account — I used steamid.io to find it)
Step 4: Writing the Import Script (in PHP)
Next, I created a small PHP file called steam_import.php — a script that:- Connects to the Steam API using my API key and SteamID
- Pulls all my owned games and playtimes
- Connects to my MySQL database
- Inserts (or updates) each game into the table
I saved this file into XAMPP’s htdocs folder (where websites and scripts are stored), so it could run on my local server.
![]() | |
Part of my import script |
Step 5: Running the Script
To activate the script, I simply opened my browser and visited http://localhost/steam_import.php to begin the script. The last part of this URL had to match the file name exactly in order to work.Behind the scenes, this:
- Pulled my entire Steam library from the API
- Inserted each game into the steam_collection database
- Updated any existing records with the latest playtime or last played date
![]() |
Confirmation of a successful update. |
Step 6: Making the Data Easier to Read
Steam reports playtime in minutes, which isn’t very friendly. So I added some code to convert it into hours and minutes, such as “05 hrs 30 mins”.
I also cleaned up the last_played date so it only showed the date, not the full timestamp (no one needs to know I last played Lord of the Rings Online at exactly 3:42 AM).
I chose to store the raw minutes separately and use the formatted text just for display. This way, I could still sort and filter by playtime properly.
I also cleaned up the last_played date so it only showed the date, not the full timestamp (no one needs to know I last played Lord of the Rings Online at exactly 3:42 AM).
I chose to store the raw minutes separately and use the formatted text just for display. This way, I could still sort and filter by playtime properly.
Step 7: Viewing My Collection
With everything imported, I went back into phpMyAdmin to view the table. It looked great! Each row shows:
- The game’s name
- Total playtime (formatted)
- Recent playtime (last 2 weeks)
- When I last played it
And because the minute values are stored in a separate column, I can sort by most played games, recent activity, or even filter out games I haven’t touched in years.
![]() | |||
Most played games of all time |
![]() |
Games played in 2025 |
Automatically Refreshing the Data
Any time I want to update my collection, I just revisit:http://localhost/steam_import.php
This reruns the script and pulls in my latest playtimes — quick and easy.
What I Learned
Even though I was already comfortable with SQL and using XAMPP, this project helped me connect the dots between different parts of the development process — turning individual tools I knew into a complete, working system.
- Working with a live API like Steam’s was a big step forward. I’d never used an external API in a personal project before, and it was eye-opening to see how accessible and flexible they can be. Understanding how to structure the request, handle the JSON response, and extract the data I needed added a real-world element to my database knowledge.
- Automating the data import with PHP gave me a new appreciation for how back-end scripting can complement a database. I didn’t just run queries manually — I wrote logic that could run over and over, fetching fresh data and updating my tables dynamically.
- Formatting raw data for display and usability — like converting playtime from minutes to a readable format, or cleaning up date outputs — made me think more about how data is consumed, not just stored. It’s one thing to collect information; it’s another to make it useful and readable.
- Designing with filtering and sorting in mind pushed me to consider the structure of my database more carefully. Separating raw values (like total minutes) from display values ensured I could sort accurately without sacrificing readability.
- Using views and calculated fields reminded me how much power SQL has for presenting data cleanly. Instead of reformatting everything manually every time, I used views to simplify repeated queries, helping me streamline the workflow.
This project wasn’t just a fun personal tracker — it was a way to reinforce what I already knew and push further, integrating API handling, automation, and thoughtful database design into a single, cohesive process.