Fonctions de l'API sur les animaux domestiques
Grâce à ces fonctions API, vous pouvez gérer les animaux de compagnie dans la base de données de votre magasin.
Ajouter un nouvel animal
Ajoute un nouvel animal à la base de données du magasin.
Point de terminaison : https://petstore3.swagger.io/api/v3/pet
Opération : POST
Exemples
- API Key
- OAuth 2.0
POST "https://petstore3.swagger.io/api/v3/pet" \
-H "accept : application/json" \
-H "Content-Type : application/json" \
-H "api_key : <VOTRE_CLÉ_API>" \
-d
```json
{
"id" : 0,
"name" : "string",
"catégorie" : {
"id" : 0,
"name" : "string"
},
"photoUrls" : [
"chaîne"
],
"tags" : [
{
"id" : 0,
"name" : "string"
}
],
"statut" : "disponible"
}
POST "https://petstore3.swagger.io/api/v3/pet" \
-H "accept : application/json" \
-H "Content-Type : application/json" \
-H "Authorization : Bearer <YOUR_OAUTH_TOKEN>" \
-d
```json
{
"id" : 0,
"name" : "string",
"catégorie" : {
"id" : 0,
"name" : "string"
},
"photoUrls" : [
"chaîne"
],
"tags" : [
{
"id" : 0,
"name" : "string"
}
],
"statut" : "disponible"
}
Réponses
| Code | Description |
|---|---|
| 200 | Opération réussie |
| 400 | Entrée invalide |
| 404 | Pet introuvable |
| 422 | Exception de validation |
| par défaut | Erreur inattendue |
Exemple de réponse
200 : Successful operation
{
"id" : 210,
"name" : "Krypto",
"catégorie" : {
"id" : 1,
"nom" : "Chiens"
},
"photoUrls" : [
"chaîne"
],
"tags" : [
{
"id" : 0,
"name" : "string"
}
],
"statut" : "disponible"
}
Paramètres
Corps de la requête
| Nom | Type | Description |
|---|---|---|
| body | Objet Pet | (Obligatoire) L'objet Pet à ajouter à la base de données. |
Mise à jour d'un animal existant
Met à jour un animal de compagnie existant en fonction de son ID.
Point final : https://petstore3.swagger.io/api/v3/pet
Opération : PUT
Exemples
- API Key
- OAuth 2.0
PUT "https://petstore3.swagger.io/api/v3/pet" \
-H "accept : application/json" \
-H "Content-Type : application/json" \
-H "api_key : <VOTRE_CLÉ_API>" \
-d
```json
{
"id" : 210,
"name" : "Krypto",
"status" : "disponible"
}
PUT "https://petstore3.swagger.io/api/v3/pet" \
-H "accept : application/json" \
-H "Content-Type : application/json" \
-H "Authorization : Bearer <YOUR_OAUTH_TOKEN>" \
-d
```json
{
"id" : 210,
"name" : "Krypto",
"status" : "disponible"
}
Réponses
| Code | Description |
|---|---|
| 200 | Opération réussie |
| 400 | Entrée invalide |
| 404 | Pet non trouvé |
| 422 | Exception de validation |
| par défaut | Erreur inattendue |
Exemple de réponse
200 : Successful operation
{
"id" : 210,
"name" : "Krypto",
"catégorie" : {
"id" : 1,
"nom" : "Chiens"
},
"photoUrls" : [
"chaîne"
],
"tags" : [
{
"id" : 0,
"name" : "string"
}
],
"statut" : "disponible"
}
Paramètres
Corps de la requête
| Nom | Type | Description |
|---|---|---|
| body | Objet Pet | Objet de l'animal de compagnie (Obligatoire) à mettre à jour. |
Recherche d'un animal par son statut
Recherche les animaux de compagnie en fonction de leur statut.
Point d'arrivée : https://petstore3.swagger.io/api/v3/pet/findByStatus
Opération : GET
Exemples
- API Key
- OAuth 2.0
GET "https://petstore3.swagger.io/api/v3/pet/findByStatus?status=available" \
-H "accept : application/json" \
-H "api_key : <VOTRE_CLÉ_API>"
GET "https://petstore3.swagger.io/api/v3/pet/findByStatus?status=available" \
-H "accept : application/json" \
-H "Authorization : Bearer <YOUR_OAUTH_TOKEN>"
Réponses
| Code | Description |
|---|---|
| 200 | Opération réussie |
| 400 | Entrée invalide |
| par défaut | erreur inattendue |
Exemple de réponse
200 : Opération réussie
[
{
"id" : 210,
"name" : "Krypto",
"catégorie" : {
"id" : 1,
"nom" : "Chiens"
},
"photoUrls" : [
"chaîne"
],
"tags" : [
{
"id" : 0,
"name" : "string"
}
],
"status" : "disponible"
}
]
Paramètres
Paramètres de la requête
| Nom | Type | Description |
|---|---|---|
| status | tableau | Statut de l'animal de compagnie à rechercher. Par défaut: disponible. Valeurs autorisées: disponible, en attente, vendu. |
Recherche d'animaux par tags
Recherche les animaux en fonction de leurs étiquettes.
Point d'arrivée : https://petstore3.swagger.io/api/v3/pet/findByTags
Opération : GET
Exemples
- API Key
- OAuth 2.0
GET "https://petstore3.swagger.io/api/v3/pet/findByTags?tags=string" \
-H "accept : application/json" \
-H "api_key : <VOTRE_CLÉ_API>"
GET "https://petstore3.swagger.io/api/v3/pet/findByTags?tags=string" \
-H "accept : application/json" \
-H "Authorization : Bearer <YOUR_OAUTH_TOKEN>"
Réponses
| Code | Description |
|---|---|
| 200 | Opération réussie |
| 400 | Entrée invalide |
| défaut | Erreur inattendue |
Exemple de réponse
200 : Opération réussie
[
{
"id" : 210,
"name" : "Krypto",
"catégorie" : {
"id" : 1,
"nom" : "Chiens"
},
"photoUrls" : [
"chaîne"
],
"tags" : [
{
"id" : 0,
"name" : "string"
}
],
"statut" : "disponible"
}
]
Paramètres
Paramètres de la requête
| Nom | Type | Description |
|---|---|---|
| tags | tableau | Tags à filtrer. Par défaut: []. Valeurs autorisées: Tout nom de balise valide. |
Recherche d'un animal par son identifiant
Recherche un animal de compagnie à l'aide de son identifiant unique.
Point de terminaison : https://petstore3.swagger.io/api/v3/pet/{petId}
Opération : GET
Exemples
- API Key
- OAuth 2.0
GET "https://petstore3.swagger.io/api/v3/pet/210" \
-H "accept : application/json" \
-H "api_key : <VOTRE_CLÉ_API>"
GET "https://petstore3.swagger.io/api/v3/pet/210" \
-H "accept : application/json" \
-H "Authorization : Bearer <YOUR_OAUTH_TOKEN>"
Réponses
| Code | Description |
|---|---|
| 200 | Opération réussie |
| 400 | ID invalide fourni |
| 404 | Pet introuvable |
| par défaut | Erreur inattendue |
Exemple de réponse
200 : Opération réussie
{
"id" : 210,
"name" : "Krypto",
"catégorie" : {
"id" : 1,
"nom" : "Chiens"
},
"photoUrls" : [
"chaîne"
],
"tags" : [
{
"id" : 0,
"name" : "string"
}
],
"statut" : "disponible"
}
Paramètres
Chemin d'accès p1arameters
| Nom | Type | Description |
|---|---|---|
| petId | integer | ID de l'animal à renvoyer |
Mise à jour d'un animal avec les données du formulaire
Met à jour un animal de compagnie dans le magasin à l'aide des données du formulaire.
Point de terminaison : https://petstore3.swagger.io/api/v3/pet/{petId}
Opération : POST
Exemples
- API Key
- OAuth 2.0
POST "https://petstore3.swagger.io/api/v3/pet/210" \
-H "api_key : <VOTRE_CLÉ_API>" \
-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"
Réponses
| Code | Description |
|---|---|
| 200 | Opération réussie |
| 405 | Entrée invalide |
| défaut | Erreur inattendue |
Exemple de réponse
200 : Opération réussie
{
"id" : 210,
"name" : "Krypto",
"catégorie" : {
"id" : 1,
"nom" : "Chiens"
},
"photoUrls" : [
"chaîne"
],
"tags" : [
{
"id" : 0,
"name" : "string"
}
],
"statut" : "disponible"
}
Paramètres
Paramètres du chemin d'accès
| Nom | Type | Description |
|---|---|---|
| petId | integer | ID de l'animal à mettre à jour |
Paramètres de la requête
| Nom | Type | Description |
|---|---|---|
| Nom | chaîne de caractères | Nom de l'animal à mettre à jour |
| statut | chaîne de caractères | Statut de l'animal à mettre à jour |
Suppression d'un animal
Supprime un animal de la base de données.
Point de terminaison : https://petstore3.swagger.io/api/v3/pet/{petId}
Opération : DELETE
Exemples
- API Key
- OAuth 2.0
DELETE "https://petstore3.swagger.io/api/v3/pet/210" \
-H "api_key : <VOTRE_CLÉ_API>"
DELETE "https://petstore3.swagger.io/api/v3/pet/210" \
-H "Authorization : Bearer <YOUR_OAUTH_TOKEN>"
Réponses
| Code | Description |
|---|---|
| 200 | Pet supprimé |
| 400 | ID invalide fourni |
| 404 | Animal non trouvé |
(Une suppression réussie renvoie un code 200 sans corps de réponse).
Paramètres
Paramètres du chemin d'accès
| Nom | Type | Description |
|---|---|---|
| petId | integer | ID de l'animal à supprimer |
Téléchargement d'une image
Permet de télécharger une image pour un animal.
Point de terminaison : https://petstore3.swagger.io/api/v3/pet/{petId}/uploadImage
Opération : POST
Exemples
- API Key
- 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 : <VOTRE_CLÉ_API>" \
--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"
Réponses
| Code | Description |
|---|---|
| 200 | Opération réussie |
| par défaut | erreur inattendue |
Exemples de réponses
200 : Opération réussie
{
"code" : 200,
"type" : "unknown",
"message" : "données supplémentaires"
}
Paramètres
Paramètres du chemin d'accès
| Nom | Type | Description |
|---|---|---|
| petId | integer | ID de l'animal à mettre à jour |
Paramètres des données du formulaire
| Nom | Type | Description |
|---|---|---|
| AdditionalMetadata | string | Données supplémentaires à transmettre au serveur. |
| file | file | Fichier à télécharger. |