mcpField
R
rocket-net-api

rocket-net-api

github.com/jezwebクラウド・DevOps1.1k109 回インストール3 週間前に更新
リポジトリ

rocket-net-api について

rocket-net-apiは、Rocket.netのマネージドWordPressホスティングAPIを利用する開発者向けの連携ガイドです。JWT認証に加え、サイト、バックアップ、ドメイン、プラグイン、レポート、アカウント、請求の各エンドポイントを説明します。

主な機能

  1. 01JWTベースのAPI認証
  2. 02WordPressサイトの作成と管理
  3. 03ドメインとCDNキャッシュの設定
  4. 04プラグイン、テーマ、ファイルの管理
  5. 05バックアップの作成、ダウンロード、復元
  6. 06レポートとアカウントのエンドポイント

活用シーン

  1. 01サイト作成と更新の自動化
  2. 02ステージングサイトの本番公開
  3. 03バックアップの管理とサイトの復元
  4. 04CDN、訪問者、帯域幅レポートの確認

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/jezweb/claude-skills --skill rocket-net-api

インストール後、Claude Code で/rocket-net-apiを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

README.md
.claude-plugin/
plugin.json
references/
endpoints.md

詳細

Rocket.net API 連携

Rocket.net のマネージド WordPress ホスティングプラットフォーム API との連携を構築します。このスキルでは、認証、サイト管理、ドメイン設定、バックアップ、プラグイン/テーマ、CDN キャッシュ制御、および 200 以上のすべての API エンドポイントを扱います。

API の概要

ベース URL:https://api.rocket.net/v1

認証:JWT トークンベース

  • メールアドレスとパスワードを指定して POST /login を実行し、トークンを取得します
  • トークンの有効期限は 7 日間です
  • リクエストでは Authorization: Bearer <token> として指定します

コンテンツタイプ:JSON API

  • 必須ヘッダー:Content-Type: application/json
  • 推奨ヘッダー:Accept: application/json

ドキュメント:https://rocketdotnet.readme.io/reference/introduction

認証

JWT トークンを取得する
const response = await fetch('https://api.rocket.net/v1/login', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({
    username: '[email protected]',
    password: 'your-password'
  })
});

const { token } = await response.json();
// Use token in subsequent requests
認証済みリクエストのパターン
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 エンドポイント

