REST APIエンドポイント
Caution
デモページ - これはマルチタブドキュメント機能を紹介するデモページです。このコンテンツは説明目的のみです。
REST APIは、データにアクセスおよび操作するためのエンドポイントを提供します。すべてのエンドポイントはJSON形式でデータを返します。
ベースURL
すべてのAPIリクエストは以下のベースURLに対して行う必要があります:
https://api.example.com/v1ユーザーエンドポイント
すべてのユーザーを取得
GET /usersすべてのユーザーのリストを返します。ページネーションパラメータをサポートしています。
クエリパラメータ:
| パラメータ | 型 | 説明 |
|---|---|---|
| page | integer | ページ番号(デフォルト: 1) |
| limit | integer | ページあたりのレコード数(デフォルト: 50、最大: 100) |
| sort | string | ソートするフィールド(例: “name”、“created_at”) |
レスポンス:
{ "data": [ { "id": "user_123", "name": "John Doe", "created_at": "2023-01-15T08:30:00Z" }, // More users... ], "meta": { "total": 250, "page": 1, "limit": 50 }}IDでユーザーを取得
GET /users/{id}IDで単一のユーザーを返します。
レスポンス:
{ "data": { "id": "user_123", "name": "John Doe", "created_at": "2023-01-15T08:30:00Z", "profile": { "bio": "Software developer", "location": "New York", "avatar_url": "https://example.com/avatars/john.jpg" } }}製品エンドポイント
すべての製品を取得
GET /productsすべての製品のリストを返します。フィルタリングとページネーションをサポートしています。
クエリパラメータ:
| パラメータ | 型 | 説明 |
|---|---|---|
| category | string | カテゴリでフィルタ |
| min_price | number | 最低価格でフィルタ |
| max_price | number | 最高価格でフィルタ |
| page | integer | ページ番号(デフォルト: 1) |
| limit | integer | ページあたりのレコード数(デフォルト: 50、最大: 100) |
レスポンス:
{ "data": [ { "id": "prod_123", "name": "Example Product", "description": "This is an example product", "price": 49.99, "category": "electronics" }, // More products... ], "meta": { "total": 350, "page": 1, "limit": 50 }}エラー処理
すべてのエンドポイントは標準のHTTPステータスコードに従い、適切な場合には詳細なエラーメッセージを含みます:
| ステータスコード | 説明 |
|---|---|
| 200 | OK - リクエスト成功 |
| 400 | Bad Request - 無効なパラメータ |
| 401 | Unauthorized - 認証が必要 |
| 403 | Forbidden - 権限不足 |
| 404 | Not Found - リソースが存在しません |
| 429 | Too Many Requests - レート制限を超過 |
| 500 | Internal Server Error - サーバーエラーが発生 |
エラーレスポンスには、何が問題だったかを説明するメッセージが含まれます:
{ "error": { "code": "invalid_parameter", "message": "The parameter 'email' is not a valid email address", "request_id": "req_abc123" }}