rblx.js
Version:
A JavaScript wrapper for interacting with the ROBLOX OpenCloud API.
38 lines (37 loc) • 1.67 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const urlcat_1 = __importDefault(require("urlcat"));
const axios_1 = __importDefault(require("axios"));
const BASE_URL = "https://apis.roblox.com/datastores/v1/universes";
async function main(apiKey, universeid, datastoreName, entryKey, versionid, scope) {
try {
BigInt(universeid);
}
catch (e) {
throw new Error("Invalid universeid: " + universeid);
}
if (versionid) {
const res_url = (0, urlcat_1.default)(BASE_URL, "/:universeid/standard-datastores/datastore/entries/entry/versions/version?datastoreName=:datastoreName&entryKey=:entryKey&versionId=:versionid", { universeid, datastoreName, entryKey, versionid });
const config = {
headers: {
"x-api-key": apiKey
}
};
const response = await axios_1.default.get(res_url, config);
return await response.data;
}
if (scope) {
const res_url = (0, urlcat_1.default)(BASE_URL, "/:universeid/standard-datastores/datastore/entries/entry/versions/version?datastoreName=:datastoreName&entryKey=:entryKey&versionId=:versionid&scope=:scope", { universeid, datastoreName, entryKey, versionid, scope });
const config = {
headers: {
"x-api-key": apiKey
}
};
const response = await axios_1.default.get(res_url, config);
return await response.data;
}
}
exports.default = main;