Cloudways JS Client is a TypeScript-based client library that allows you to power your applications with the Cloudways API. It provides a convenient and strongly-typed way to interact with the Cloudways API, enabling you to manage servers, perform automation, and integrate Cloudways functionality into your web applications.
Please note that this library is still under development. Although it's functional and can be used, some features might be incomplete or subject to changes.
- Easy-to-use client library for the Cloudways API.
- Simplifies server management and web app integration.
- Built with TypeScript for improved type safety and development experience.
- Comprehensive documentation and code examples, including JSDoc comments.
You can install the package via npm:
npm install cloudways-js-client
The Cloudways JS Client library makes it easy to interact with the Cloudways API for various operations. Below are some examples to help you get started.
Before performing any operations, initialize the API with your Cloudways account credentials:
import { initializeCloudwaysApi } from 'cloudways-js-client';
const email = 'your_email@example.com'; // Replace with your Cloudways account email
const apiKey = 'your_api_key'; // Replace with your Cloudways API key
initializeCloudwaysApi(email, apiKey);
To delete a server, use the deleteServer
function. Ensure you have the correct server ID:
import { deleteServer } from "cloudways-js-client";
async function deleteServerA() {
const serverId = 12345; // Replace with the server ID you want to delete
await deleteServer(serverId);
console.log("Server deleted successfully.");
}
You can retrieve the list of servers associated with your account using the getServersList
function:
import { getServersList } from "cloudways-js-client";
async function listServers() {
try {
const servers = await getServersList();
console.log("Servers List:", servers);
} catch (error) {
console.error("Error fetching servers list:", error);
}
}
listServers();
You can combine these functions to perform multiple operations. For example, to delete a server and then get the updated list of servers:
async function deleteServerAndGetList() {
const serverId = 12345; // Replace with the server ID to delete
await deleteServer(serverId);
console.log("Server deleted successfully.");
console.log("Updated Servers List:", await getServersList());
}
deleteServerAndGetList();
If you find any issues or have any feature requests, please open an issue on GitHub.
This project is open source and available under the MIT License.