
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@camposcloud/sdk
Advanced tools
A TypeScript/JavaScript SDK for interacting with the CamposCloud API. This SDK provides a simple and intuitive way to manage applications, upload files, and perform various operations on the CamposCloud platform.
You can see the full API documentation at API Docs.
npm install @camposcloud/sdk
First, you need to obtain an API token from your CamposCloud dashboard. Then initialize the SDK:
import CamposCloudSDK from '@camposcloud/sdk';
const api = new CamposCloudSDK({
apiToken: "your-api-token-here"
});
const main = async () => {
try {
const me = await api.getMe();
console.log(`Hello ${me.name} đź‘‹`);
} catch (error) {
console.error('Error fetching user data:', error);
}
}
main();
getMe()Get information about the authenticated user.
const userInfo = await api.getMe();
Returns: UserData object containing user information.
getApplication({ appId })Get details of a specific application.
const app = await api.getApplication({ appId: "your-app-id" });
Parameters:
appId (string): The ID of the applicationReturns: Application instance
getApplications()Get all applications for the authenticated user.
const result = await api.getApplications();
console.log(result.applications);
console.log(`Total RAM used: ${result.totalUsedRAM}`);
Returns: Object containing:
applications: Array of ApplicationResponseDatatotalUsedRAM: String indicating total RAM usagepagination: Pagination informationcreateApplication(data)Create a new application.
import fs from 'fs';
const file = await fs.promises.readFile('path/to/your/app.zip');
const app = await api.createApplication({
appName: "My App",
file: file,
mainFile: "index.js",
memoryMB: 512,
runtimeEnvironment: "nodejs",
});
Parameters:
appName (string): Name of the applicationfile (Buffer): ZIP file containing your applicationmainFile (string): Entry point file (e.g., "index.js", "main.py")memoryMB (number): Memory allocation in MBruntimeEnvironment ("nodejs" | "python"): Runtime environmentexposedViaWeb (boolean, optional): Whether to expose via webautoRestartEnabled (boolean, optional): Enable auto-restartstartupCommand (string, optional): Custom startup commandteamId (string, optional): Team ID if creating for a teamReturns: Application instance
deleteApplication({ appId })Delete an application.
await api.deleteApplication({ appId: "your-app-id" });
startApplication({ appId })Start an application.
const result = await api.startApplication({ appId: "your-app-id" });
stopApplication({ appId })Stop an application.
const result = await api.stopApplication({ appId: "your-app-id" });
restartApplication({ appId })Restart an application.
const result = await api.restartApplication({ appId: "your-app-id" });
uploadFile({ appId, file, path })Upload a file to an application.
import fs from 'fs';
const file = await fs.promises.readFile('path/to/file.txt');
const result = await api.uploadFile({
appId: "your-app-id",
file: file,
path: "/optional/path"
});
Parameters:
appId (string): The application IDfile (Buffer): File content as Bufferpath (string, optional): Target path in the applicationWhen you get or create an application, you receive an Application instance with convenient methods:
const app = await api.getApplication({ appId: "your-app-id" });
// Application data
console.log(app.data);
// Control methods
await app.start();
await app.stop();
await app.restart();
await app.delete();
// Upload file directly to this application
import fs from 'fs';
const file = await fs.promises.readFile('path/to/file.txt');
await app.uploadFile(file, '/optional/path');
start(): Start the applicationstop(): Stop the applicationrestart(): Restart the applicationdelete(): Delete the applicationuploadFile(file: Buffer, path?: string): Upload a file to the applicationimport CamposCloudSDK from '@camposcloud/sdk';
import fs from 'fs';
const api = new CamposCloudSDK({
apiToken: "your-api-token-here"
});
const main = async () => {
try {
// Get user info
const me = await api.getMe();
console.log(`Hello ${me.name}!`);
// Create an application
const file = await fs.promises.readFile('my-app.zip');
const app = await api.createApplication({
appName: "My Node.js App",
file: file,
mainFile: "index.js",
memoryMB: 256,
runtimeEnvironment: "nodejs",
});
console.log(`Application created with ID: ${app.data._id}`);
// Start the application
await app.start();
console.log('Application started!');
// Upload additional file
const configFile = await fs.promises.readFile('config.json');
await app.uploadFile(configFile, '/config');
console.log('Config file uploaded!');
// Get all applications
const apps = await api.getApplications();
console.log(`You have ${apps.applications.length} applications`);
} catch (error) {
console.error('Error:', error);
}
}
main();
The SDK throws errors for various conditions. Always wrap your API calls in try-catch blocks:
try {
const app = await api.getApplication({ appId: "invalid-id" });
} catch (error: any) {
if (error.response?.status === 404) {
console.log('Application not found');
} else {
console.error('API Error:', error.message);
}
}
This SDK is written in TypeScript and provides full type definitions. You'll get autocomplete and type checking out of the box:
import { ApplicationResponseData, UserData } from '@camposcloud/sdk';
// Types are automatically inferred
const user: UserData = await api.getMe();
const apps: ApplicationResponseData[] = (await api.getApplications()).applications;
To contribute to this SDK:
# Clone the repository
git clone https://github.com/camposcloud/camposcloud-sdk
# Install dependencies
npm install
# Run tests
npm run test
# Build the project
npm run build
This project is licensed under the ISC License.
FAQs
camposcloud-sdk is a TypeScript SDK for interacting with the CamposCloud API, providing methods to manage applications, users, and more.
We found that @camposcloud/sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.