npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

pterodactyl.ts

v1.2.4

Published

Easily manage your panel and servers on a Pterodactyl panel

Readme

Known Vulnerabilities Build Status Publish Package to npm and github

Pterodactyl.ts

This is a easy to use typescript based api wrapper for the pterodactyl api.

Quick start

ApplicationClient

With the ApplicationClient you can manage servers, nodes, users, and more.
This requires an panel api key with the specific permissions.

import { ApplicationClient } from 'pterodactyl.ts';
const applicationClient = new ApplicationClient({
  apikey: process.env.PTERODACTYL_API_KEY,
  panel: process.env.PTERODACTYL_PANEL,
});

Create a new user

const newUser = new UserBuilder()
  .setEmail('[email protected]')
  .setFirstName('Max')
  .setLastName('Mustermann')
  .setUsername('exampleGamer420')
  .setPassword(process.env.MAX_PASSWORD);

await applicationClient.createUser(newUser);

Create a new server

const newServer = new ServerBuilder()
  .setName('Hello world!')
  .setDescription('This is my fancy game server')
  .setOwnerId(1) // The user id for the owner
  .setAllocationId(1) // The allocation id for the server
  .setLimits({
    memory: 512,
    swap: 0,
    disk: 5120,
    io: 500,
    cpu: 100,
    threads: undefined,
  })
  .setFeatureLimits({
    databases: 1,
    backups: 5,
    allocations: 2,
  });
// TODO Env setup (variables, egg, etc.)

await applicationClient.createServer(newServer).then((server) => {
  console.log('The server is currently ' + server.status);
});

Create new allocations

const newAllocation = new AllocationBuilder()
  .setIp('1.2.3.4')
  .setAlias('example.com')
  .addPort(25565)
  .addPort('3000-3005')
  .addPorts([25566, 25567]);

await applicationClient.getNode(0).then((node) => {
  node.createAllocation(newAllocation);
});

Documentation

UserClient

With the ApplicationClient you can manage servers, subusers, backups, files and more.
This is from user perspective and you’ll need an api key from your user settings.

[!WARNING]
Your hosting provider may have limits on your requests, please make sure you don’t spam a panel!
Abusing your hosting providers panel may result in suspension or ip bans!

import { UserClient } from 'pterodactyl.ts';
const userClient = new UserClient({
  apikey: process.env.PTERODACTYL_API_KEY,
  panel: process.env.PTERODACTYL_PANEL,
});

Establish a server console connection

// Get a specific server from your account
import { SocketEvent } from 'pterodactyl.ts';
const server = await userClient.getServer('someId');

/**
 * Console connection
 */
// The authentication is done automatically
const socket = await server.getConsoleSocket();
await socket.connect(true);

// Get the logs, when the server is offline you'll receive a generated log message
const logs = await socket.getLogs();

// Get live console logging
socket.on(SocketEvent.CONSOLE_OUTPUT, (log) => {
  console.log(log);
});

socket.disconnect();

Upload, read, download, compress a file on a server

import fs from 'fs';

const server = await userClient.getServer('someId');

// Accepts a filepath, buffer or blob
await server.uploadFile('/', 'hello.world', 'hello.world');

server.getFiles('/').then((files) => {
  console.log('Files in "/"": ' + files.map((file) => file.name).join(', '));

  const helloWorldFile = files.find((file) => file.name === 'hello.world');
  if (!helloWorldFile) {
    console.error('File not found');
    return;
  }

  helloWorldFile.getContent().then((contents) => {
    console.log('Contents of hello.world: ' + contents);
  });

  helloWorldFile.downloadUrl().then((url) => {
    console.log('You can download hello.world via: ' + url);
  });

  helloWorldFile.compress().then(async (archive) => {
    console.log('Compressed hello.world');
    await archive.downloadStream().then((stream) => {
      stream.pipe(fs.createWriteStream('hello.world.tar.gz'));
    });
    archive.delete();
  });
});

Create a server backup

const newBackup = new BackupBuilder()
  .setName('Backup of server')
  .setLocked(true)
  .setIgnored(['logs', 'cache']);

server.createBackup(newBackup);

Manage server subusers

import { USER_PERMISSION } from 'pterodactyl.ts';

const newSubUser = new SubUserBuilder()
  .setEmail('[email protected]')
  .setPermissions([USER_PERMISSION.ACTIVITY_READ, USER_PERMISSION.CONTROL_RESTART])
  .addPermission(USER_PERMISSION.CONTROL_CONSOLE);

await server.createSubuser(newSubUser).then(async (subUser) => {
  await subUser.updatePermissions([USER_PERMISSION.CONTROL_START, USER_PERMISSION.CONTROL_STOP]);
  console.log('The user has ' + subUser.permissions.length + ' permissions');
  await subUser.delete();
});

Create a server schedule with tasks

const newTask = new ScheduleTaskBuilder()
  .setAction('backup')
  .setContinueOnFailure(true)
  .setPayload('cache, logs'); // For backups the payload are the ignored files

const newTask2 = new ScheduleTaskBuilder()
  .setAction('command')
  .setPayload('say Backup completed!'); // For commands the payload contains the command

const newTask3 = new ScheduleTaskBuilder()
  .setAction('power')
  .setPayload(SERVER_SIGNAL.RESTART); // For power actions the payload contains the server signal

const newSchedule = new ScheduleBuilder()
  .setActive(true)
  .setName('Daily Backup')
  .setMinute('0')
  .setHour('0')
  .setMonth('*')
  .setDayOfMonth('*')
  .setDayOfWeek('*')
  .setOnlyWhenOnline(false);

server.createSchedule(newSchedule).then(async (schedule) => {
  await schedule.createTask(newTask);
  await schedule.createTask(newTask2);
  await schedule.createTask(newTask3);
});

Documentation

Disclaimer

Use is at own risk!
You can easily delete everything - be cautious!