ANOTHER REWRITE WILL HAPPEN SO I CAN FIX UP SOME FUNCTIONS, GIVE ME TIME AND EVERYTHING WILL BE IN WORKING ORDER AGAIN!
If you have issues with downloading this package, and you come accross "package.json" not found, open a cmd.exe in the startup bar of your PC and then type npm init -y
IF YOU HAVE ANY ISSUES WITH THIS API, PLEASE JOIN THIS DISCORD AND ASK FOR SUPPORT. https://discord.gg/beTDVtD
login() WAS RECENTLY CHANGED PLEASE VIEW NEW DOCUMENTATION
Stars are very much appreciated <3, i would really appreciate if you find this project useful to please share with your frends :)
While this was originally meant to work with Discord.js, it will work with any of NodeJS librarys, such as socket.io and more!.
npm install nodeactyl
First, follow the installation instructions, then you will need to have the following in your code.
AS OF 1.3.0 AND AFTER THIS WAS CHANGED TO THIS!!
After importing the API, you need to "login" to your panel/server like so:
You need to specify wether you login() needs to be a client login or administrator login/
Nodeactyl is an API For NodeJS to communicated with the panel, you can control ANY server on your nodes with it (If you purchase a server from another host, no worry! The API works with your own server too!) . Thie library original intent was to be for discord bots, but since this is in NodeJS, it is usable in ANY type of NodeJS program You can remake your own UI for the panel, and just stick with the pterodactyl daemon, doesnt suit you? use it in socket.io and have your node/server information displayed on a webpage! The possibilitys are endless!
This API works by using the pterodactyl API (Curl requests) to the server/node, by gathering the Panel website, Account API and a server/node ID. This library depends on axios, a promise basid http/https request system, this is how nodectyl is able to send curl commands to pterodactyl. The API itself is VERY simple and i am extremely suprised that no one has even tried making one (There are probably private ones, but none are avaliable to the public).
Below is some basic documentation until the documentation is fully complete, the WIP documentation can be viewed here: https://nodeactyl.elliotfrost.xyz.
Dont even try using this API without reading Getting Started guide.
How to get online status of a server.
How to get the entire server object (returns literally everything).
/* Returns a JSON Object like so:
"attributes":{
"server_owner":true,
"identifier":"d3aac109",
"uuid":"d3aac109-e5a0-4331-b03e-3454f7e136dc",
"name":"Survival",
"description":"",
"limits":{
"memory":1024,
"swap":0,
"disk":5000,
"io":500,
"cpu":200
},
"feature_limits":{
"databases":5,
"allocations":5
}
}*/
How to check if the API Key holder is the owner of a server.
/* Returns CPU Usage in a JSON Object:
{
"totalCPU": "23%"
}*/
/* Returns RAM Usage in a JSON Object:
{
"totalRAM": 1024,
"usedRAM": 234
}*/
/* Returns storage in a JSON Object
{
"usedDisk": 657
"totalDisk": 10000
}*/
How to get name/description of a server.
/* Returns storage in a JSON Object
{
"name": "Super neat server (Not really)",
"description": "A cool Server"
}*/
How to get the IDs of a server.
/* Returns storage in a JSON Object
{
"id": "86s3n93",
"uuid": "soidhyffiuy87trg8rhg8egvregfyiegyurgfduiegfiwhgdfiudwhgfiuw2huifregyufgwipgfugwiufgyrfguiewgfruehufhgwdg"
}*/
How to get a server's allocation amount.
/* Returns storage in a JSON Object
{
"amount": 2
}*/
How to get a server's MySQL Database amount.
/* Returns storage in a JSON Object
{
"amount": 1
}*/
How to send a commands to a server.
How to get a list of all servers a user has access to.
NOTE: **PLEASE VIEW ** Examples
TO SEE THIS IN ACTION, THIS ALONE IS NOT ENOUGH TO DO WHAT YOU NEED
/* RETURNS JSON LIKE THIS:
"attributes":{
"server_owner":true,
"identifier":"d3aac109",
"uuid":"d3aac109-e5a0-4331-b03e-3454f7e136dc",
name":"Survival",
"description":"",
"limits":{
"memory":1024,
"swap":0,
"disk":5000,
"io":500,
"cpu":200
},
"feature_limits":{
"databases":5,
"allocations":5
}
}
}*/
// (This will keep repeating)
NOTE YOU WILL NEED A APPLICATION API KEY NOT YOUR ACCOUNT API
How to list all users.
NOTE: Take a look at the getALlServers() in the /examples/ area, this works the same way
/* RETURNS JSON OBJECT(S) LIKE THIS:
{
"object": "user",
"attributes": {
"id": 1,
"external_id": null,
"uuid": "c4022c6c-9bf1-4a23-bff9-519cceb38335",
"username": "codeco",
"email": "[email protected]",
"first_name": "Rihan",
"last_name": "Arfan",
"language": "en",
"root_admin": true,
"2fa": false,
"created_at": "2018-03-18T15:15:17+00:00",
"updated_at": "2018-10-16T21:51:21+00:00"
}
}
/* RETURNS A JSON LIKE THIS
{
"object": "user",
"attributes": {
"id": 1,
"external_id": null,
"uuid": "c4022c6c-9bf1-4a23-bff9-519cceb38335",
"username": "codeco",
"email": "[email protected]",
"first_name": "Rihan",
"last_name": "Arfan",
"language": "en",
"root_admin": true,
"2fa": false,
"created_at": "2018-03-18T15:15:17+00:00",
"updated_at": "2018-10-16T21:51:21+00:00"
}*/
How to get user by external ID.
/* RETURNS A JSON LIKE THIS
{
"object": "user",
"attributes": {
"id": 1,
"external_id": null,
"uuid": "c4022c6c-9bf1-4a23-bff9-519cceb38335",
"username": "codeco",
"email": "[email protected]",
"first_name": "Rihan",
"last_name": "Arfan",
"language": "en",
"root_admin": true,
"2fa": false,
"created_at": "2018-03-18T15:15:17+00:00",
"updated_at": "2018-10-16T21:51:21+00:00"
}
}*/
How to create a server.
Node.login("https://panel.mypanel.com", "8JvMkvdy6L632H3gFY")
Node.createServer("NameServer", "1", "5", "15", "quay.io/pterodactyl/core:java-glibc", "java -Xms128M -Xmx 1024M -jar server.jar", "500", "0", "1024", "500", "100", "1", "2")
// Please provide the following information in order: NameServer, IDOwner, NestID, EggID, DockerImage, Startup, Memory, Swap, Disk, io, Cpu, NumberDataBases, NumberAllocations
How to change user account details.
How to list all nodes.
NOTE: Follow example for getAlllServers() to fully use this API!
/* RETURNS A JSON OBJECT LIKE SO:
{
"object": "node",
"attributes": {
"id": 2,
"public": true,
"name": "Test",
"description": "Test",
"location_id": 1,
"fqdn": "fsn1.matthewp.io",
"scheme": "https",
"behind_proxy": false,
"maintenance_mode": false,
"memory": 4096,
"memory_overallocate": 0,
"disk": 10000,
"disk_overallocate": 0,
"upload_size": 100,
"daemon_listen": 2096,
"daemon_sftp": 2022,
"daemon_base": "\/tmp\/daemon-data",
"created_at": "2018-04-06T02:19:33+00:00",
"updated_at": "2018-10-28T01:13:03+00:00"
}
}*/
/* RETURNS A JSON OBJECT LIKE SO:
{
"object": "node",
"attributes": {
"id": 2,
"public": true,
"name": "Test",
"description": "Test",
"location_id": 1,
"fqdn": "fsn1.matthewp.io",
"scheme": "https",
"behind_proxy": false,
"maintenance_mode": false,
"memory": 4096,
"memory_overallocate": 0,
"disk": 10000,
"disk_overallocate": 0,
"upload_size": 100,
"daemon_listen": 2096,
"daemon_sftp": 2022,
"daemon_base": "\/tmp\/daemon-data",
"created_at": "2018-04-06T02:19:33+00:00",
"updated_at": "2018-10-28T01:13:03+00:00"
}
}
*/
How to create/edit a node:,br /> Seriously... you dont want a API for this. just do it manually (Will add if requested)
How to list node allocations (Which servers have which ports, or see if ports are open):
NOTE: Take a look at the /examples/ for getAllServers() in order to use this API fully
/* RETURNS A JSON OBJECT LIKE SO:
{
"object": "allocation",
"attributes": {
"id": 3,
"ip": "195.201.194.74",
"alias": null,
"port": 25499,
"assigned": true
}
}
*/
How to create/delete allocations:,br /> Will be added if requested
How to get every single server on the panel:
NOTE: Take a look at the /examples/ for getAllServers() in order to use this API fully
/* RETURNS A JSON OBJECT AS SO:
{
"object": "server",
"attributes": {
"id": 2,
"external_id": null,
"uuid": "47a7052b-f07e-4845-989d-e876e30960f4",
"identifier": "47a7052b",
"name": "Eat Cows",
"description": "",
"suspended": false,
"limits": {
"memory": 2048,
"swap": -1,
"disk": 10000,
"io": 500,
"cpu": 300
},
"feature_limits": {
"databases": 10,
"allocations": 0
},
"user": 1,
"node": 2,
"allocation": 3,
"nest": 1,
"egg": 4,
"pack": null,
"container": {
"startup_command": "java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}",
"image": "quay.io\/pterodactyl\/core:java",
"installed": true,
"environment": {
"SERVER_JARFILE": "server.jar",
"VANILLA_VERSION": "latest",
"STARTUP": "java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}",
"P_SERVER_LOCATION": "test",
"P_SERVER_UUID": "47a7052b-f07e-4845-989d-e876e30960f4"
}
},
"updated_at": "2018-11-20T14:35:00+00:00",
"created_at": "2018-09-29T22:50:16+00:00"
}
}
*/
how to get detailed server details:
/* RETURNS A JSON OBJECT AS SO:
{
"object": "server",
"attributes": {
"id": 2,
"external_id": null,
"uuid": "47a7052b-f07e-4845-989d-e876e30960f4",
"identifier": "47a7052b",
"name": "Survival",
"description": "gsk;ljgkj;hgdakl;gha",
"suspended": false,
"limits": {
"memory": 2048,
"swap": -1,
"disk": 10000,
"io": 500,
"cpu": 300
},
"feature_limits": {
"databases": 10,
"allocations": 0
},
"user": 1,
"node": 2,
"allocation": 3,
"nest": 1,
"egg": 4,
"pack": null,
"container": {
"startup_command": "java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}",
"image": "quay.io\/pterodactyl\/core:java",
"installed": true,
"environment": {
"SERVER_JARFILE": "server.jar",
"VANILLA_VERSION": "latest",
"STARTUP": "java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}",
"P_SERVER_LOCATION": "test",
"P_SERVER_UUID": "47a7052b-f07e-4845-989d-e876e30960f4"
}
},
"updated_at": "2018-11-20T02:52:37+00:00",
"created_at": "2018-09-29T22:50:16+00:00"
}
}
*/
How to Update Server Build configuration/update Startup parameters/update server details: Please, save yourself the hassle and do it in the panel (Will add upon request)