サイト管理
メソッドエンドポイント説明
GET/sitesすべてのサイトを一覧表示
POST/sites新しいサイトを作成
GET/sites/{id}サイトの詳細を取得
PATCH/sites/{id}サイトのプロパティを更新
DELETE/sites/{id}サイトを削除
POST/sites/{id}/cloneサイトを複製(バックグラウンドタスク)
GET/sites/{id}/credentialsサイトの認証情報を取得
GET/sites/{id}/usageサイトの使用状況統計を取得
POST/sites/{id}/lockサイトをロック(変更を防止)
DELETE/sites/{id}/lockサイトのロックを解除
GET/sites/{id}/pma_loginphpMyAdmin の SSO リンクを取得
GET/sites/{id}/settingsサイトの設定を取得
PATCH/sites/{id}/settingsサイトの設定を更新
GET/sites/locations利用可能なサイトのロケーションを一覧表示
ステージングサイト
メソッドエンドポイント説明
POST/sites/{id}/stagingステージングサイトを作成
DELETE/sites/{id}/stagingステージングサイトを削除
POST/sites/{id}/staging/publishステージングサイトを本番環境に公開
サイトテンプレート
メソッドエンドポイント説明
GET/sites/templatesサイトテンプレートを一覧表示
POST/sites/templatesサイトテンプレートを作成
GET/sites/templates/{id}テンプレートの詳細を取得
DELETE/sites/templates/{id}テンプレートを削除
POST/sites/templates/{id}/sitesテンプレートからサイトを作成
ドメイン
メソッドエンドポイント説明
GET/sites/{id}/domainsドメインエイリアスを一覧表示
POST/sites/{id}/domainsドメインエイリアスを追加
DELETE/sites/{id}/domains/{domainId}ドメインエイリアスを削除
GET/sites/{id}/maindomainメインドメイン情報を取得
POST/sites/{id}/maindomainメインドメインを設定
PUT/sites/{id}/maindomainメインドメインを置換
PATCH/sites/{id}/maindomainドメインの検証/SSL を更新
GET/sites/{id}/maindomain/statusドメインのステータスを確認
GET/sites/{id}/maindomain/recheck検証を強制的に再確認
GET/sites/{id}/domains/{domainId}/edge_settingsエッジ設定を取得
PATCH/sites/{id}/domains/{domainId}/edge_settingsエッジ設定を更新
CDN キャッシュ
メソッドエンドポイント説明
POST/sites/{id}/cache/purge特定のファイルをキャッシュから削除
POST/sites/{id}/cache/purge_everythingすべてのキャッシュを削除
プラグイン
メソッドエンドポイント説明
GET/sites/{id}/pluginsインストール済みプラグインを一覧表示
POST/sites/{id}/pluginsプラグインをインストール
PATCH/sites/{id}/pluginsプラグインを有効化/無効化
PUT/sites/{id}/pluginsプラグインを更新
DELETE/sites/{id}/pluginsプラグインを削除
GET/sites/{id}/plugins/search利用可能なプラグインを検索
GET/sites/{id}/featured_pluginsおすすめのプラグインを一覧表示
テーマ
メソッドエンドポイント説明
GET/sites/{id}/themesインストール済みテーマの一覧
POST/sites/{id}/themesテーマをインストール
PATCH/sites/{id}/themesテーマを有効化
PUT/sites/{id}/themesテーマを更新
DELETE/sites/{id}/themesテーマを削除
GET/sites/{id}/themes/search利用可能なテーマを検索
バックアップ
メソッドエンドポイント説明
GET/sites/{id}/backupバックアップの一覧
POST/sites/{id}/backupバックアップを作成
GET/sites/{id}/backup/{backupId}バックアップをダウンロード
DELETE/sites/{id}/backup/{backupId}バックアップを削除
POST/sites/{id}/backup/{backupId}/restoreバックアップを復元
GET/sites/{id}/backup/automated自動バックアップの一覧
POST/sites/{id}/backup/automated/{restoreId}/restore自動バックアップを復元
クラウドバックアップ
メソッドエンドポイント説明
GET/sites/{id}/cloud_backupsクラウドバックアップの一覧
POST/sites/{id}/cloud_backupsクラウドバックアップを作成
GET/sites/{id}/cloud_backups/{backupId}クラウドバックアップを取得
DELETE/sites/{id}/cloud_backups/{backupId}クラウドバックアップを削除
GET/sites/{id}/cloud_backups/{backupId}/downloadダウンロードリンクを取得
POST/sites/{id}/cloud_backups/{backupId}/restoreクラウドバックアップを復元
ファイル
メソッドエンドポイント説明
GET/sites/{id}/file_manager/filesファイルの一覧
POST/sites/{id}/filesファイルをアップロード
PUT/sites/{id}/filesファイルの内容を保存
DELETE/sites/{id}/filesファイルを削除
GET/sites/{id}/files/viewファイルの内容を表示
GET/sites/{id}/files/downloadファイルをダウンロード
POST/sites/{id}/files/folderフォルダーを作成
POST/sites/{id}/files/extractアーカイブを展開
POST/sites/{id}/files/compressファイルを圧縮
PATCH/sites/{id}/files/chmod権限を変更
FTP アカウント
メソッドエンドポイント説明
GET/sites/{id}/ftp_accountsFTP アカウントの一覧
POST/sites/{id}/ftp_accountsFTP アカウントを作成
PATCH/sites/{id}/ftp_accountsFTP アカウントを更新
DELETE/sites/{id}/ftp_accountsFTP アカウントを削除
SSH キー
メソッドエンドポイント説明
GET/sites/{id}/ssh_keysSSH キーの一覧
POST/sites/{id}/ssh_keysSSH キーをインポート
DELETE/sites/{id}/ssh_keysSSH キーを削除
POST/sites/{id}/ssh_keys/authorizeSSH キーを有効化
POST/sites/{id}/ssh_keys/deauthorizeSSH キーを無効化
GET/sites/{id}/ssh_keys/{name}SSH キーの情報を表示
WordPress
メソッドエンドポイント説明
GET/sites/{id}/wp_loginWordPress の SSO リンクを取得
GET/sites/{id}/wp_statusWordPress のステータスを取得
POST/sites/{id}/wpcliWP-CLI コマンドを実行
レポート
メソッドエンドポイント説明
GET/reporting/sites/{id}/cdn_requestsCDN リクエストレポート
GET/reporting/sites/{id}/cdn_cache_statusキャッシュステータスレポート
GET/reporting/sites/{id}/cdn_cache_contentキャッシュコンテンツレポート
GET/reporting/sites/{id}/visitors訪問者レポート
GET/reporting/sites/{id}/waf_eventlistWAF イベント一覧
GET/reporting/sites/{id}/waf_events_sourceソース別 WAF イベント
GET/reporting/sites/{id}/waf_firewall_eventsファイアウォールイベント
GET/reporting/sites/{id}/bandwidth_usage帯域幅使用量
GET/reporting/sites/{id}/bandwidth_top_usage帯域幅使用量の上位
GET/sites/{id}/access_logsアクセスログ
アカウント管理
MethodEndpointDescription
GET/account/meユーザー情報を取得
PATCH/account/meアカウント設定を更新
GET/account/usageアカウントの使用状況を取得
POST/account/passwordパスワードを変更
GET/account/tasksアカウントのタスク一覧を取得
GET/account/hosting_plan現在のプランを取得
PUT/account/hosting_planホスティングプランを変更
POST/account/billing_sso請求用 SSO Cookie を取得
アカウントユーザー
MethodEndpointDescription
GET/usersアカウントユーザーの一覧を取得
POST/usersアカウントユーザーを作成
GET/users/{userId}ユーザーの詳細を取得
PATCH/users/{userId}ユーザーを更新
DELETE/users/{userId}ユーザーを削除
POST/users/{userId}/reinvite招待を再送信
サイトユーザー
MethodEndpointDescription
GET/sites/{id}/usersサイトユーザーの一覧を取得
POST/sites/{id}/usersサイトユーザーを招待
DELETE/sites/{id}/users/{userId}サイトユーザーを削除
POST/sites/{id}/users/{userId}/reinvite招待を再送信
請求
MethodEndpointDescription
GET/billing/addresses請求先住所の一覧を取得
POST/billing/addresses請求先住所を作成
GET/billing/addresses/{addressId}請求先住所を取得
PATCH/billing/addresses/{addressId}請求先住所を更新
DELETE/billing/addresses/{addressId}請求先住所を削除
GET/billing/invoices請求書の一覧を取得
GET/billing/invoices/{invoiceId}請求書を取得
GET/billing/invoices/{invoiceId}/pdf請求書の PDF をダウンロード
POST/billing/invoices/{invoiceId}/credit_card_paymentカードで支払う
GET/billing/payment_methods支払い方法の一覧を取得
POST/billing/payment_methods支払い方法を追加
DELETE/billing/payment_methods/{methodId}支払い方法を削除
GET/billing/products利用可能な製品の一覧を取得
その他の機能
MethodEndpointDescription
GET/sites/{id}/password_protectionパスワード保護の状態を取得
POST/sites/{id}/password_protectionパスワード保護を有効化
DELETE/sites/{id}/password_protectionパスワード保護を無効化
GET/sites/{id}/shopshieldShopShield URI の一覧を取得
POST/sites/{id}/shopshieldShopShield を有効化
DELETE/sites/{id}/shopshield/{id}ShopShield を無効化
GET/account/visitorsアカウントの訪問者統計
GET/account/bandwidthアカウントの帯域幅統計

よく使うパターン

すべてのサイトを一覧表示
const sites = await rocketApiRequest('/sites');
console.log(sites);
// Returns array of site objects with id, domain, status, etc.
新しいサイトを作成
const newSite = await rocketApiRequest('/sites', {
  method: 'POST',
  body: JSON.stringify({
    name: 'my-new-site',
    location: 'us-east-1',
    // Additional options as needed
  })
});
CDN キャッシュを消去
// 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 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'
});
プラグインを管理
// 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'
  })
});
WP-CLI コマンドを実行
const result = await rocketApiRequest(`/sites/${siteId}/wpcli`, {
  method: 'POST',
  body: JSON.stringify({
    command: 'user list --format=json'
  })
});
WordPress SSO ログイン
// Get SSO link for WordPress admin
const { url } = await rocketApiRequest(`/sites/${siteId}/wp_login`);
// Redirect user to url for auto-login

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;
}

エラー処理

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 };
  }
}

バックグラウンドタスク

クローン、バックアップの復元、ステージングの公開など、多くの操作はバックグラウンドタスクとして実行されます。タスクの状態を監視してください。

// 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'
});

レート制限

API にはレート制限があります。指数バックオフを実装してください。

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');
}

参考資料

コメント