Skip to content
This repository was archived by the owner on Sep 8, 2024. It is now read-only.

Repository files navigation

Open source pterodactyl API wrapper for JavaScript.


Application:


Application:

Features


  • Create servers and users.
  • Delete servers and users.
  • Update users.
  • Get all nodes, users, servers, nests, locations.
  • Get an induvidual node, user, server, nest, location.

More features coming soon.


Usage


Logging in

constapi=require('nodeactyl.js').Application;api.login("PanelURL","APIKey");// Your Code...


Get all users

Code:

constapi=require('nodeactyl.js').Application;api.login("PanelURL","APIKey");api.fetchUsers(options).then(users=>console.log(users));

Expected response:

Click me!
{
"data": [{
"id": 1,
"external_id": null,
"uuid": "6769acd2-a8b4-4994-b1ff-ffa6992b4713",
"username": "root",
"email": "root@example.com",
"first_name": "Root",
"last_name": ".",
"language": "en",
"root_admin": true,
"2fa": true,
"created_at": "2020-02-18T08:51:19+00:00",
"updated_at": "2020-10-21T12:42:33+00:00"
},
{
"id": 2,
"external_id": null,
"uuid": "b0c8745b-36fb-405f-b7a1-a33a50f842e8",
"username": "example",
"email": "example@example.com",
"first_name": "example",
"last_name": "account",
"language": "en",
"root_admin": false,
"2fa": false,
"created_at": "2020-02-18T10:25:29+00:00",
"updated_at": "2020-09-19T22:24:20+00:00"
}
],
"info": {
"total_amount": 2,
"startedAt": 1603661663600,
"endedAt": 1603661670919
}
}

Get all servers

Code:

constapi=require('nodeactyl.js').Application;api.login("PanelURL","APIKey");api.fetchServers().then(servers=>console.log(servers));

Expected response:

Click me!
{
"data": [{
"id": 1,
"external_id": null,
"uuid": "14ea435b-fec0-4ca1-8cae-6bab629a0f14",
"identifier": "14ea435b",
"name": "JS Server",
"description": "",
"suspended": false,
"limits": {
"memory": 0,
"swap": 0,
"disk": 0,
"io": 500,
"cpu": 0,
"threads": null
},
"feature_limits": {
"databases": 0,
"allocations": 0,
"backups": 0
},
"user": 2,
"node": 1,
"allocation": 51,
"nest": 5,
"egg": 15,
"container": {
"startup_command": "${STARTUP_CMD}",
"image": "{IMAGE}",
"installed": true,
"environment": {
"STARTUP_CMD": "bash",
"STARTUP": "${STARTUP_CMD}",
"P_SERVER_LOCATION": "US",
"P_SERVER_UUID": "14ea435b-fec0-4ca1-8cae-6bab629a0f14",
"P_SERVER_ALLOCATION_LIMIT": 0
}
},
"updated_at": "2020-07-20T09:42:31+00:00",
"created_at": "2020-02-18T10:56:06+00:00"
},
{
"id": 3,
"external_id": null,
"uuid": "17c192ff-39ed-472d-a308-1de0bbcd9167",
"identifier": "17c192ff",
"name": "Bot Server",
"description": "",
"suspended": false,
"limits": {
"memory": 0,
"swap": 0,
"disk": 5000,
"io": 500,
"cpu": 0,
"threads": null
},
"feature_limits": {
"databases": 0,
"allocations": 0,
"backups": 0
},
"user": 25,
"node": 1,
"allocation": 52,
"nest": 5,
"egg": 15,
"container": {
"startup_command": "${STARTUP_CMD}",
"image": "{IMAGE}",
"installed": true,
"environment": {
"STARTUP_CMD": "bash",
"STARTUP": "${STARTUP_CMD}",
"P_SERVER_LOCATION": "US",
"P_SERVER_UUID": "17c192ff-39ed-472d-a308-1de0bbcd9167",
"P_SERVER_ALLOCATION_LIMIT": 0
}
},
"updated_at": "2020-08-25T19:46:16+00:00",
"created_at": "2020-02-18T10:59:09+00:00"
}
],
"info": {
"total_amount": 2,
"startedAt": 1603662511023,
"endedAt": 1603662553597
}
}

