
Security News
Vite+ Joins the Push to Consolidate JavaScript Tooling
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
@neuralnexus/ampapi
Advanced tools
An API that allows you to communicate with AMP installations from within JavaScript/TypeScript.
An API that allows you to communicate with AMP installations from within JavaScript/TypeScript.
Documentation for available API calls can be found by appending /API to the URL of any existing AMP installation.
Support:
@thepotatoking3452
in the #development
channel of the AMP Discordnpm install @neuralnexus/ampapi
yarn add @neuralnexus/ampapi
bun install @neuralnexus/ampapi
import { CommonAPI } from "@neuralnexus/ampapi";
// If you know the module that the instance is using, specify it instead of CommonAPI
const API = new CommonAPI("http://localhost:8080/", "admin", "myfancypassword123");
await API.APILogin();
// API call parameters are simply in the same order as shown in the documentation.
API.Core.SendConsoleMessage("say Hello Everyone, this message was sent from the TypeScript API!");
const currentStatus = await API.Core.GetStatus();
const CPUUsagePercent = currentStatus.Metrics["CPU Usage"].Percent;
console.log(`Current CPU usage is: " + ${CPUUsagePercent} "%`);
import { ADS } from "@neuralnexus/ampapi";
const API = new ADS("http://localhost:8080/", "admin", "myfancypassword123");
await API.APILogin();
// Get the available instances
const targets = await API.ADSModule.GetInstances();
// In this example, my Hub server is on the second target
// If you're running a standalone setup, you can just use targets[0]
const target = targets[1]
let hub_instance_id = "";
// Get the available instances
const instances = target.AvailableInstances;
for (const instance of instances) {
// Find the instance named "Hub"
if (instance.InstanceName == "Hub") {
hub_instance_id = instance.InstanceID;
break;
}
}
// Use the instance ID to get the API for the instance
const Hub = await API.InstanceLogin(hub_instance_id, "Minecraft");
// Get the current CPU usage
const currentStatus = await Hub.Core.GetStatus();
const CPUUsagePercent = currentStatus.Metrics["CPU Usage"].Percent;
// Send a message to the console
await Hub.Core.SendConsoleMessage(`say Current CPU usage is: ${CPUUsagePercent}%`)
import { CommonAPI } from "@neuralnexus/ampapi";
try {
const API = new CommonAPI("http://localhost:8080/");
// The third parameter is either used for 2FA logins, or if no password is specified to use a remembered token from a previous login, or a service login token.
const loginResult = await API.Core.Login("admin", "myfancypassword123", "", false);
if (loginResult.hasOwnProperty("success") && loginResult.success === true) {
console.log("Login successful");
API.sessionId = loginResult["sessionID"];
// API call parameters are simply in the same order as shown in the documentation.
await API.Core.SendConsoleMessage("say Hello Everyone, this message was sent from the Python API!");
const currentStatus = await API.Core.GetStatus();
const CPUUsagePercent = currentStatus.Metrics["CPU Usage"].Percent;
console.log(`Current CPU usage is: ${CPUUsagePercent}%`);
} else {
console.log("Login failed");
console.log(loginResult);
}
} catch(err) {
// In reality, you'd handle this exception better
throw new Error(err)
}
import { CommonAPI, Status } from "@neuralnexus/ampapi";
// If you know the module that the instance is using, specify it instead of CommonAPI
const API: CommonAPI = new CommonAPI("http://localhost:8080/", "admin", "myfancypassword123");
await API.APILogin();
// API call parameters are simply in the same order as shown in the documentation.
API.Core.SendConsoleMessage("say Hello Everyone, this message was sent from the TypeScript API!");
const currentStatus: Status = await API.Core.GetStatus();
const CPUUsagePercent: number = currentStatus.Metrics["CPU Usage"].Percent;
console.log(`Current CPU usage is: " + ${CPUUsagePercent} "%`);
import { ADS, IADSInstance, Instance, Minecraft, Result, Status, UUID } from "@neuralnexus/ampapi";
const API: ADS = new ADS("http://localhost:8080/", "admin", "myfancypassword123");
await API.APILogin();
// Get the available instances
const targets: IADSInstance[] = await API.ADSModule.GetInstances();
// In this example, my Hub server is on the second target
// If you're running a standalone setup, you can just use targets[0]
const target: IADSInstance = targets[1]
let hub_instance_id: UUID;
// Get the available instances
const instances: Instance[] = target.AvailableInstances;
for (const instance of instances) {
// Find the instance named "Hub"
if (instance.InstanceName == "Hub") {
hub_instance_id = instance.InstanceID;
break;
}
}
// Use the instance ID to get the API for the instance
const Hub: Minecraft = await API.InstanceLogin(hub_instance_id, "Minecraft");
// Get the current CPU usage
const currentStatus: Status = await Hub.Core.GetStatus();
const CPUUsagePercent: number = currentStatus.Metrics["CPU Usage"].Percent;
// Send a message to the console
await Hub.Core.SendConsoleMessage(`say Current CPU usage is: ${CPUUsagePercent}%`)
import { CommonAPI, LoginResult, Status } from "@neuralnexus/ampapi";
try {
const API: CommonAPI = new CommonAPI("http://localhost:8080/");
// The third parameter is either used for 2FA logins, or if no password is specified to use a remembered token from a previous login, or a service login token.
const loginResult: LoginResult = await API.Core.Login("admin", "myfancypassword123", "", false);
if (loginResult.hasOwnProperty("success") && loginResult.success === true) {
console.log("Login successful");
API.sessionId = loginResult["sessionID"];
// API call parameters are simply in the same order as shown in the documentation.
await API.Core.SendConsoleMessage("say Hello Everyone, this message was sent from the Python API!");
const currentStatus: Status = await API.Core.GetStatus();
const CPUUsagePercent: number = currentStatus.Metrics["CPU Usage"].Percent;
console.log(`Current CPU usage is: ${CPUUsagePercent}%`);
} else {
console.log("Login failed");
console.log(loginResult);
}
} catch(err) {
// In reality, you'd handle this exception better
throw new Error(err)
}
FAQs
An API that allows you to communicate with AMP installations from within JavaScript/TypeScript.
We found that @neuralnexus/ampapi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Security News
Ruby Central’s incident report on the RubyGems.org access dispute sparks backlash from former maintainers and renewed debate over project governance.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.