bunactyl
v1.0.1
Published
TypeScript SDK for Pterodactyl
Maintainers
Readme
Pterodactyl TypeScript SDK
A comprehensive TypeScript SDK for the Pterodactyl Panel API. This SDK provides a simple and intuitive interface to interact with the Pterodactyl API, making it easier to manage your Pterodactyl instance programmatically.
Documentation can be found at https://bunactyl.irazz.lol
Features
- Complete TypeScript definitions for the Pterodactyl API
- Promise-based API with async/await support
- Full coverage of the Pterodactyl Application API endpoints
- Built with Bun's fetch API
- Comprehensive documentation and examples
Installation
# Using npm
npm install bunactyl
# Using Bun
bun add bunactylUsage
Initializing the Client
import { Bunactyl } from 'bunactyl';
// Initialize the client
const ptero = new Bunactyl({
url: 'https://your-pterodactyl-panel.com',
apiKey: 'your-api-key-here'
});Examples
Working with Users
// List all users
const users = await ptero.users.list();
console.log(users);
// Get a specific user
const user = await ptero.users.getById(1);
console.log(user);
// Create a new user
const newUser = await ptero.users.create({
email: '[email protected]',
username: 'newuser',
first_name: 'New',
last_name: 'User'
});
console.log(newUser);
// Update a user
const updatedUser = await ptero.users.update(1, {
first_name: 'Updated',
last_name: 'Name'
});
console.log(updatedUser);
// Delete a user
await ptero.users.delete(1);Working with Nodes
// List all nodes
const nodes = await ptero.nodes.list();
console.log(nodes);
// Get a specific node
const node = await ptero.nodes.getById(1);
console.log(node);
// Get node configuration
const config = await ptero.nodes.getConfiguration(1);
console.log(config);
// Create a new node
const newNode = await ptero.nodes.create({
name: 'New Node',
location_id: 1,
fqdn: 'node.example.com',
scheme: 'https',
memory: 8192,
disk: 50000,
upload_size: 100,
daemon_sftp: 2022,
daemon_listen: 8080
});
console.log(newNode);Working with Servers
// List all servers
const servers = await ptero.servers.list();
console.log(servers);
// Get a specific server
const server = await ptero.servers.getById(1);
console.log(server);
// Create a new server
const newServer = await ptero.servers.create({
name: 'Test Server',
user: 1,
egg: 1,
docker_image: 'ghcr.io/mcjars/pterodactyl-yolks:java_23',
startup: 'java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}',
environment: {
SERVER_JARFILE: 'server.jar',
VANILLA_VERSION: 'latest',
},
limits: {
memory: 1024,
swap: 0,
disk: 5000,
io: 500,
cpu: 0
},
feature_limits: {
databases: 5,
allocations: 5,
backups: 2
},
allocation: {
default: 1,
additional: []
}
});
console.log(newServer);Working with Allocations
// List all allocations for a node
const allocations = await ptero.allocations(1).list();
console.log(allocations);
// Create new allocations
await ptero.allocations(1).create({
ip: '10.0.0.1',
ports: ['25565', '25566', '25567']
});
// Delete an allocation
await ptero.allocations(1).delete(5);Working with Locations
// List all locations
const locations = await ptero.locations.list();
console.log(locations);
// Create a new location
const newLocation = await ptero.locations.create({
short: 'US',
long: 'United States'
});
console.log(newLocation);API Reference
This SDK provides acess to the following Pterodactyl API endpoints:
Users
users.list(include?, filter?, sort?)- List all usersusers.getById(id, include?)- Get a specific userusers.getByExternalId(externalId, include?)- Get a user by external IDusers.create(userData)- Create a new userusers.update(id, userData)- Update a userusers.delete(id)- Delete a user
Nodes
nodes.list(include?)- List all nodesnodes.getById(id, include?)- Get a specific nodenodes.getConfiguration(id)- Get node configurationnodes.create(nodeData)- Create a new nodenodes.update(id, nodeData)- Update a nodenodes.delete(id)- Delete a node
Servers
servers.list(include?)- List all serversservers.getById(id, include?)- Get a specific serverservers.getByExternalId(externalId, include?)- Get a server by external IDservers.create(serverData)- Create a new serverservers.updateDetails(id, details)- Update server detailsservers.updateBuild(id, buildConfig)- Update server build configurationservers.updateStartup(id, startupConfig)- Update server startup configurationservers.delete(id)- Delete a server
Allocations
allocations(nodeId).list(include?)- List allocations for a nodeallocations(nodeId).create(allocationData)- Create allocations for a nodeallocations(nodeId).delete(allocationId)- Delete an allocation
Locations
locations.list(include?)- List all locationslocations.getById(id, include?)- Get a specific locationlocations.create(locationData)- Create a new locationlocations.update(id, locationData)- Update a locationlocations.delete(id)- Delete a location
License
AGPL-3.0 License
