Skip to content

Releases: INotSleep/pqry

v1.2.2

19 Nov 19:50
Compare
Choose a tag to compare

Implementation of ServerWebSocket

v1.0.1

02 Apr 11:46
85fc388
Compare
Choose a tag to compare

pqry v1.0.1

Easier query to pterodactyl v1 panel.

Installing

npm install pqry

Usage

  1. Get apikey from your panel
  2. Import PQRY:
import { PQRY } from "pqry";
  1. Specify your host (link to panel) and api:
const pqry = new PQRY({
  host: "https://link.to.panel.com",
  apikey: "your api key"
});
  1. Use it :)

Functions

  • < > - required
  • [ ] - optional
  • await before all functions is required!

GetServers()

import { GetServers } from "pqry";

console.log(await GetServers(<host>, <apikey>))

Return list of your servers:

[
{
  server_owner: true,
  identifier: '1a2b3c4d',
  internal_id: 59181,
  uuid: '1a2b3c4d-aab9-48b9-be2f-203eefc1eef0',
  name: 'My Server',
  cpu2: null,
  node: 'MyNode1',
  nest_id: 1,
  sftp_details: { ip: 'my.sftp.link.com', port: 22 },
  description: '',
  limits: {
    memory: 4096,
    swap: 0,
    disk: 40960,
    io: 500,
    cpu: 200,
    threads: null,
    oom_disabled: false
  },
  invocation: 'java -Xmx4096M server.jar nogui',
  docker_image: 'INotSleep:java17',
  egg_features: [ 'eula' ],
  feature_limits: { databases: 0, allocations: 5, backups: 3 },
  status: null,
  is_suspended: false,
  is_installing: false,
  is_transferring: false,
  allocations: [
    {
      id: 36714,
      ip: '12.34.56.78',
      ip_alias: 'my.alias.com',
      port: 25876,
      notes: null,
      is_default: true
    }
  ],
  host: 'https://link.to.panel.com',
  apikey: 'your api key'
}
]

You can also make it like this:

pqry.getServers()

GetApiKeys()

import { GetApiKeys } from "pqry";

console.log(await GetApiKeys(<host>, <apikey>))

Return your api keys:

[
{
  identifier: 'FLWvge36u5Puc9NQ', // this is short name.
  description: '12314234124',
  allowed_ips: [],
  last_used_at: '2022-03-12T00:36:38+03:00',
  created_at: '2022-03-11T19:40:49+03:00',
  host: 'https://link.to.panel.com',
  apikey: 'your api key, not this api key.',
}
]

You can also make it like this:

pqry.getApiKeys()

CreateApiKey()

import { CreateApiKey } from "pqry";

console.log(await CreateApiKey(<host>, <apikey>, <description>, [allowed_ips]))

Return your created api key:

{
  identifier: 'FLWvge36u5Puc9NQ', // this is short name.
  description: '12314234124',
  allowed_ips: [],
  last_used_at: null,
  created_at: '2022-03-11T19:40:49+03:00',
  host: 'https://link.to.panel.com',
  apikey: 'your api key, not this api key.',
}

You can also make it like this:

pqry.createApiKey(<description>, [allowed_ips])

DeleteApiKey()

import { DeleteApiKey } from "pqry";

console.log(await DeleteApiKey(<host>, <apikey>, <identifier>))

Return:

undefined

You can also make it like this:

pqry.deleteApiKey(<description>, [allowed_ips])

or this:

var apikeys = await pqry.getApiKeys()
apikeys[0].delete()

GetServer()

import { GetServer } from "pqry";

console.log(await GetServer(<host>, <apikey>, <identifier>))

Return your server:

{
  server_owner: true,
  identifier: '1a2b3c4d',
  internal_id: 59181,
  uuid: '1a2b3c4d-aab9-48b9-be2f-203eefc1eef0',
  name: 'My Server',
  cpu2: null,
  node: 'MyNode1',
  nest_id: 1,
  sftp_details: { ip: 'my.sftp.link.com', port: 22 },
  description: '',
  limits: {
    memory: 4096,
    swap: 0,
    disk: 40960,
    io: 500,
    cpu: 200,
    threads: null,
    oom_disabled: false
  },
  invocation: 'java -Xmx4096M server.jar nogui',
  docker_image: 'INotSleep:java17',
  egg_features: [ 'eula' ],
  feature_limits: { databases: 0, allocations: 5, backups: 3 },
  status: null,
  is_suspended: false,
  is_installing: false,
  is_transferring: false,
  allocations: [
    {
      id: 36714,
      ip: '12.34.56.78',
      ip_alias: 'my.alias.com',
      port: 25876,
      notes: null,
      is_default: true
    }
  ],
  host: 'https://link.to.panel.com',
  apikey: 'your api key'
}

You can also make it like this:

pqry.getServer(<identifier>)

Signal()

import { Signal } from "pqry";

console.log(await Signal(<host>, <apikey>, <identifier>, <signal>))

Return:

undefined

Avlaible signals:

  • start
  • restart
  • stop
  • kill
    You can also make it like this:
await pqry.signal(<identifier>, <signal>)

or this:

var server = await pqry.getServer("1a2b3c4d")

server.power.start()
server.power.restart()
server.power.stop()
server.power.kill()

SendCommand()

import { SendCommand } from "pqry";

console.log(SendCommand(<host>, <apikey>, <identifier>, <command>))

Return:

undefined

You can also make it like this:

await pqry.sendCommand(<identifier>, <command>)

or this:

var server = await pqry.getServer("1a2b3c4d")

server.sendCommand(<command>)

UsageInfo()

import { UsageInfo } from "pqry";

console.log(await UsageInfo(<host>, <apikey>, <identifier>))

Return usage info of your server:

{
  current_state: 'running',
  is_suspended: false,
  resources: {
    memory_bytes: 1180884992,
    cpu_absolute: 20.679,
    disk_bytes: 449824735,
    network_rx_bytes: 453400,
    network_tx_bytes: 184979,
    uptime: 53932619
  }
}

You can also make it like this:

pqry.usageInfo(<identifier>)

or this:

var server = await pqry.getServer("1a2b3c4d")

server.usage()

Example

import { PQRY } from "pqry";

const pqry = new PQRY({
  host: "https://link.to.panel.com",
  apikey: "your api key"
});

(async() => {
  var server = await pqry.getServer("1a2b3c4d");
  server.sendCommand("say §cRestart in 1 second!")
  setTimeout(() => {
    server.power.stop()
  }, 1000)
})();