Get all nodes

Code:

constapi=require('nodeactyl.js').Application;api.login("PanelURL","APIKey");api.fetchNodes(options).then(nodes=>console.log(nodes));

Expected response:

Click me!
{
"data": [{
"id": 1,
"uuid": "b55f5fd4-494c-4d35-a6d3-66e61c060ddc",
"public": true,
"name": "Node 1 - Discord Bots",
"description": "VM | Dedicated Server 1",
"location_id": 3,
"fqdn": "node.example.com",
"scheme": "https",
"behind_proxy": false,
"maintenance_mode": false,
"memory": 30720,
"memory_overallocate": 10000,
"disk": 204800,
"disk_overallocate": 10000,
"upload_size": 1024,
"daemon_listen": 8080,
"daemon_sftp": 2022,
"daemon_base": "/srv/daemon-data",
"created_at": "2020-02-18T09:30:18+00:00",
"updated_at": "2020-09-22T11:07:46+00:00",
"allocated_resources": {
"memory": 1050,
"disk": 681000
}
},
{
"id": 2,
"uuid": "53598bf3-3558-48a4-8561-61ce61adf773",
"public": false,
"name": "Node 2 - Discord Bots",
"description": "VM | Dedicated Server 1",
"location_id": 3,
"fqdn": "node.example.com",
"scheme": "https",
"behind_proxy": false,
"maintenance_mode": false,
"memory": 30720,
"memory_overallocate": 10000,
"disk": 204800,
"disk_overallocate": 10000,
"upload_size": 1024,
"daemon_listen": 8080,
"daemon_sftp": 2022,
"daemon_base": "/srv/daemon-data",
"created_at": "2020-02-18T09:30:54+00:00",
"updated_at": "2020-09-22T11:07:43+00:00",
"allocated_resources": {
"memory": 0,
"disk": 709000
}
}
],
"info": {
"total_amount": 2,
"startedAt": 1603664644572,
"endedAt": 1603664645334
}
}

Get all nests

Code:

constapi=require('nodeactyl.js').Application;api.login("PanelURL","APIKey");api.fetchNests(options).then(nests=>console.log(nests));

Expected response:

Click me!
{
"data": [{
"id": 1,
"uuid": "687c3fb5-20b8-477d-a0ea-839274463435",
"author": "support@pterodactyl.io",
"name": "Minecraft",
"description": "Minecraft - the classic game from Mojang. With support for Vanilla MC, Spigot, and many others!",
"created_at": "2020-02-18T08:51:00+00:00",
"updated_at": "2020-02-18T08:51:00+00:00"
},
{
"id": 2,
"uuid": "aff34dcb-7a85-4547-82b6-93caf31287ab",
"author": "support@pterodactyl.io",
"name": "Source Engine",
"description": "Includes support for most Source Dedicated Server games.",
"created_at": "2020-02-18T08:51:00+00:00",
"updated_at": "2020-02-18T08:51:00+00:00"
}
],
"info": {
"total_amount": 2,
"startedAt": 1603664894936,
"endedAt": 1603664895531
}
}

Get all locations

Code:

constapi=require('nodeactyl.js').Application;api.login("PanelURL","APIKey");api.fetchLocations(options).then(locations=>console.log(locations));

Expected response:

Click me!
{
"success": true,
"data": [
{
"id": 3,
"short": "US",
"long": "US LOCATION",
"updated_at": "2020-05-02T04:32:58+00:00",
"created_at": "2020-05-02T04:32:58+00:00"
},
{
"id": 5,
"short": "Gaming",
"long": "Gaming Nodes. EU and US",
"updated_at": "2020-08-10T12:56:38+00:00",
"created_at": "2020-08-10T12:56:38+00:00"
}
],
"info": {
"total_amount": 2,
"startedAt": 1603840795885,
"endedAt": 1603840805135
}
}


