An API to generate a collage of games from a Steam profile. Python is used to generate the image, which is served via an HTTP server using Flask. Hosted using Kamatera.
Give it a go! --> https://alifeee.co.uk/steam_mosaic/
Blog post --> https://blog.alifeee.co.uk/steam-collage-api/
| Service | URL |
|---|---|
| Docker Hub | alifeee/steamcollageapi |
| GitHub | alifeee/steam_collage |
| Kamatera Console | alifeee |
| Kamatera Server | http://server.alifeee.co.uk |
A .env file is used to store environment variables. The following variables are used:
| Name | Description |
|---|---|
API_KEY |
Steam API key - see below. |
DO_CACHE |
Whether to cache the game thumbnails. Note that this increases the memory usage of the server. |
# .env
API_KEY=8917981789178
DO_CACHE=True
A steam API key must be placed in the .env file in the root directory, or exposed to the environment via the terminal. Keys can be obtained from Steam.
python -m venv envpip install -r requirements.txtpip freeze > requirements.txtptw -- --cov=apipython ./api/api.py debugdocker build -t alifeee/steamcollageapi .
docker run -d --restart unless-stopped -p 5000:5000 -e API_KEY=8917981789178 alifeee/steamcollageapidocker push alifeee/steamcollageapiThunder client is a VS Code extension which allows you to make HTTP requests. It is useful for testing the API.
Some tests are included in the tests collection. These can be run by using the Run All button in the top right of collection.
ssh root@server.alifeee.co.uk
> enter passworddocker pull alifeee/steamcollageapidocker ps -a
> get container id
docker rm <container id>docker create -d --restart unless-stopped -p 5000:5000 -e API_KEY=8917981789178 --name steamcollageapi alifeee/steamcollageapi
> get container id
docker start <container id>First, create the user:
sudo useradd -r -s /bin/false steamcollage
echo "user id: "$(cat /etc/passwd | grep "^steamcollage:" | awk -F':' '{print $3}')name: steam collage api
services:
steamcollageapi:
environment:
- API_KEY=1B74FD1DD42E130B9C066CE658CB0270
container_name: steamcollageapi
ports:
- 5000:5000/tcp
restart: unless-stopped
image: alifeee/steamcollageapi
# when user doesn't exist in container, user UID
# user: steamcollage
user: "994"
command: python ./api.pyThis workflow:
- Checks out the repository
- Sets up Python 3.10
- Installs dependencies
- Runs linting
- Runs tests
None.
This workflow:
- Checks out the repository
- Builds the Docker image
- Pushes the Docker image to Docker Hub
- Deploys the Docker image to Kamatera
| Name | Description |
|---|---|
API_KEY |
Steam API key - see above. |
DOCKERHUB_USERNAME |
Docker Hub username. |
DOCKERHUB_TOKEN |
Docker Hub access token. |
HOST |
IP address of the Kamatera server |
USERNAME |
Username for the Kamatera server |
KEY |
RSA key* for the Kamatera server |
See rsa_ssh_key_setup.md for details on setting up the RSA key.
All APIs are served on the port 5000.
Returns a list of games for a given steam ID.
| Name | Type | Description |
|---|---|---|
id |
string |
Steam ID or vanity URL of the user, e.g., alifeee |
cols |
int |
Number of columns in the collage |
rows |
int |
Number of rows in the collage |
sort |
name, recent, or playtime |
Sort order of the games |
wget http://localhost:5000/steamcollage/games?id=alifeee&cols=5&rows=5&sort=recentReturns a boolean indicating whether a given steam account exists, and whether it is private.
| Name | Type | Description |
|---|---|---|
id |
string |
Steam ID or vanity URL of the user, e.g., alifeee |
wget http://localhost:5000/steamcollage/verifyuser?id=alifeee{
"exists": true,
"private": false
}Returns "Alive" if the server is running.
wget http://localhost:5000/steamcollage/alive"Alive"
Returns an image if the server is running.
wget http://localhost:5000/steamcollage/alive_imgTo check the API is alive, I use Testfully to poll the /steamcollage/alive endpoint every hour.


