Code Monkey home page Code Monkey logo

mojang-api's Introduction

mojang-api

Javascript microservice that bundles multiple Mojang APIs into a single GET request.

Purpose

Mojang, the developers of Minecraft, provides multiple APIs for websites and servers to fetch identity information about users. Requests do not accept authentication tokens, however they are heavily rate limited and fragmented among several endpoints. The purpose of this project is to package several of the most commonly used APIs into a single GET request with no rate limiting and no need for client-side caching.

I have deployed this on my personal domain ashcon.app and am opening it up for the internet to use for free. It runs using Cloudflare Workers, which are Javascript functions that live in the closest datacenter to your request. The API is currently handling 1M+ requests per day with an average response time of 200ms and a < 0.0001% error rate.

Single Request (now)

Username or UUID -> Everything
https://api.ashcon.app/mojang/v2/user/[username|uuid] (click for example)

{
  "uuid": <uuid>,
  "username": <username>,
  "username_history": [
    {
      "username": <username>,
      "changed_at": <date|null>
    }
  ],
  "textures": {
    "slim": <boolean>,
    "custom": <boolean>,
    "skin": {
      "url": <url>,
      "data": <base64>
    },
    "cape": {
      "url": <url|null>,
      "data": <base64|null>
    },
    "raw": {
      "value": <base64>,
      "signature": <base64>
    }
  },
  "legacy": <true|null>,
  "demo": <true|null>,
  "created_at": <date|null>
}

Multiple Requests (before)

Username -> UUID
https://api.mojang.com/users/profiles/minecraft/[username]

{
  "id": <uuid>,
  "name": <username>
}

UUID -> Username History
https://api.mojang.com/user/profiles/[uuid]/names

[
  {
    "name": <username>
  },
  {
    "name": <username>,
    "changedToAt": <integer>
  }
]

UUID -> Profile + Textures
https://sessionserver.mojang.com/session/minecraft/profile/[uuid]

{
  "id": <uuid>,
  "name": <username>,
  "properties": [
    {
      "name": "textures",
      "value": <base64> // Then decode the base64 string and make http requests to fetch the textures...
    }
  ]
}

Build

wrangler build
wrangler preview

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.