Get a user

Code:

constapi=require('nodeactyl.js').Application;api.login("PanelURL","APIKey");api.getUser(USERID,options).then(user=>console.log(user));

Expected response:

Click me!
{
"data": {
"id": 2,
"external_id": null,
"uuid": "b0c8745b-36fb-405f-b7a1-a33a50f842e8",
"username": "exampleaccount",
"email": "example@example.com",
"first_name": "firstName",
"last_name": "lastName",
"language": "en",
"root_admin": true,
"2fa": false,
"created_at": "2020-02-18T10:25:29+00:00",
"updated_at": "2020-09-19T22:24:20+00:00",
"extras": {
"servers": ["servers..."]
}
},
"info": {
"total_amount": 1,
"startedAt": 1603665900917,
"endedAt": 1603665901747
}
}

Get a server

Code:

constapi=require('nodeactyl.js').Application;api.login("PanelURL","APIKey");api.getServer(SERVERID,options).then(server=>console.log(server));

Expected response:

Click me!
{
"data": {
"id": 1,
"external_id": null,
"uuid": "14ea435b-fec0-4ca1-8cae-6bab629a0f14",
"identifier": "14ea435b",
"name": "JS Server",
"description": "",
"suspended": false,
"limits": {
"memory": 0,
"swap": 0,
"disk": 0,
"io": 500,
"cpu": 0,
"threads": null
},
"feature_limits": {
"databases": 0,
"allocations": 0,
"backups": 0
},
"user": 2,
"node": 1,
"allocation": 51,
"nest": 5,
"egg": 15,
"container": {
"startup_command": "${STARTUP_CMD}",
"image": "{IMAGE}",
"installed": true,
"environment": {
"STARTUP_CMD": "bash",
"STARTUP": "${STARTUP_CMD}",
"P_SERVER_LOCATION": "US",
"P_SERVER_UUID": "14ea435b-fec0-4ca1-8cae-6bab629a0f14",
"P_SERVER_ALLOCATION_LIMIT": 0
}
},
"updated_at": "2020-07-20T09:42:31+00:00",
"created_at": "2020-02-18T10:56:06+00:00"
},
"info": {
"total_amount": 1,
"startedAt": 1603666633385,
"endedAt": 1603666634042
}
}

Get a node

Code:

constapi=require('nodeactyl.js').Application;api.login("PanelURL","APIKey");api.getNode(NODEID,options).then(node=>console.log(node));

Expected response:

Click me!
{
"data": {
"id": 2,
"uuid": "53598bf3-3558-48a4-8561-61ce61adf773",
"public": false,
"name": "Node 2 - Discord Bots",
"description": "VM | Dedicated Server 1",
"location_id": 3,
"fqdn": "node.example.com",
"scheme": "https",
"behind_proxy": false,
"maintenance_mode": false,
"memory": 30720,
"memory_overallocate": 10000,
"disk": 204800,
"disk_overallocate": 10000,
"upload_size": 1024,
"daemon_listen": 8080,
"daemon_sftp": 2022,
"daemon_base": "/srv/daemon-data",
"created_at": "2020-02-18T09:30:54+00:00",
"updated_at": "2020-09-22T11:07:43+00:00",
"allocated_resources": {
"memory": 0,
"disk": 709000
}
},
"info": {
"total_amount": 1,
"startedAt": 1603666178333,
"endedAt": 1603666179108
}
}

Get a nest

Code:

constapi=require('nodeactyl.js').Application;api.login("PanelURL","APIKey");api.getNest(NESTID,options).then(nest=>console.log(nest));

Expected response:

