Reputation: 422
I am wondering if it is possible to take a minecraft UUID and convert it into the users current username. I know how to get all of there previous usernames, but I dont know how to single out the newest one, I am able to do this with the mojang API.
import requests
data = requests.get("https://api.mojang.com/user/profiles/UUID/names")
print(data.content)
Upvotes: 0
Views: 3259
Reputation: 3
A few lines of code can do the trick.
import requests
uuid = ["enter UUID here"]
#uuid can be a list or a single string
for i in uuid:
data = requests.get(f"https://sessionserver.mojang.com/session/minecraft/profile/{i}").json()
print(data["name"])
Good for converting mass amounts of UUID's into IGNs without using namemc. Hope this helped.
Upvotes: 0
Reputation: 21
this should work but it has no parseing
r = requests.get(f'https://api.mojang.com/users/profiles/minecraft/notchat=0').json()
uuid = r['id']
r2 = requests.get(f'https://api.mojang.com/user/profiles/{uuid}/names').json()
print(r2)
Upvotes: 2
Reputation: 422
I figured it out, I did the following.
data = requests.get("https://sessionserver.mojang.com/session/minecraft/profile/uuid").json()
print(data["name"])
NOTE: The UUID must be given with out dashes ("-")
Upvotes: 0