Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(3 edits)

The API is fully accessible with HTTP.

The requests library is something you WILL encounter when using python. It is used for sending HTTP requests.

py -m pip install requests

The docs: https://requests.readthedocs.io/en/latest/

How you could go about doing this: Look at the cURL template on the loot locker API docs for making a session:

curl -X POST "https://api.lootlocker.io/game/v2/session/guest" \
  -H "Content-Type: application/json" \
  -d "{\"game_key\": \"your_game_key\", \"game_version\": \"0.10.0.0\"}"

What you can see: The mode is POST to the url “https://api.lootlocker.io/game/v2/session/guest”. The HTTP Headers (-H argument) are made of key-value pairs (like dictionaries). The key is “Content-Type” and the value is “application/json”. This is standard HTTP. Now to the loot locker specific stuff. The -d argument is the data you send. Here, this is {“game_key”: some_game_key, “game_version”: some_version}.

To transfer this to python:

import requests

GAME_KEY = "my_key"
GAME_VERSION = "1.0.0"

url = "https://api.lootlocker.io/game/v2/session/guest"

# This is the -H argument as a dict
headers = {
    "Content-Type": "application/json"
}

# This is the -d argument as a dict
data = {
    "game_key": GAME_KEY,
    "game_version": GAME_VERSION
}

# Since dicts are (basically) in JSON format, you can specify these as the data
# requests.post returns requests.Response, from which you can get the status_code and other information
r = requests.post(url, headers=headers, json=data)

The same thing can be done for getting the leaderboard. The API Docs show you, that the response will look something like this:

{
  "success": true,
  "session_token": "e6fa44946f077dd9fe67311ab3f188c596df9969",
  "player_id": 3,
  "public_uid": "TSEYDXD8",
  "player_identifier": "ec9b35e6-b184-4f34-b49f-980f86b291e2",
  "player_created_at": "2022-05-30T07:56:01+00:00",
  "check_grant_notifications": true,
  "check_deactivation_notifications": false,
  "seen_before": true
}

Now by accessing r.json().get("session_token") for example, we can get the session_token, which we can later use to save the score to the leaderboard.

IN SHORT:

  1. Look at the cURL template
  2. Convert -H and -d to dicts
  3. POST to the URL of the API
  4. Evaluate the Response
  5. Repeat

If you need help with anything, hit me up on discord (@fabianbuthere)!

(Sorry for the lengthy answer, I’m used to StackOverflow)

Usually i post the source code for linux users to play the game too, but I guess that i can't do that for this game since someone could just get the game id and send fake requests with higher scores

(1 edit)

Thanks Bro! I ran into some issues but figured it out later. Thanks! if it wasn't you, i'd be stuck in this for the whole day