🚀 Dummy REST API

テスト用ダミーREST APIエンドポイント

概要

このAPIは、フロントエンド開発やテスト目的で使用できるダミーREST APIエンドポイントを提供します。 実際のバックエンドなしで、様々なHTTPメソッド、レスポンス形式、エラーケースをテストできます。

ベースURL: http://localhost:3000
📖 Swagger UIで詳細を見る

👥 ユーザー

GET /api/users

ユーザーリストを取得(ページネーション、ソート対応)

クエリパラメータ:

  • pageinteger - ページ番号 (デフォルト: 1)
  • limitinteger - 1ページあたりの件数 (デフォルト: 10)
  • sortstring - ソートフィールド (例: name, age)
  • orderstring - ソート順 (asc/desc)

レスポンス例:

{
  "status": "success",
  "data": [
    {
      "id": 1,
      "name": "山田太郎",
      "email": "yamada@example.com",
      "age": 30
    }
  ],
  "pagination": {
    "total": 100,
    "page": 1,
    "limit": 10,
    "totalPages": 10
  }
}
GET /api/users/:id

IDを指定してユーザーを取得

レスポンス例:

{
  "status": "success",
  "data": {
    "id": 1,
    "name": "山田太郎",
    "email": "yamada@example.com",
    "age": 30
  }
}
POST /api/users

新しいユーザーを作成

リクエストボディ:

{
  "name": "山田太郎",
  "email": "yamada@example.com",
  "age": 30
}
PUT /api/users/:id

ユーザー情報を更新

リクエストボディ:

{
  "name": "山田太郎",
  "email": "yamada@example.com",
  "age": 31
}
DELETE /api/users/:id

ユーザーを削除

レスポンス例:

{
  "status": "success",
  "data": {
    "message": "User deleted successfully",
    "messageJa": "ユーザーが正常に削除されました"
  }
}

📝 投稿

GET /api/posts

投稿リストを取得(ページネーション対応)

レスポンス例:

{
  "status": "success",
  "data": [
    {
      "id": 1,
      "title": "サンプル投稿",
      "content": "これはサンプルの投稿内容です。",
      "authorId": 1,
      "createdAt": "2024-01-01T00:00:00.000Z"
    }
  ],
  "pagination": {
    "total": 50,
    "page": 1,
    "limit": 10,
    "totalPages": 5
  }
}
POST /api/posts

新しい投稿を作成

リクエストボディ:

{
  "title": "サンプル投稿",
  "content": "これはサンプルの投稿内容です。",
  "authorId": 1
}
GET /api/posts/:id

IDを指定して投稿を取得

PUT /api/posts/:id

投稿を更新

DELETE /api/posts/:id

投稿を削除

💬 コメント

GET /api/comments

コメントリストを取得

レスポンス例:

{
  "status": "success",
  "data": [
    {
      "id": 1,
      "postId": 1,
      "author": "山田太郎",
      "content": "これはコメントです。",
      "createdAt": "2024-01-01T00:00:00.000Z"
    }
  ]
}
POST /api/comments

新しいコメントを作成

リクエストボディ:

{
  "postId": 1,
  "author": "山田太郎",
  "content": "これはコメントです。"
}
GET /api/comments/:id

IDを指定してコメントを取得

PUT /api/comments/:id

コメントを更新

DELETE /api/comments/:id

コメントを削除

🛍️ 商品

GET /api/products

商品リストを取得

レスポンス例:

{
  "status": "success",
  "data": [
    {
      "id": 1,
      "name": "ノートパソコン",
      "price": 89800,
      "category": "Electronics",
      "inStock": true
    }
  ]
}
POST /api/products

新しい商品を作成

リクエストボディ:

{
  "name": "ノートパソコン",
  "price": 89800,
  "category": "Electronics",
  "inStock": true
}
GET /api/products/:id

IDを指定して商品を取得

PUT /api/products/:id

商品を更新

DELETE /api/products/:id

商品を削除

Todo

GET /api/todos

Todoリストを取得

レスポンス例:

{
  "status": "success",
  "data": [
    {
      "id": 1,
      "title": "タスクを完了する",
      "completed": false,
      "userId": 1,
      "dueDate": "2024-12-31T23:59:59.000Z"
    }
  ]
}
POST /api/todos

新しいTodoを作成

リクエストボディ:

{
  "title": "タスクを完了する",
  "completed": false,
  "userId": 1,
  "dueDate": "2024-12-31T23:59:59.000Z"
}
GET /api/todos/:id

IDを指定してTodoを取得

PUT /api/todos/:id

Todoを更新

DELETE /api/todos/:id

Todoを削除

👤 アカウント

GET /api/account

アカウント情報を取得

クエリパラメータ:

  • accountstring - アカウント識別子 (例: dummy)

レスポンス例:

{
  "status": "success",
  "data": {
    "UserID": "A123456",
    "UserNameJP": "〇〇 〇〇",
    "UserNameEN": "Hoge Fuga"
  }
}

🔧 ユーティリティ

GET /api/delay

指定されたミリ秒数だけレスポンスを遅延

クエリパラメータ:

  • delayinteger - 遅延時間(ミリ秒、最大3000)

レスポンス例:

{
  "status": "success",
  "data": {
    "message": "Response delayed by 1000ms",
    "messageJa": "レスポンスを1000ms遅延しました",
    "delay": 1000
  }
}
GET /api/status/:code

指定されたHTTPステータスコードを返す

パスパラメータ:

  • codeinteger - ステータスコード (200, 201, 400, 401, 403, 404, 500)

レスポンス例:

{
  "status": "success",
  "data": {
    "code": 200,
    "description": "OK",
    "descriptionJa": "成功"
  }
}
GET /api/random

ランダムなデータを生成して返す

クエリパラメータ:

  • typestring - データタイプ (user, post, product)

レスポンス例:

{
  "status": "success",
  "data": {
    "id": 42,
    "name": "ランダムユーザー",
    "email": "random@example.com",
    "age": 25
  }
}

⚠️ エラーレスポンス

すべてのエラーは以下の形式で返されます:

エラーレスポンス例:

{
  "status": "error",
  "message": "Resource not found",
  "messageJa": "リソースが見つかりません",
  "code": 404
}

一般的なエラーコード:

  • 400 - 無効なリクエスト
  • 404 - リソースが見つかりません
  • 405 - サポートされていないメソッド
  • 500 - サーバー内部エラー