Aller au contenu

🔗 Documentation API

API publique Boaz-Housing pour développeurs externes


📋 Fichiers Disponibles

guide-utilisation.md

Guide complet d'utilisation de l'API externe - Authentification - Endpoints disponibles - Exemples requêtes - Codes erreurs

guide-logements.md

API Logements spécifique - CRUD logements - Filtres avancés - Vérification disponibilité

kit-developpeur.md

Kit développeur complet avec exemples - Scripts Python/JavaScript - Collections Postman - Tests automatisés


🎯 API Base URL

Production : https://api-housing.boaz-study.tech

Développement : http://localhost:8001


🚀 Quick Start

1. Authentification

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Login
curl -X POST https://api-housing.boaz-study.tech/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","password":"password"}'

# Réponse
{
  "access_token": "eyJ0eXAiOiJKV1QiLCJhbGc...",
  "token_type": "bearer",
  "user": {...}
}

2. Utiliser l'API

1
2
3
# Exemple : Lister logements disponibles
curl -X GET https://api-housing.boaz-study.tech/api/logements/disponibles \
  -H "Authorization: Bearer YOUR_TOKEN"

3. Créer une ressource

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Exemple : Créer un logement
curl -X POST https://api-housing.boaz-study.tech/api/logements/ \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "titre": "Studio moderne",
    "adresse": "10 rue Example",
    "ville": "Paris",
    "loyer": 600.00,
    "montant_charges": 50.00
  }'

📊 Endpoints Principaux

Logements

1
2
3
4
5
6
GET    /api/logements/              - Liste logements
GET    /api/logements/disponibles   - Logements disponibles
POST   /api/logements/              - Créer logement
GET    /api/logements/{id}          - Détail logement
PUT    /api/logements/{id}          - Modifier logement
DELETE /api/logements/{id}          - Supprimer logement

Souscriptions

1
2
3
4
5
GET    /api/souscriptions/          - Liste souscriptions
POST   /api/souscriptions/          - Créer souscription
GET    /api/souscriptions/{id}      - Détail souscription
PUT    /api/souscriptions/{id}      - Modifier souscription
POST   /api/souscriptions/{id}/paiement-en-ligne - Paiement Stripe

Services

1
GET    /api/services/               - Liste services disponibles

Organisation

1
GET    /api/organisation/           - Détails organisation

🔑 Authentification

Type : Bearer Token (JWT)

Header requis :

1
Authorization: Bearer YOUR_JWT_TOKEN

Obtention token :

1
2
POST /api/auth/login
Body: {"email": "...", "password": "..."}


📝 Format Réponses

Succès

1
2
3
4
5
6
{
  "id": 123,
  "titre": "Studio moderne",
  "ville": "Paris",
  ...
}

Liste

1
2
3
4
[
  {"id": 1, ...},
  {"id": 2, ...}
]

Erreur

1
2
3
{
  "detail": "Logement non trouvé"
}

🐛 Codes Erreurs

Code Signification Action
200 OK Succès
201 Created Ressource créée
400 Bad Request Vérifier données envoyées
401 Unauthorized Token manquant/invalide
403 Forbidden Droits insuffisants
404 Not Found Ressource introuvable
422 Unprocessable Entity Validation échouée
500 Internal Server Error Erreur serveur

🔗 Liens Utiles


🧪 Tests

Collection Postman

Voir kit-developpeur.md pour télécharger la collection

Tests automatisés

1
2
3
4
5
6
# Backend
cd backend
pytest

# Avec coverage
pytest --cov=app tests/

Maintenu par : Équipe Boaz-Housing Dev Dernière mise à jour : 01/10/2025