@voctal/pelican
v0.6.0
Published
An unofficial TypeScript Pelican API wrapper
Downloads
807
Maintainers
Readme
About
@voctal/pelican allows you to easily use the Pelican Panel API. See the module documentation.
You can find the Pelican API docs on your own panel at https://<domain>/docs/api, or on the demo: https://demo.pelican.dev/docs/api.
[!NOTE] This module is still under development and does not include every features. Not everything was fully tested. However you can use the
restproperty ofPelicanApplicationandPelicanClientto access the API routes that this module does not support.
Features
- Client API
- Application API
- WebSocket API
- All responses are validated using Zod
- (almost) Fully typed and documented
Installation
Node.js 22 or newer is required.
npm install @voctal/pelicanExample usage
Use PelicanApplication to interact with the Application API:
import { PelicanApplication } from "@voctal/pelican";
const application = new PelicanApplication({
token: "...",
url: "https://example.com",
});
const servers = await application.servers.list();
const users = await application.users.list();
// See all methods on the documentationUse PelicanClient to interact with the Client API:
import { PelicanClient } from "@voctal/pelican";
const client = new PelicanClient({
token: "...",
url: "https://example.com",
});
const account = await client.account.get();
const servers = await client.servers.list();
const files = await client.files.list(serverId);
// See all methods on the documentationUse PelicanWebSocket to interact with the WebSocket API:
import { PelicanClient, PelicanWebSocket, WebSocketEvents } from "@voctal/pelican";
const client = new PelicanClient({
token: "...",
url: "https://example.com",
});
// Get a server identifier
const servers = await client.servers.list();
const firstServerId = servers.data[0]?.attributes.identifier;
if (!firstServerId) return console.log("No servers!");
// Create the WebSocket
const ws = new PelicanWebSocket(client, firstServerId);
ws.on(WebSocketEvents.ConsoleOutput, log => {
console.log("New server log: ", log);
});
ws.on(WebSocketEvents.Stats, stats => {
console.log("New stats: ", stats);
});
await ws.connect();If you are using the REST class, you might need the Zod schemas to validate the responses. They are all available from @voctal/pelican/schemas:
import { userSchema } from "@voctal/pelican/schemas";
userSchema.parse(data);Links
Help
Need help with the module? Ask on our support server!