Click me!
{
"data": {
"id": 1,
"uuid": "687c3fb5-20b8-477d-a0ea-839274463435",
"author": "support@pterodactyl.io",
"name": "Minecraft",
"description": "Minecraft - the classic game from Mojang. With support for Vanilla MC, Spigot, and many others!",
"created_at": "2020-02-18T08:51:00+00:00",
"updated_at": "2020-02-18T08:51:00+00:00",
"extras": {
"eggs": ["eggs..."],
"servers": ["servers..."]
}
},
"info": {
"total_amount": 1,
"startedAt": 1603667043772,
"endedAt": 1603667049412
}
}

Get a location

Code:

constapi=require('nodeactyl.js').Application;api.login("PanelURL","APIKey");api.getLocation(3,options).then(location=>console.log(location));

Expected response:

Click me!
{
"success": true,
"data": {
"id": 3,
"short": "US",
"long": "US LOCATION",
"updated_at": "2020-05-02T04:32:58+00:00",
"created_at": "2020-05-02T04:32:58+00:00"
},
"info": {
"total_amount": 1,
"startedAt": 1603840795885,
"endedAt": 1603840805135
}
}


Create a user

Code:

constapi=require('nodeactyl.js').Application;api.login("PanelURL","APIKey");api.createUser("example","example","example@example.com","ExampleFirst","ExampleLast",false,"en").then(newUser=>console.log(newUser));

Arguments:

Click me!

List of arguments: (use in order)

ArgumenttypeDescriptionRequired?
UsernameStringUsers username.Yes
PasswordStringUsers password.Yes
EmailStringUsers Email.Yes
FirstNameStringUsers first name.Yes
LastNameStringUsers last name.Yes
IsAdminBooleanIs the user admin?Yes
LanguageStringLanguage. [en/fr]Yes

Expected response:

Click me!
{
"success": true,
"data": {
"id": 1155,
"external_id": null,
"uuid": "9cc0ee54-640f-4bdb-ad84-3a193ada8644",
"username": "example",
"email": "example@example.com",
"first_name": "ExampleFirst",
"last_name": "ExampleLast",
"language": "en",
"root_admin": false,
"2fa": false,
"created_at": "2020-10-26T00:13:50+00:00",
"updated_at": "2020-10-26T00:13:50+00:00"
},
"info": {
"total_amount": 1,
"startedAt": 1603671229920,
"endedAt": 1603671230779
}
}

Create a server

Code:

constapi=require('nodeactyl.js').Application;api.login("PanelURL","APIKey");api.createServer("test",2,5,16,3,0,-1,0,500,0,null,null,{"INSTALL_REPO": null,"INSTALL_BRANCH": null,"USER_UPLOAD": "0","AUTO_UPDATE": "0","BOT_JS_FILE": "index.js"},{databases: 1,allocations: 0,backups: 5}).then(newServer=>console.log(newServer));

Arguments:

Click me!

List of arguments: (use in order)

ArgumenttypeDescriptionRequired?
ServerNameStringCharacter limits: a-z A-Z 0-9 _ - . and [Space].Yes
UserIDNumberUsers ID.Yes
NestIDNumberthe Nest that this server will be grouped under.Yes
EggIDNumberthe Egg will define how this server should operate.Yes
LocationNumberNode location.Yes
CPUNumberThe amount of CPU Power the server can use. (100 = 1 core)Yes
RAMNumberThe maximum amount of memory allowed for this container.Yes
SwapNumberSetting this to 0 will disable swap space on this server. Setting to -1 will allow unlimited swapYes
DiskNumberThis server will not be allowed to boot if it is using more than this amount of space.Yes
IONumberThe IO performance of this server relative to other running containers on the system. Value should be between 10 and 1000 (please keep at 500)Yes
DockerImage[String|null]This is the default Docker image that will be used to run this server. Can be null (if null the wrapper will get the dockerimage from the egg)Yes
StartupCmd[String|null]Start Up Command. Can be null (if null the wrapper will get the default startupcmd from the egg)Yes
environmentObjectenviroment (The information the egg requires.)Yes
optionObjectFeature Limits: [databases, allocations, backups]No
option.databasesNumberAmount of databases this server is allowed to have. (Default: 0)No
option.allocationsNumberAmount of allocations this server is allowed to have. (Default: 0)No
option.backupsNumberAmount of backups this server is allowed to have. (Default: 0)No

