Ce guide vous permet de tester toutes les fonctionnalités de l'API en utilisant curl.
cd server
npm install
npm startLe serveur démarre sur http://localhost:5000
curl -X POST http://localhost:5000/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "proprietaire@example.com",
"password": "password123",
"first_name": "Jean",
"last_name": "Dupont",
"phone": "+33612345678",
"role": "owner"
}'Réponse:
{
"message": "Inscription réussie",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": 1,
"email": "proprietaire@example.com",
"first_name": "Jean",
"last_name": "Dupont",
"phone": "+33612345678",
"role": "owner"
}
}💡 Sauvegardez le token retourné !
curl -X POST http://localhost:5000/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "organisateur@example.com",
"password": "password123",
"first_name": "Marie",
"last_name": "Martin",
"phone": "+33623456789",
"role": "organizer"
}'curl -X POST http://localhost:5000/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "proprietaire@example.com",
"password": "password123"
}'TOKEN="votre_token_ici"
curl -X GET http://localhost:5000/api/auth/profile \
-H "Authorization: Bearer $TOKEN"OWNER_TOKEN="token_du_proprietaire"
curl -X POST http://localhost:5000/api/venues \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OWNER_TOKEN" \
-d '{
"name": "Château de la Vallée",
"description": "Magnifique château du 18ème siècle, idéal pour vos cousinades",
"type": "Château",
"address": "15 Route du Château",
"city": "Amboise",
"region": "Centre-Val de Loire",
"postal_code": "37400",
"capacity": 30,
"bedrooms": 12,
"bathrooms": 8,
"price_per_night": 800,
"price_per_weekend": 2200,
"price_per_week": 5000,
"amenities": ["Piscine", "Parc", "Salle de réception", "WiFi", "Parking"],
"images": ["https://example.com/chateau1.jpg", "https://example.com/chateau2.jpg"]
}'curl -X GET http://localhost:5000/api/venues/owner/my-venues \
-H "Authorization: Bearer $OWNER_TOKEN"curl -X PUT http://localhost:5000/api/venues/1 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OWNER_TOKEN" \
-d '{
"name": "Château de la Vallée - Mis à jour",
"description": "Magnifique château entièrement rénové",
"price_per_night": 850,
"available": true
}'curl -X DELETE http://localhost:5000/api/venues/1 \
-H "Authorization: Bearer $OWNER_TOKEN"curl -X GET http://localhost:5000/api/venuesPar ville:
curl -X GET "http://localhost:5000/api/venues?city=Paris"Par capacité et prix:
curl -X GET "http://localhost:5000/api/venues?capacity_min=20&capacity_max=50&price_max=600"Par région et type:
curl -X GET "http://localhost:5000/api/venues?region=Provence&type=Gîte%20rural"Combinaison de filtres:
curl -X GET "http://localhost:5000/api/venues?city=Lyon&capacity_min=15&price_max=500&available=true"curl -X GET http://localhost:5000/api/venues/1ORGANIZER_TOKEN="token_de_l_organisateur"
curl -X POST http://localhost:5000/api/bookings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ORGANIZER_TOKEN" \
-d '{
"venue_id": 1,
"start_date": "2024-08-15",
"end_date": "2024-08-22",
"guests_count": 25,
"message": "Nous organisons une cousinade pour célébrer les 90 ans de notre grand-mère"
}'curl -X GET http://localhost:5000/api/bookings/my-bookings \
-H "Authorization: Bearer $ORGANIZER_TOKEN"curl -X GET http://localhost:5000/api/bookings/owner/received \
-H "Authorization: Bearer $OWNER_TOKEN"curl -X GET http://localhost:5000/api/bookings/1 \
-H "Authorization: Bearer $ORGANIZER_TOKEN"curl -X PUT http://localhost:5000/api/bookings/1/status \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OWNER_TOKEN" \
-d '{
"status": "confirmed"
}'curl -X PUT http://localhost:5000/api/bookings/1/status \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OWNER_TOKEN" \
-d '{
"status": "rejected"
}'curl -X PUT http://localhost:5000/api/bookings/1/status \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ORGANIZER_TOKEN" \
-d '{
"status": "cancelled"
}'curl -X DELETE http://localhost:5000/api/bookings/1 \
-H "Authorization: Bearer $ORGANIZER_TOKEN"curl -X GET http://localhost:5000/api/reviews/venue/1curl -X POST http://localhost:5000/api/reviews \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ORGANIZER_TOKEN" \
-d '{
"venue_id": 1,
"booking_id": 1,
"rating": 5,
"comment": "Excellent lieu pour notre cousinade ! Très spacieux et bien équipé."
}'curl -X DELETE http://localhost:5000/api/reviews/1 \
-H "Authorization: Bearer $ORGANIZER_TOKEN"curl -X GET http://localhost:5000/api/events \
-H "Authorization: Bearer $ORGANIZER_TOKEN"curl -X POST http://localhost:5000/api/events \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ORGANIZER_TOKEN" \
-d '{
"title": "Cousinade Été 2024",
"description": "Réunion de la famille Martin",
"location": "Château de la Vallée, Amboise",
"start_date": "2024-08-15",
"end_date": "2024-08-22",
"booking_id": 1,
"image_url": "https://example.com/event.jpg"
}'# Propriétaire
curl -X POST http://localhost:5000/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "owner@test.com",
"password": "test123",
"first_name": "Paul",
"last_name": "Bernard",
"role": "owner"
}'
# Sauvegarder le token retourné
OWNER_TOKEN="<token_retourné>"
# Organisateur
curl -X POST http://localhost:5000/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "organizer@test.com",
"password": "test123",
"first_name": "Sophie",
"last_name": "Dubois",
"role": "organizer"
}'
# Sauvegarder le token
ORGANIZER_TOKEN="<token_retourné>"curl -X POST http://localhost:5000/api/venues \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OWNER_TOKEN" \
-d '{
"name": "Gîte des Lavandes",
"description": "Gîte familial en Provence",
"type": "Gîte rural",
"address": "5 Chemin des Lavandes",
"city": "Roussillon",
"region": "Provence-Alpes-Côte d'\''Azur",
"postal_code": "84220",
"capacity": 20,
"bedrooms": 7,
"bathrooms": 3,
"price_per_night": 400,
"price_per_week": 2500,
"amenities": ["Piscine", "Jardin", "BBQ"],
"images": ["https://example.com/gite.jpg"]
}'# Rechercher
curl -X GET "http://localhost:5000/api/venues?city=Roussillon"
# Voir les détails
curl -X GET http://localhost:5000/api/venues/1
# Réserver
curl -X POST http://localhost:5000/api/bookings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ORGANIZER_TOKEN" \
-d '{
"venue_id": 1,
"start_date": "2024-07-20",
"end_date": "2024-07-27",
"guests_count": 18,
"message": "Pour une réunion de famille"
}'# Voir les réservations reçues
curl -X GET http://localhost:5000/api/bookings/owner/received \
-H "Authorization: Bearer $OWNER_TOKEN"
# Confirmer la réservation
curl -X PUT http://localhost:5000/api/bookings/1/status \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OWNER_TOKEN" \
-d '{"status": "confirmed"}'curl -X POST http://localhost:5000/api/events \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ORGANIZER_TOKEN" \
-d '{
"title": "Cousinade Famille Dubois 2024",
"description": "Retrouvailles familiales",
"location": "Gîte des Lavandes, Roussillon",
"start_date": "2024-07-20",
"end_date": "2024-07-27",
"booking_id": 1
}'curl -X POST http://localhost:5000/api/reviews \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ORGANIZER_TOKEN" \
-d '{
"venue_id": 1,
"booking_id": 1,
"rating": 5,
"comment": "Parfait pour notre cousinade !"
}'# Le lieu avec sa note moyenne et nombre d'avis
curl -X GET http://localhost:5000/api/venues/1curl -X GET http://localhost:5000/api/auth/profile \
-H "Authorization: Bearer $ORGANIZER_TOKEN"401 Unauthorized
{
"error": "Accès refusé. Token manquant."
}→ Ajoutez le header Authorization: Bearer <token>
403 Forbidden
{
"error": "Accès réservé aux propriétaires."
}→ Votre rôle ne permet pas cette action
400 Bad Request
{
"error": "Tous les champs sont requis"
}→ Vérifiez les données envoyées
404 Not Found
{
"error": "Lieu non trouvé"
}→ L'ID n'existe pas
- Sauvegardez vos tokens dans des variables d'environnement
- Utilisez jq pour formater les réponses:
| jq . - Testez d'abord en tant que propriétaire, puis organisateur
- Vérifiez les statuts des réservations avant de les modifier
- Les dates doivent être au format
YYYY-MM-DD
Documentation complète de l'API: Voir CHANGELOG.md