Spigot API Documentation

Analyze a spigot jar

Analyze a spigot jar and get a list of possible matches

POST

/api/v1/spigot/

The main purpose of this endpoint is to analyze a spigot jar and identify the correct minecraft version. While identifying the spigot build is possible, it is not recommended.

Upload file here

Upload spigot jar file to test API endpoint

Generate fingerprint

Because Spigot jar files are generated by BuildTools and are therefore unique, a simple file hash won't work. Instead, we generate a fingerprint of the jar file. This fingerprint is a list of all the files in the jar file, their MD5 hash and their name.

import JSZip from "jszip";

function Md5HashFileContents(data) {
    return new Promise((resolve, reject) => {
        let fileReader = new FileReader();
        fileReader.onload = function (e) {
            const md5 = SparkMD5.ArrayBuffer.hash(e.target.result);
            resolve(md5);
        };
        fileReader.onerror = function () {
            reject("error");
        };
        fileReader.readAsArrayBuffer(data);
    });
}

function ProcessFileInJar(name, file) {
    return new Promise(async (resolve, reject) => {
        const data = await file.async("blob");
        const hash = await Md5HashFileContents(data)
        resolve([name, hash]);
    })
}

export async function JarFileFingerprint(file) {
    let zip = new JSZip();
    let files = await zip.loadAsync(file);
    let promises = [];
    for (let file of Object.keys(files.files)) {
        promises.push(ProcessFileInJar(file, files.files[file]));
    }
    const results = await Promise.all(promises);
    return results;
}

Fingerprint

Create request

Now that we have a fingerprint, we can create a request to the API. The request is a simple JSON object with a single property, edges. The edges property is an array of all the edges in the fingerprint. Each edge is an array of two elements, the first being the name of the file and the second being the MD5 hash as seen above.

const file = "server.jar";

const fingerprint = await JarFileFingerprint(file)
let result = await fetch('/api/v1/spigot', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
    },
    body: JSON.stringify({
        "edges": fingerprint
    }),
});

result = await result.json();
console.log(result);

Response

The response is a JSON object with a array of possible matches. Each match is an object with the following properties:
- score: The score of the match. The higher the score, the more likely it is that the match is correct.
- file: Information about the file that was matched.

There are some limitations, its accuracy is reduced because of resource constraints. Its very accurate for version identification, but not so much for the build number.