12 Oct 2020 Generate Minecraft whitelist from username list [python]

Simple script that allows to create Minecraft server whitelist.json file from list of player usernames.

import requests, json, uuid

whitelist = []

for line in open("players.txt", "r"):
    r = requests.get("https://api.mojang.com/users/profiles/minecraft/" + line.rstrip())
    pj = json.loads(r.text)
    whitelist.append({
        "uuid": str(uuid.UUID(pj['id'])),
        "name": pj['name']
    })
print(json.dumps(whitelist))

Just put player list in players.txt (one per line), run script and pipe output to another file (python whitelist.py > whitelist.json)