Pets API 関数
これらのAPI関数を使用すると、ストアのデータベース内のペットを管理できます。
新しいペットの追加
ストアのデータベースに新しいペットを追加します。
エンドポイント: https://petstore3.swagger.io/api/v3/pet
操作: POST
例
- API キー
- OAuth 2.0
POST "https://petstore3.swagger.io/api/v3/pet" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "api_key: <YOUR_API_KEY>" \
-d '{
"id": 0,
"name": "string",
"category": {
"id": 0,
"name": "string"
},
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}'
POST "https://petstore3.swagger.io/api/v3/pet" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_OAUTH_TOKEN>" \
-d '{
"id": 0,
"name": "string",
"category": {
"id": 0,
"name": "string"
},
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}'
レスポンス
| コード | 説明 |
|---|---|
| 200 | 操作成功 |
| 400 | 無効な入力 |
| 404 | ペットが見つかりません |
| 422 | 検証エラー |
| default | 予期しないエラー |
レスポンス例
200: 操作成功
{
"id": 210,
"name": "Krypto",
"category": {
"id": 1,
"name": "Dogs"
},
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
パラメータ
リクエスト本文
| 名前 | タイプ | 説明 |
|---|---|---|
| body | Pet オブジェクト | (必須) ストアに追加する Pet オブジェクト。 |
既存のペットの更新
ID に基づいて既存のペットを更新します。
エンドポイント: https://petstore3.swagger.io/api/v3/pet
操作: PUT
例
- API キー
- OAuth 2.0
PUT "https://petstore3.swagger.io/api/v3/pet" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "api_key: <YOUR_API_KEY>" \
-d '{
"id": 210,
"name": "Krypto",
"status": "available"
}'
PUT "https://petstore3.swagger.io/api/v3/pet" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_OAUTH_TOKEN>" \
-d '{
"id": 210,
"name": "Krypto",
"status": "available"
}'
レスポンス
| コード | 説明 |
|---|---|
| 200 | 操作成功 |
| 400 | 無効な入力 |
| 404 | ペットが見つかりません |
| 422 | 検証エラー |
| default | 予期しないエラー |
レスポンス例
200: 操作成功
{
"id": 210,
"name": "Krypto",
"category": {
"id": 1,
"name": "Dogs"
},
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
パラメータ
リクエスト本文
| 名前 | タイプ | 説明 |
|---|---|---|
| body | Pet オブジェクト | (必須) 更新するペットのオブジェクト。 |
ステータスによるペットの検索
ステータスに基づいてペットを検索します。
エンドポイント: https://petstore3.swagger.io/api/v3/pet/findByStatus
操作: GET
例
- API キー
- OAuth 2.0
GET "https://petstore3.swagger.io/api/v3/pet/findByStatus?status=available" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"
GET "https://petstore3.swagger.io/api/v3/pet/findByStatus?status=available" \
-H "accept: application/json" \
-H "Authorization: Bearer <YOUR_OAUTH_TOKEN>"
レスポンス
| コード | 説明 |
|---|---|
| 200 | 操作成功 |
| 400 | 無効な入力 |
| default | 予期しないエラー |
レスポンス例
200: 操作成功
[
{
"id": 210,
"name": "Krypto",
"category": {
"id": 1,
"name": "Dogs"
},
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
]
パラメータ
クエリパラメータ
| 名前 | 型 | 説明 |
|---|---|---|
| status | string | 検索するペットのステータス。 デフォルト: available。 有効な値: available, pending, sold。 |
タグによるペットの検索
タグに基づいてペットを検索します。
エンドポイント: https://petstore3.swagger.io/api/v3/pet/findByTags
操作: GET
例
- API キー
- OAuth 2.0
GET "https://petstore3.swagger.io/api/v3/pet/findByTags?tags=string" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"
GET "https://petstore3.swagger.io/api/v3/pet/findByTags?tags=string" \
-H "accept: application/json" \
-H "Authorization: Bearer <YOUR_OAUTH_TOKEN>"
レスポンス
| コード | 説明 |
|---|---|
| 200 | 操作成功 |
| 400 | 無効な入力 |
| default | 予期しないエラー |
レスポンス例
200: 操作成功
[
{
"id": 210,
"name": "Krypto",
"category": {
"id": 1,
"name": "Dogs"
},
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
]
パラメータ
クエリパラメータ
| 名前 | 型 | 説明 |
|---|---|---|
| tags | array | フィルタリングに使用するタグ。 デフォルト: []。有効な値: 有効なタグ名。 |
ID によるペットの検索
一意の ID を使用してペットを検索します。
エンドポイント: https://petstore3.swagger.io/api/v3/pet/{petId}
操作: GET
例
- API キー
- OAuth 2.0
GET "https://petstore3.swagger.io/api/v3/pet/210" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"
GET "https://petstore3.swagger.io/api/v3/pet/210" \
-H "accept: application/json" \
-H "Authorization: Bearer <YOUR_OAUTH_TOKEN>"
レスポンス
| コード | 説明 |
|---|---|
| 200 | 操作成功 |
| 400 | 指定されたIDが無効 |
| 404 | ペットが見つかりません |
| default | 予期しないエラー |
レスポンス例
200: 操作成功
{
"id": 210,
"name": "Krypto",
"category": {
"id": 1,
"name": "Dogs"
},
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
パラメータ
パスパラメータ
| 名前 | 型 | 説明 |
|---|---|---|
| petId | integer | 取得するペットのID |
フォームデータによるペットの更新
ストア内のペットをフォームデータで更新します。
エンドポイント: https://petstore3.swagger.io/api/v3/pet/{petId}
操作: POST
例
- API キー
- OAuth 2.0
POST "https://petstore3.swagger.io/api/v3/pet/210" \
-H "api_key: <YOUR_API_KEY>" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "name=Krypto" \
--data-urlencode "status=available"
POST "https://petstore3.swagger.io/api/v3/pet/210" \
-H "accept: application/json" \
-H "Authorization: Bearer <YOUR_OAUTH_TOKEN>" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "name=Krypto" \
--data-urlencode "status=available"
レスポンス
| コード | 説明 |
|---|---|
| 200 | 操作成功 |
| 405 | 無効な入力 |
| default | 予期しないエラー |
レスポンス例
200: 操作成功
{
"id": 210,
"name": "Krypto",
"category": {
"id": 1,
"name": "Dogs"
},
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
パラメータ
パスパラメータ
| 名前 | 型 | 説明 |
|---|---|---|
| petId | integer | 更新するペットのID |
クエリパラメータ
| 名前 | 型 | 説明 |
|---|---|---|
| name | string | 更新するペットの名前 |
| status | string | 更新するペットの状態 |
ペットの削除
データベースからペットを削除します。
エンドポイント: https://petstore3.swagger.io/api/v3/pet/{petId}
操作: DELETE
例
- API キー
- OAuth 2.0
DELETE "https://petstore3.swagger.io/api/v3/pet/210" \
-H "api_key: <YOUR_API_KEY>"
DELETE "https://petstore3.swagger.io/api/v3/pet/210" \
-H "Authorization: Bearer <YOUR_OAUTH_TOKEN>"
レスポンス
| コード | 説明 |
|---|---|
| 200 | ペットが削除されました |
| 400 | 指定されたIDが無効です |
| 404 | ペットが見つかりません |
(削除が成功した場合、レスポンスボディなしで 200 コードが返されます。)
パラメータ
パスパラメータ
| 名前 | タイプ | 説明 |
|---|---|---|
| petId | integer | 削除するペットのID |
画像のアップロード
ペットの画像をアップロードします。
エンドポイント: https://petstore3.swagger.io/api/v3/pet/{petId}/uploadImage
操作: POST
例
- API キー
- OAuth 2.0
POST "https://petstore3.swagger.io/api/v3/pet/210/uploadImage" \
-H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-H "api_key: <YOUR_API_KEY>" \
--form "file=@/path/to/your/file"
POST "https://petstore3.swagger.io/api/v3/pet/210/uploadImage" \
-H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer <YOUR_OAUTH_TOKEN>" \
--form "file=@/path/to/your/file"
レスポンス
| コード | 説明 |
|---|---|
| 200 | 操作成功 |
| default | 予期しないエラー |
レスポンスの例
200: 操作成功
{
"code": 200,
"type": "unknown",
"message": "additional data"
}
パラメータ
パスパラメータ
| 名前 | タイプ | 説明 |
|---|---|---|
| petId | integer | 更新するペットのID |
フォームデータパラメータ
| 名前 | 型 | 説明 |
|---|---|---|
| additionalMetadata | string | サーバーに渡す追加データ。 |
| file | file | アップロードするファイル。 |