Oracle
ORACLE
docs

Decompiler API

The Oracle Decompiler API provides a powerful service for decompiling Lua scripts. This guide explains how to use the API effectively.

Authentication

All API requests require authentication using a Bearer token. Include your API key in the request headers:

Authorization: Bearer YOUR_API_KEY

Endpoint

POST https://oracle.mshq.dev/decompile

Request Format

The API accepts POST requests with a JSON body containing the following parameters:

ParameterTypeDescription
scriptstringBase64 encoded bytecode of the Lua script
decompilerOptionsobject(Optional) Configuration options for the decompiler

Decompiler Options

OptionTypeDescription
renamingTypestringType of renaming to apply ("NONE", "UNIQUE", "UNIQUE_VALUE_BASED")
removeDotZerobooleanRemove .0 from numbers
removeFunctionEntryNotebooleanRemove function entry notes
swapConstantPositionbooleanSwap constant positions in expressions
inlineWhileConditionsbooleanInline while loop conditions
showFunctionLineDefinedbooleanShow line numbers where functions are defined
removeUselessNumericForStepbooleanRemove unnecessary step values in numeric for loops
removeUselessReturnInFunctionbooleanRemove redundant return statements at function end
sugarRecursiveLocalFunctionsbooleanOptimize recursive local function declarations
sugarLocalFunctionsbooleanOptimize local function declarations
sugarGlobalFunctionsbooleanOptimize global function declarations
sugarGenericForbooleanOptimize generic for loop syntax
showFunctionDebugNamebooleanShow debug names for functions
upvalueCommentbooleanAdd comments for upvalue references

Response Codes

Status CodeDescription
200Success - Returns decompiled code
400Bad Request - Invalid options or script format
401Unauthorized - Invalid API key
402Payment Required - Insufficient tokens
429Too Many Requests - Rate limit exceeded
500Server Error - Decompilation failed

Example Usage (Node.js)

const key = "YOUR_API_KEY";
var https = require('https');
var fs = require('fs');

function request(script, key) {
    return new Promise((resolve, reject) => {
        const encoded = script.toString('base64');
        const post_data = JSON.stringify({
            'script': encoded
        });

        const post_options = {
            host: 'oracle.mshq.dev',
            path: '/decompile',
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Content-Length': Buffer.byteLength(post_data, 'utf8'),
                'Authorization': 'Bearer ' + key
            }
        };

        const post_req = https.request(post_options, (res) => {
            let data = '';

            res.setEncoding('utf8');
            res.on('data', (chunk) => {
                data += chunk;
            });

            res.on('end', () => {
                if (res.statusCode === 200) {
                    resolve(data.toString('utf8'));
                } else if (res.statusCode === 402) {
                    resolve(data.toString('utf8'));
                } else if (res.statusCode === 429) {
                    resolve(data.toString('utf8'));
                } else if (res.statusCode === 500) {
                    reject('-- Decompilation failed!');
                } else if (res.statusCode === 400) {
                    reject('-- Update the decompiling script');
                } else {
                    reject(`-- Something went wrong when decompiling: ${res.statusCode}`);
                }
            });
        });

        post_req.on('error', (e) => {
            reject(`-- Request failed: ${e.message}`);
        });

        post_req.write(post_data);
        post_req.end();
    });
}

Example Usage (Lua)

local key = "YOUR_API_KEY"
local options = {
    renamingType = "UNIQUE",
    removeDotZero = true,
    sugarGenericFor = true
}

function decompile(s)
    local response = request {
        Url = "https://oracle.mshq.dev/decompile?key=" .. key,
        Method = "POST",
        Headers = {
            ["Content-Type"] = "application/json"
        },
        Body = json.encode({
            script = encode(getscriptbytecode(s)),
            decompilerOptions = options
        }),
    }

    return
        response.StatusCode == 200 and response.Body or
        response.StatusCode == 402 and response.Body or
        response.StatusCode == 429 and response.Body or
        response.StatusCode == 401 and response.Body or
        response.StatusCode == 500 and "-- Decompilation failed!" or
        response.StatusCode == 400 and "-- Update the decompiling script / Check decompiling options for errors" or
        "-- Something went wrong when decompiling: " .. response.StatusCode
end

Rate Limits

The Decompiler API uses a queue-based rate limiting system:

  • Requests are processed as they are uploaded in a queue system
  • Processing time depends on script complexity and current queue length

Note: You may get rate limited if you send too many requests in a short period of time.