Here is a module that can let you parse the Roblox API into a table of Properties, Functions, YieldFunctions, Events, Callbacks, Enums and EnumItems.
local APIUtil = {};
APIUtil.Url = "http://anaminus.github.io/rbx/json/api/latest.json";
APIUtil.MaxChunkSize = (100000);
setmetatable(APIUtil, {
__index = function(self, k)
local AttemptGet = rawget(APIUtil, k);
return (AttemptGet) or (game:GetService(k));
end
})
function APIUtil:Get()
local Result = self.HttpService:GetAsync(APIUtil.Url);
return Result;
end
function APIUtil:Construct()
local API = self:Get();
local function SplitIntoChunks(JSONStr)
local MaxChunkSize = APIUtil.MaxChunkSize;
local Chunks = {};
for i = 1, math.ceil(string.len(JSONStr)/MaxChunkSize) do
local Chunk = (string.sub(JSONStr, (i - 1) * MaxChunkSize + 1, (i * MaxChunkSize)));
table.insert(Chunks, Chunk);
end
return Chunks;
end
local APIChunks = SplitIntoChunks(API);
local function Decode(Str)
return self.HttpService:JSONDecode(Str);
end
local function GetRF(Index)
return APIChunks[Index], #APIChunks;
end
local function GetJSON()
local APITable = {};
local FirstPage, PageCount = GetRF(1);
table.insert(APITable, FirstPage);
for i = 2, PageCount do
local Result = GetRF(i);
table.insert(APITable, Result);
end
return table.concat(APITable);
end
local JSON = GetJSON();
local Dump = Decode(JSON);
local Classes = {};
local Enums = {};
local function SortAlpha(T, Property)
table.sort(T, function(A, B)
return A[Property] < B[Property];
end)
end
local function IsEnum(EnumName)
return (Enums[EnumName] ~= nil);
end
local function GetProperties(ClassName)
local Class = Classes[ClassName];
local Properties = {};
if (not Class) then return Properties end;
while Class do
for _, Property in next, Class.Properties do
table.insert(Properties, Property);
end
Class = Classes[Class.Superclass];
end
SortAlpha(Properties, "Name");
return Properties;
end
local ItemFunctions = {
Class = function(Item)
Classes[Item.Name] = Item;
Item.Properties = {};
Item.Functions = {};
Item.YieldFunctions = {};
Item.Events = {};
Item.Callbacks = {};
end,
Property = function(Item)
table.insert(Classes[Item.Class].Properties, Item);
end,
Function = function(Item)
table.insert(Classes[Item.Class].Functions, Item);
end,
YieldFunction = function(Item)
table.insert(Classes[Item.Class].YieldFunctions, Item);
end,
Event = function(Item)
table.insert(Classes[Item.Class].Events, Item);
end,
Callback = function(Item)
table.insert(Classes[Item.Class].Callbacks, Item);
end,
Enum = function(Item)
Enums[Item.Name] = Item;
Item.EnumItems = {};
end,
EnumItem = function(Item)
Enums[Item.Enum].EnumItems[Item.Name] = Item;
end,
}
local function SortItem(Item)
local ItemType = Item.type;
ItemFunctions[ItemType](Item);
end
for _, Item in next, Dump do
SortItem(Item);
end
return ({
Classes = Classes,
Enums = Enums,
GetProperties = GetProperties,
IsEnum = IsEnum
})
end
return APIUtil;
How to use:
Make a ModuleScript with this code (on the Server or in a Plugin).
-- Require it
local API = require(PathToAPI);
-- Construct it
local Result = API:Construct();
-- Use it (?)
print(Result.Classes.Plugin);
Output:
{
["Callbacks"] = {},
["Events"] = > {...},
["Functions"] = > {...},
["Name"] = "Plugin",
["Properties"] = > {...},
["Superclass"] = "Instance",
["YieldFunctions"] = > {...},
["tags"] = {},
["type"] = "Class",
}
Et voila. You can now easily access the properties of (I believe) any class in Roblox’s latest API.