rocket-net-api
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRocket.net API Integration
Rocket.net API集成
Build integrations with Rocket.net's managed WordPress hosting platform API. This skill covers authentication, site management, domain configuration, backups, plugins/themes, CDN cache control, and all 200+ API endpoints.
与Rocket.net的托管WordPress平台API进行集成开发。本技能涵盖身份验证、站点管理、域名配置、备份、插件/主题管理、CDN缓存控制以及全部200+个API端点。
API Overview
API概述
Base URL:
https://api.rocket.net/v1Authentication: JWT token-based
- Obtain token via POST with email/password
/login - Token expires in 7 days
- Include in requests as
Authorization: Bearer <token>
Content Type: JSON API
- Required header:
Content-Type: application/json - Recommended header:
Accept: application/json
Documentation: https://rocketdotnet.readme.io/reference/introduction
基础URL:
https://api.rocket.net/v1身份验证:基于JWT令牌
- 通过POST 接口,使用邮箱/密码获取令牌
/login - 令牌有效期为7天
- 请求中需携带
Authorization: Bearer <token>
内容类型:JSON API
- 必填请求头:
Content-Type: application/json - 推荐请求头:
Accept: application/json
Authentication
身份验证
Get JWT Token
获取JWT令牌
typescript
const response = await fetch('https://api.rocket.net/v1/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
username: 'your-email@example.com',
password: 'your-password'
})
});
const { token } = await response.json();
// Use token in subsequent requeststypescript
const response = await fetch('https://api.rocket.net/v1/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
username: 'your-email@example.com',
password: 'your-password'
})
});
const { token } = await response.json();
// Use token in subsequent requestsAuthenticated Request Pattern
已认证请求模板
typescript
async function rocketApiRequest(
endpoint: string,
options: RequestInit = {}
): Promise<any> {
const response = await fetch(`https://api.rocket.net/v1${endpoint}`, {
...options,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${token}`,
...options.headers
}
});
if (response.status === 401) {
// Token expired, re-authenticate
throw new Error('Token expired - request new token');
}
return response.json();
}typescript
async function rocketApiRequest(
endpoint: string,
options: RequestInit = {}
): Promise<any> {
const response = await fetch(`https://api.rocket.net/v1${endpoint}`, {
...options,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${token}`,
...options.headers
}
});
if (response.status === 401) {
// Token expired, re-authenticate
throw new Error('Token expired - request new token');
}
return response.json();
}API Endpoints by Category
按分类划分的API端点
Sites Management
站点管理
| Method | Endpoint | Description |
|---|---|---|
| GET | | List all sites |
| POST | | Create new site |
| GET | | Get site details |
| PATCH | | Update site properties |
| DELETE | | Delete site |
| POST | | Clone a site (background task) |
| GET | | Get site credentials |
| GET | | Get site usage statistics |
| POST | | Lock site (prevent modifications) |
| DELETE | | Unlock site |
| GET | | Get phpMyAdmin SSO link |
| GET | | Get site settings |
| PATCH | | Update site settings |
| GET | | List available site locations |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| GET | | 列出所有站点 |
| POST | | 创建新站点 |
| GET | | 获取站点详情 |
| PATCH | | 更新站点属性 |
| DELETE | | 删除站点 |
| POST | | 克隆站点(后台任务) |
| GET | | 获取站点凭证 |
| GET | | 获取站点使用统计 |
| POST | | 锁定站点(阻止修改) |
| DELETE | | 解锁站点 |
| GET | | 获取phpMyAdmin单点登录链接 |
| GET | | 获取站点设置 |
| PATCH | | 更新站点设置 |
| GET | | 列出可用站点部署位置 |
Staging Sites
staging站点(预发布站点)
| Method | Endpoint | Description |
|---|---|---|
| POST | | Create staging site |
| DELETE | | Delete staging site |
| POST | | Publish staging to production |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| POST | | 创建预发布站点 |
| DELETE | | 删除预发布站点 |
| POST | | 将预发布站点发布至生产环境 |
Site Templates
站点模板
| Method | Endpoint | Description |
|---|---|---|
| GET | | List site templates |
| POST | | Create site template |
| GET | | Get template details |
| DELETE | | Delete template |
| POST | | Create site from template |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| GET | | 列出站点模板 |
| POST | | 创建站点模板 |
| GET | | 获取模板详情 |
| DELETE | | 删除模板 |
| POST | | 通过模板创建站点 |
Domains
域名
| Method | Endpoint | Description |
|---|---|---|
| GET | | List domain aliases |
| POST | | Add domain alias |
| DELETE | | Remove domain alias |
| GET | | Get main domain info |
| POST | | Set main domain |
| PUT | | Replace main domain |
| PATCH | | Update domain validation/SSL |
| GET | | Check domain status |
| GET | | Force validation recheck |
| GET | | Get edge settings |
| PATCH | | Update edge settings |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| GET | | 列出域名别名 |
| POST | | 添加域名别名 |
| DELETE | | 移除域名别名 |
| GET | | 获取主域名信息 |
| POST | | 设置主域名 |
| PUT | | 替换主域名 |
| PATCH | | 更新域名验证/SSL配置 |
| GET | | 检查域名状态 |
| GET | | 强制重新验证域名 |
| GET | | 获取边缘节点设置 |
| PATCH | | 更新边缘节点设置 |
CDN Cache
CDN缓存
| Method | Endpoint | Description |
|---|---|---|
| POST | | Purge specific files |
| POST | | Purge all cache |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| POST | | 清除指定文件缓存 |
| POST | | 清除全部缓存 |
Plugins
插件
| Method | Endpoint | Description |
|---|---|---|
| GET | | List installed plugins |
| POST | | Install plugins |
| PATCH | | Activate/deactivate plugins |
| PUT | | Update plugins |
| DELETE | | Delete plugins |
| GET | | Search available plugins |
| GET | | List featured plugins |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| GET | | 列出已安装插件 |
| POST | | 安装插件 |
| PATCH | | 启用/禁用插件 |
| PUT | | 更新插件 |
| DELETE | | 删除插件 |
| GET | | 搜索可用插件 |
| GET | | 列出推荐插件 |
Themes
主题
| Method | Endpoint | Description |
|---|---|---|
| GET | | List installed themes |
| POST | | Install themes |
| PATCH | | Activate theme |
| PUT | | Update themes |
| DELETE | | Delete themes |
| GET | | Search available themes |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| GET | | 列出已安装主题 |
| POST | | 安装主题 |
| PATCH | | 启用主题 |
| PUT | | 更新主题 |
| DELETE | | 删除主题 |
| GET | | 搜索可用主题 |
Backups
备份
| Method | Endpoint | Description |
|---|---|---|
| GET | | List backups |
| POST | | Create backup |
| GET | | Download backup |
| DELETE | | Delete backup |
| POST | | Restore backup |
| GET | | List automated backups |
| POST | | Restore automated backup |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| GET | | 列出备份 |
| POST | | 创建备份 |
| GET | | 下载备份 |
| DELETE | | 删除备份 |
| POST | | 恢复备份 |
| GET | | 列出自动备份 |
| POST | | 恢复自动备份 |
Cloud Backups
云备份
| Method | Endpoint | Description |
|---|---|---|
| GET | | List cloud backups |
| POST | | Create cloud backup |
| GET | | Get cloud backup |
| DELETE | | Delete cloud backup |
| GET | | Get download link |
| POST | | Restore cloud backup |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| GET | | 列出云备份 |
| POST | | 创建云备份 |
| GET | | 获取云备份详情 |
| DELETE | | 删除云备份 |
| GET | | 获取下载链接 |
| POST | | 恢复云备份 |
Files
文件管理
| Method | Endpoint | Description |
|---|---|---|
| GET | | List files |
| POST | | Upload file |
| PUT | | Save file contents |
| DELETE | | Delete file |
| GET | | View file contents |
| GET | | Download file |
| POST | | Create folder |
| POST | | Extract archive |
| POST | | Compress files |
| PATCH | | Change permissions |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| GET | | 列出文件 |
| POST | | 上传文件 |
| PUT | | 保存文件内容 |
| DELETE | | 删除文件 |
| GET | | 查看文件内容 |
| GET | | 下载文件 |
| POST | | 创建文件夹 |
| POST | | 解压归档文件 |
| POST | | 压缩文件 |
| PATCH | | 修改文件权限 |
FTP Accounts
FTP账户
| Method | Endpoint | Description |
|---|---|---|
| GET | | List FTP accounts |
| POST | | Create FTP account |
| PATCH | | Update FTP account |
| DELETE | | Delete FTP account |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| GET | | 列出FTP账户 |
| POST | | 创建FTP账户 |
| PATCH | | 更新FTP账户 |
| DELETE | | 删除FTP账户 |
SSH Keys
SSH密钥
| Method | Endpoint | Description |
|---|---|---|
| GET | | List SSH keys |
| POST | | Import SSH key |
| DELETE | | Delete SSH key |
| POST | | Activate SSH key |
| POST | | Deactivate SSH key |
| GET | | View SSH key info |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| GET | | 列出SSH密钥 |
| POST | | 导入SSH密钥 |
| DELETE | | 删除SSH密钥 |
| POST | | 激活SSH密钥 |
| POST | | 停用SSH密钥 |
| GET | | 查看SSH密钥信息 |
WordPress
WordPress
| Method | Endpoint | Description |
|---|---|---|
| GET | | Get WordPress SSO link |
| GET | | Get WordPress status |
| POST | | Execute WP-CLI command |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| GET | | 获取WordPress单点登录链接 |
| GET | | 获取WordPress状态 |
| POST | | 执行WP-CLI命令 |
Reporting
报表
| Method | Endpoint | Description |
|---|---|---|
| GET | | CDN requests report |
| GET | | Cache status report |
| GET | | Cache content report |
| GET | | Visitors report |
| GET | | WAF events list |
| GET | | WAF events by source |
| GET | | Firewall events |
| GET | | Bandwidth usage |
| GET | | Top bandwidth usage |
| GET | | Access logs |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| GET | | CDN请求报表 |
| GET | | 缓存状态报表 |
| GET | | 缓存内容报表 |
| GET | | 访客报表 |
| GET | | WAF事件列表 |
| GET | | 按来源划分的WAF事件 |
| GET | | 防火墙事件 |
| GET | | 带宽使用报表 |
| GET | | 带宽Top使用报表 |
| GET | | 访问日志 |
Account Management
账户管理
| Method | Endpoint | Description |
|---|---|---|
| GET | | Get user information |
| PATCH | | Update account settings |
| GET | | Get account usage stats |
| POST | | Change password |
| GET | | List account tasks |
| GET | | Get current plan |
| PUT | | Change hosting plan |
| POST | | Get billing SSO cookie |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| GET | | 获取用户信息 |
| PATCH | | 更新账户设置 |
| GET | | 获取账户使用统计 |
| POST | | 修改密码 |
| GET | | 列出账户任务 |
| GET | | 获取当前套餐 |
| PUT | | 更换托管套餐 |
| POST | | 获取账单系统单点登录Cookie |
Account Users
账户用户
| Method | Endpoint | Description |
|---|---|---|
| GET | | List account users |
| POST | | Create account user |
| GET | | Get user details |
| PATCH | | Update user |
| DELETE | | Remove user |
| POST | | Resend invite |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| GET | | 列出账户用户 |
| POST | | 创建账户用户 |
| GET | | 获取用户详情 |
| PATCH | | 更新用户信息 |
| DELETE | | 删除用户 |
| POST | | 重新发送邀请 |
Site Users
站点用户
| Method | Endpoint | Description |
|---|---|---|
| GET | | List site users |
| POST | | Invite site user |
| DELETE | | Remove site user |
| POST | | Resend invite |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| GET | | 列出站点用户 |
| POST | | 邀请站点用户 |
| DELETE | | 删除站点用户 |
| POST | | 重新发送邀请 |
Billing
账单
| Method | Endpoint | Description |
|---|---|---|
| GET | | List billing addresses |
| POST | | Create billing address |
| GET | | Get billing address |
| PATCH | | Update billing address |
| DELETE | | Delete billing address |
| GET | | List invoices |
| GET | | Get invoice |
| GET | | Download invoice PDF |
| POST | | Pay with card |
| GET | | List payment methods |
| POST | | Add payment method |
| DELETE | | Delete payment method |
| GET | | List available products |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| GET | | 列出账单地址 |
| POST | | 创建账单地址 |
| GET | | 获取账单地址详情 |
| PATCH | | 更新账单地址 |
| DELETE | | 删除账单地址 |
| GET | | 列出发票 |
| GET | | 获取发票详情 |
| GET | | 下载发票PDF |
| POST | | 信用卡支付 |
| GET | | 列出支付方式 |
| POST | | 添加支付方式 |
| DELETE | | 删除支付方式 |
| GET | | 列出可用产品 |
Additional Features
附加功能
| Method | Endpoint | Description |
|---|---|---|
| GET | | Get password protection status |
| POST | | Enable password protection |
| DELETE | | Disable password protection |
| GET | | List ShopShield URIs |
| POST | | Enable ShopShield |
| DELETE | | Disable ShopShield |
| GET | | Account visitor stats |
| GET | | Account bandwidth stats |
| 请求方法 | 端点 | 描述 |
|---|---|---|
| GET | | 获取密码保护状态 |
| POST | | 启用密码保护 |
| DELETE | | 禁用密码保护 |
| GET | | 列出ShopShield URI |
| POST | | 启用ShopShield |
| DELETE | | 禁用ShopShield |
| GET | | 账户访客统计 |
| GET | | 账户带宽统计 |
Common Patterns
常见使用示例
List All Sites
列出所有站点
typescript
const sites = await rocketApiRequest('/sites');
console.log(sites);
// Returns array of site objects with id, domain, status, etc.typescript
const sites = await rocketApiRequest('/sites');
console.log(sites);
// Returns array of site objects with id, domain, status, etc.Create a New Site
创建新站点
typescript
const newSite = await rocketApiRequest('/sites', {
method: 'POST',
body: JSON.stringify({
name: 'my-new-site',
location: 'us-east-1',
// Additional options as needed
})
});typescript
const newSite = await rocketApiRequest('/sites', {
method: 'POST',
body: JSON.stringify({
name: 'my-new-site',
location: 'us-east-1',
// Additional options as needed
})
});Purge CDN Cache
清除CDN缓存
typescript
// Purge specific URLs
await rocketApiRequest(`/sites/${siteId}/cache/purge`, {
method: 'POST',
body: JSON.stringify({
files: [
'https://example.com/style.css',
'https://example.com/script.js'
]
})
});
// Purge everything
await rocketApiRequest(`/sites/${siteId}/cache/purge_everything`, {
method: 'POST'
});typescript
// Purge specific URLs
await rocketApiRequest(`/sites/${siteId}/cache/purge`, {
method: 'POST',
body: JSON.stringify({
files: [
'https://example.com/style.css',
'https://example.com/script.js'
]
})
});
// Purge everything
await rocketApiRequest(`/sites/${siteId}/cache/purge_everything`, {
method: 'POST'
});Create and Restore Backup
创建并恢复备份
typescript
// Create backup
const backup = await rocketApiRequest(`/sites/${siteId}/backup`, {
method: 'POST'
});
// List backups
const backups = await rocketApiRequest(`/sites/${siteId}/backup`);
// Restore backup (background task)
await rocketApiRequest(`/sites/${siteId}/backup/${backupId}/restore`, {
method: 'POST'
});typescript
// Create backup
const backup = await rocketApiRequest(`/sites/${siteId}/backup`, {
method: 'POST'
});
// List backups
const backups = await rocketApiRequest(`/sites/${siteId}/backup`);
// Restore backup (background task)
await rocketApiRequest(`/sites/${siteId}/backup/${backupId}/restore`, {
method: 'POST'
});Manage Plugins
管理插件
typescript
// List installed plugins
const plugins = await rocketApiRequest(`/sites/${siteId}/plugins`);
// Install plugin
await rocketApiRequest(`/sites/${siteId}/plugins`, {
method: 'POST',
body: JSON.stringify({
plugins: ['wordfence', 'yoast-seo']
})
});
// Update all plugins
await rocketApiRequest(`/sites/${siteId}/plugins`, {
method: 'PUT',
body: JSON.stringify({
plugins: ['all']
})
});
// Activate/deactivate plugin
await rocketApiRequest(`/sites/${siteId}/plugins`, {
method: 'PATCH',
body: JSON.stringify({
plugins: ['wordfence'],
action: 'activate' // or 'deactivate'
})
});typescript
// List installed plugins
const plugins = await rocketApiRequest(`/sites/${siteId}/plugins`);
// Install plugin
await rocketApiRequest(`/sites/${siteId}/plugins`, {
method: 'POST',
body: JSON.stringify({
plugins: ['wordfence', 'yoast-seo']
})
});
// Update all plugins
await rocketApiRequest(`/sites/${siteId}/plugins`, {
method: 'PUT',
body: JSON.stringify({
plugins: ['all']
})
});
// Activate/deactivate plugin
await rocketApiRequest(`/sites/${siteId}/plugins`, {
method: 'PATCH',
body: JSON.stringify({
plugins: ['wordfence'],
action: 'activate' // or 'deactivate'
})
});Execute WP-CLI Commands
执行WP-CLI命令
typescript
const result = await rocketApiRequest(`/sites/${siteId}/wpcli`, {
method: 'POST',
body: JSON.stringify({
command: 'user list --format=json'
})
});typescript
const result = await rocketApiRequest(`/sites/${siteId}/wpcli`, {
method: 'POST',
body: JSON.stringify({
command: 'user list --format=json'
})
});WordPress SSO Login
WordPress单点登录
typescript
// Get SSO link for WordPress admin
const { url } = await rocketApiRequest(`/sites/${siteId}/wp_login`);
// Redirect user to url for auto-logintypescript
// Get SSO link for WordPress admin
const { url } = await rocketApiRequest(`/sites/${siteId}/wp_login`);
// Redirect user to url for auto-loginTypeScript Types
TypeScript类型定义
typescript
interface RocketSite {
id: number;
name: string;
domain: string;
status: 'active' | 'suspended' | 'pending';
location: string;
created_at: string;
updated_at: string;
}
interface RocketBackup {
id: number;
site_id: number;
type: 'manual' | 'automated' | 'cloud';
status: 'pending' | 'completed' | 'failed';
size: number;
created_at: string;
}
interface RocketPlugin {
name: string;
slug: string;
version: string;
status: 'active' | 'inactive';
update_available: boolean;
}
interface RocketDomain {
id: number;
domain: string;
is_main: boolean;
ssl_status: 'pending' | 'active' | 'failed';
validation_method: 'dns' | 'http';
}
interface RocketAuthResponse {
token: string;
expires_at: string;
}typescript
interface RocketSite {
id: number;
name: string;
domain: string;
status: 'active' | 'suspended' | 'pending';
location: string;
created_at: string;
updated_at: string;
}
interface RocketBackup {
id: number;
site_id: number;
type: 'manual' | 'automated' | 'cloud';
status: 'pending' | 'completed' | 'failed';
size: number;
created_at: string;
}
interface RocketPlugin {
name: string;
slug: string;
version: string;
status: 'active' | 'inactive';
update_available: boolean;
}
interface RocketDomain {
id: number;
domain: string;
is_main: boolean;
ssl_status: 'pending' | 'active' | 'failed';
validation_method: 'dns' | 'http';
}
interface RocketAuthResponse {
token: string;
expires_at: string;
}Error Handling
错误处理
typescript
interface RocketApiError {
error: string;
message: string;
status: number;
}
async function handleRocketRequest(endpoint: string, options?: RequestInit) {
try {
const response = await rocketApiRequest(endpoint, options);
return { data: response, error: null };
} catch (error) {
if (error.status === 401) {
// Re-authenticate and retry
await refreshToken();
return handleRocketRequest(endpoint, options);
}
if (error.status === 404) {
return { data: null, error: 'Resource not found' };
}
if (error.status === 429) {
// Rate limited - wait and retry
await sleep(1000);
return handleRocketRequest(endpoint, options);
}
return { data: null, error: error.message };
}
}typescript
interface RocketApiError {
error: string;
message: string;
status: number;
}
async function handleRocketRequest(endpoint: string, options?: RequestInit) {
try {
const response = await rocketApiRequest(endpoint, options);
return { data: response, error: null };
} catch (error) {
if (error.status === 401) {
// Re-authenticate and retry
await refreshToken();
return handleRocketRequest(endpoint, options);
}
if (error.status === 404) {
return { data: null, error: 'Resource not found' };
}
if (error.status === 429) {
// Rate limited - wait and retry
await sleep(1000);
return handleRocketRequest(endpoint, options);
}
return { data: null, error: error.message };
}
}Background Tasks
后台任务
Many operations (clone, backup restore, staging publish) run as background tasks. Monitor task status:
typescript
// Start a background task
const { task_id } = await rocketApiRequest(`/sites/${siteId}/clone`, {
method: 'POST',
body: JSON.stringify({ name: 'cloned-site' })
});
// Check task status
const tasks = await rocketApiRequest(`/sites/${siteId}/tasks`);
const task = tasks.find(t => t.id === task_id);
console.log(task.status); // 'pending', 'running', 'completed', 'failed'
// Cancel task if needed
await rocketApiRequest(`/sites/${siteId}/tasks/${task_id}/cancel`, {
method: 'POST'
});许多操作(克隆站点、恢复备份、预发布站点发布)以后台任务形式运行。可通过以下方式监控任务状态:
typescript
// Start a background task
const { task_id } = await rocketApiRequest(`/sites/${siteId}/clone`, {
method: 'POST',
body: JSON.stringify({ name: 'cloned-site' })
});
// Check task status
const tasks = await rocketApiRequest(`/sites/${siteId}/tasks`);
const task = tasks.find(t => t.id === task_id);
console.log(task.status); // 'pending', 'running', 'completed', 'failed'
// Cancel task if needed
await rocketApiRequest(`/sites/${siteId}/tasks/${task_id}/cancel`, {
method: 'POST'
});Rate Limits
请求频率限制
The API has rate limits. Implement exponential backoff:
typescript
async function withRetry<T>(
fn: () => Promise<T>,
maxRetries = 3,
delay = 1000
): Promise<T> {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (error.status === 429 && i < maxRetries - 1) {
await new Promise(resolve => setTimeout(resolve, delay * Math.pow(2, i)));
continue;
}
throw error;
}
}
throw new Error('Max retries exceeded');
}API设有请求频率限制,建议实现指数退避策略:
typescript
async function withRetry<T>(
fn: () => Promise<T>,
maxRetries = 3,
delay = 1000
): Promise<T> {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (error.status === 429 && i < maxRetries - 1) {
await new Promise(resolve => setTimeout(resolve, delay * Math.pow(2, i)));
continue;
}
throw error;
}
}
throw new Error('Max retries exceeded');
}