Expected response:

Click me!
{
"success": true,
"data": {
"id": 4973,
"external_id": null,
"uuid": "243b320e-c925-4260-a3bd-d820efc0f8d8",
"identifier": "243b320e",
"name": "test",
"description": "",
"suspended": false,
"limits": {
"memory": 0,
"swap": -1,
"disk": 0,
"io": 500,
"cpu": 0,
"threads": null
},
"feature_limits": {
"databases": 0,
"allocations": 0,
"backups": 0
},
"user": 2,
"node": 1,
"allocation": 4295,
"nest": 5,
"egg": 16,
"container": {
"startup_command": "if [[ -d .git ]] && [[ {{AUTO_UPDATE}} == \"1\" ]]; then git pull; fi && /usr/local/bin/npm install --production && /usr/local/bin/node /home/container/{{BOT_JS_FILE}}",
"image": "{IMAGE}",
"installed": false,
"environment": {
"INSTALL_REPO": "",
"INSTALL_BRANCH": "",
"USER_UPLOAD": "0",
"AUTO_UPDATE": "0",
"BOT_JS_FILE": "index.js",
"STARTUP": "if [[ -d .git ]] && [[ {{AUTO_UPDATE}} == \"1\" ]]; then git pull; fi && /usr/local/bin/npm install --production && /usr/local/bin/node /home/container/{{BOT_JS_FILE}}",
"P_SERVER_LOCATION": "US",
"P_SERVER_UUID": "243b320e-c925-4260-a3bd-d820efc0f8d8",
"P_SERVER_ALLOCATION_LIMIT": 0
}
},
"updated_at": "2020-10-26T11:06:22+00:00",
"created_at": "2020-10-26T11:06:22+00:00"
},
"info": {
"total_amount": 1,
"startedAt": 1603710365485,
"endedAt": 1603710383204
}
}


Delete a user

Code:

constapi=require('nodeactyl.js').Application;api.login("PanelURL","APIKey");api.deleteUser(USERID).then(response=>console.log(response));

Expected response:

Click me!
{
"success": true,
"info": { "startedAt": 1603714948104, "endedAt": 1603714949005 }
}

Update a user

Code:

constapi=require('nodeactyl.js').Application;api.login("PanelURL","APIKey");api.updateUser(58,"example","PASSWORD","example@example.com","Example","User",false,'en').then(response=>console.log(response));

Arguments:

Click me!

List of arguments: (use in order)

ArgumenttypeDescriptionRequired?
UserIDNumberUsers ID.Yes
UsernameStringUsers new username. (nullable)Yes
PasswordStringUsers new password. (nullable)Yes
EmailStringUsers new email. (nullable)Yes
FirstNameStringUsers new first name. (nullable)Yes
LastNameStringUsers new last name. (nullable)Yes
IsAdminBooleanIs the user admin? (true/false) (nullable)Yes
LanguageStringLanguage, Normally: [en/fr] (nullable)Yes

Expected response:

Click me!
{
"success": true,
"data": {
"id": 58,
"external_id": null,
"uuid": "8a8fd2a0-57e3-49f6-82ef-07c02c426be9",
"username": "example",
"email": "example@example.com",
"first_name": "Example",
"last_name": "User",
"language": "en",
"root_admin": false,
"2fa": false,
"created_at": "2020-04-22T09:47:03+00:00",
"updated_at": "2020-10-28T06:01:16+00:00"
},
"info": {
"total_amount": 1,
"startedAt": 1603864871881,
"endedAt": 1603864877319
}
}


About

Pterodactyl API wapper for javascript.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages