Get all keys from a datatype?

Hello developers. I was wondering if there was any way I could get all keys that belong to a datatype.

For example, if we take a Vector3, it should contain the following properties and functions:

  • X
  • Y
  • Z
  • Magnitude
  • Unit
  • Cross
  • Angle
  • Dot
  • FuzzyEq
  • Lerp
  • Max
  • Min

Is there a built-in way to get these keys? What I mean is something like this:

local myColor = Color3.new();

for key, value in pairs(myColor) do --This will in fact error
    print(key, value);
end

Except, of course, pairs errors. But is there a way I can iterate, or get all the keys that belong to a datatype?

At first, I tried something I knew wouldn’t work, but I still did it anyways. If I could get the metatable of these datatypes then I could try to figure things out from there, however, this is obviously not possible since the following line will not return the true metatable:

local myColor = Color3.new();
print(getmetatable(myColor)); --"The metatable is locked"

Next, I thought that there would be some kind of API dump like Maximum’s Client Tracker that would provide these keys, after all, it is also not possible to get all the properties of an Instance, so I thought there might be something similar. However, the API dump only contains Enums and Classes but not datatypes. Even after I searched through, the only thing I found that was related was AutocompleteMetadata.xml, but it would seem way too unreasonable to parse the literal autocomplete XML just to search for the autocomplete functions of these datatypes and get the members from there.

So my question is: Is there any API Dump, API function, Service, or whatever that could provide me the keys that are found in datatypes? I really don’t want to either do it all manually and keep track of the changes or parse the autocomplete XML file just for that purpose.

You can get the JSON file the documents use to do it.
https://create.roblox.com/docs/_next/data/sKO2AmUfcAVQZoHYvvZW6/reference/engine/datatypes/DataTypeName.json [pageProps/data/apiReference/ (constructors, constants, properties, etc.)].

I’m assuming the directory “sKO2AmUfcAVQZoHYvvZW6” is static and won’t change; I’m not sure though.

I recommend using a JSON tree viewer to work out its format as well.

2 Likes

I may be missing something here, but when I try to open the link I get 404.

Change “DataTypeName” on the end to the name of the datatype you want

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.