UZUZI
UZUZI

Reputation: 11

Turn Minecraft name to UUID in javascript

I'm building a Website on which you can enter your Minecraft UUID and it gives you a 3D Render of your Minecraft Skin. Unfortunately the API I am using only supports UUIDs. I thought the website could work like this:

  1. You Enter a Username
  2. The Username gets converted to a UUID using some API
  3. The UUID gets send to the other API which hands you a Render of your Skin

How can this be done?


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" media="screen" href="https://fontlibrary.org//face/minecraftia" type="text/css"/>
    <title>Check Minecraft Skin!</title>
    <script src="https://kit.fontawesome.com/c0ac5a1789.js" crossorigin="anonymous"></script>
</head>
<body>
    <main>


        <input type="text" id="skinname" placeholder="Enter your UUID" />
        <button class="button">Search</button>
    
        <div class="output">
          <img id="image"/>
        </div>
    
        <script>
      const skinname = document.getElementById("skinname");
      const button = document.querySelector("button");
      const image = document.getElementById("image");
      button.addEventListener("click", async () => {
        const rta = await fetch(
          "https://visage.surgeplay.com/full/500/" + skinname.value
        );
        image.src = rta.url;
        }); 
        </script>
    </main>
</body>
</html>

Upvotes: 1

Views: 1276

Answers (1)

twice01
twice01

Reputation: 181

You can use official Mojang API

https://api.mojang.com/users/profiles/minecraft/<username>

Upvotes: 2

Related Questions