{"id":26895825,"url":"https://github.com/twobrake/ptero-ws","last_synced_at":"2026-02-07T18:35:23.818Z","repository":{"id":262084100,"uuid":"866273463","full_name":"TwoBrake/ptero-ws","owner":"TwoBrake","description":"A simple wrapper for handling websocket connections to a Pterodactyl Panel instance.","archived":false,"fork":false,"pushed_at":"2024-10-14T23:56:54.000Z","size":46,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-21T16:52:33.121Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://lucastranks.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TwoBrake.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-02T00:23:41.000Z","updated_at":"2024-10-14T23:56:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"b99a20d6-2b55-400d-97c7-381f64832d31","html_url":"https://github.com/TwoBrake/ptero-ws","commit_stats":null,"previous_names":["twobrake/ptero-ws"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/TwoBrake/ptero-ws","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwoBrake%2Fptero-ws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwoBrake%2Fptero-ws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwoBrake%2Fptero-ws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwoBrake%2Fptero-ws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TwoBrake","download_url":"https://codeload.github.com/TwoBrake/ptero-ws/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwoBrake%2Fptero-ws/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266541568,"owners_count":23945447,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-01T02:58:48.597Z","updated_at":"2026-02-07T18:35:21.882Z","avatar_url":"https://github.com/TwoBrake.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ptero WS\n\nPtero WS is a Node.js wrapper for handling websocket connections to a Pterodactyl Panel instance.\n\n## Features\n\n- **✨ Easy to use**: Ptero WS is designed to be easy to use and understand.\n- **🛠️ Typescript support**: Ptero WS is written in Typescript, so you can use it in your Typescript projects.\n- **📜 Fully typed**: Ptero WS is fully typed, so you can use it in your Typescript projects without any issues.\n- **🔔 Event-based**: Ptero WS is event-based, so you can listen to events and handle them accordingly.\n- **⚙️ Customizable**: Ptero WS is customizable, so you can change the default settings to your liking.\n- **💡 Lightweight**: Ptero WS is lightweight, so it won't slow down your application.\n\n## Installation\n\n1. Install the package using NPM:\n   ```bash\n   npm install ptero-ws\n   ```\n2. Import the package in your project using **ES6**:\n   ```typescript\n   import { pterows } from \"ptero-ws\";\n   ```\n   Or use **CommonJS**:\n   ```typescript\n   const { pterows } = require(\"ptero-ws\");\n   ```\n\n## Usage\n\n1. Create a new instance of **Ptero WS**:\n\n   ```typescript\n   const socket = new pterows(\n     \"https://panel.yourdomain.com\",\n     \"CLIENT_KEY\",\n     \"SERVER_ID\"\n   );\n   ```\n\n   Note that we append the following parameters to the class.\n\n   - **https://panel.yourdomain.com**: Your Pterodactyl Panel instance base URL.\n   - **CLIENT_KEY**: Your Pterodactyl Panel user's client key.\n   - **SERVER_ID**: Your Pterodactyl Panel unique identifier for the server you want to connect to.\n\n   You can also provide an option object to customize the options:\n\n   ```typescript\n   {\n    debug: false, // Whether or not messages should be displayed in the console when the socket is connected and closed.\n    browser: false, // Whether or not the socket should be treated as a browser socket.\n   }\n   ```\n\n2. Create your first event listener using **Ptero WS**:\n   ```typescript\n   socket.on(\"open\", () =\u003e {\n     socket.listen(\"stats\", (data) =\u003e {\n       console.log(JSON.parse(data));\n     });\n   });\n   ```\n   Note that we wrap the inner listener with `socket.on(\"open\")`. This is done to ensure that the socket has fully connected before creating an event listener.\n3. Once you have finished using **Ptero WS**, make sure to close the websocket connection to free system resources.\n   ```typescript\n   socket.close();\n   ```\n\n## Listeners\n\n| Name                     | Arguments            | Description                                                |\n| ------------------------ | -------------------- | ---------------------------------------------------------- |\n| auth success             |                      | The authentication was successful.                         |\n| backup complete          |                      | Sent when a backup is complete.                            |\n| backup restore completed |                      | Sent when a backup has been restored to the server.        |\n| console output           | the output message   | The output from the console (one line).                    |\n| daemon error             | the error message    | The daemon received an error (usually with the websocket). |\n| daemon message           | the message          | A message from the daemon.                                 |\n| install completed        |                      | Sent when a server's installation process is complete.     |\n| install output           | the output message   | The output from the installation process.                  |\n| install started          |                      | Sent when a server's installation process starts.          |\n| jwt error                | the error message    | An error occurred with the authentication token.           |\n| stats                    | statistics JSON data | Current statistics about the server.                       |\n| status                   | the power state      | The power state of the server.                             |\n| token expired            |                      | The token expired; connection will be closed shortly.      |\n| token expiring           |                      | Warning event: you should reauthenticate the connection.   |\n| transfer logs            | the output log       | The logs from the transfer process.                        |\n| transfer status          | the transfer state   | The current transfer status.                               |\n\n## Sendable Events\n\n| Name         | Arguments                             | Description                               |\n| ------------ | ------------------------------------- | ----------------------------------------- |\n| auth         | the websocket auth token              | Authenticates the websocket connection.   |\n| set state    | \"start\", \"stop\", \"restart\", or \"kill\" | Sets the power state of the server.       |\n| send command | the command                           | Sends a command to the server console.    |\n| send logs    |                                       | Requests the console logs for the server. |\n| send stats   |                                       | Requests the server statistics.           |\n\n## Questions\n\n\u003e [!IMPORTANT]\n\u003e Please make sure to check the examples before-hand.\n\nIf you have any other questions or need help, feel free to open an issue on the GitHub repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwobrake%2Fptero-ws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwobrake%2Fptero-ws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwobrake%2Fptero-ws/lists"}