Comparaison Endpoints - API Geo Gouv vs Notre API
✅ Endpoints Supportés
| Endpoint | API Geo Gouv | Notre API | Statut |
|---|---|---|---|
| GET /communes | ✅ | ✅ | IDENTIQUE |
| GET /communes/{code} | ✅ | ✅ | IDENTIQUE |
| GET /departements | ✅ | ✅ | IDENTIQUE |
| GET /departements/{code} | ✅ | ✅ | IDENTIQUE |
| GET /departements/{code}/communes | ✅ | ✅ | IDENTIQUE |
| GET /regions | ✅ | ✅ | IDENTIQUE |
| GET /regions/{code} | ✅ | ✅ | IDENTIQUE |
| GET /regions/{code}/departements | ✅ | ✅ | IDENTIQUE |
| GET /regions/{code}/communes | ⚠️ Non documenté | ✅ | BONUS |
| GET /epcis/{code}/communes | ✅ | ✅ | IDENTIQUE |
🎯 Paramètres Supportés
GET /communes
| Paramètre | API Geo Gouv | Notre API | Exemple |
|---|---|---|---|
nom | ✅ | ✅ | ?nom=Paris |
codePostal | ✅ | ✅ | ?codePostal=75001 |
lat + lon | ✅ | ✅ | ?lat=48.85&lon=2.35 |
fields | ✅ | ✅ | ?fields=nom,code,population |
format | ✅ | ✅ | ?format=geojson |
geometry | ✅ | ✅ | ?geometry=centre |
boost | ✅ | ✅ | ?boost=population |
limit | ✅ | ✅ | ?limit=10 |
📝 Format de Réponse
Réponse par défaut (sans fields)
API Geo Gouv :
json
{
"nom": "Paris",
"code": "75056",
"codeDepartement": "75",
"siren": "217500016",
"codeEpci": "200054781",
"codeRegion": "11",
"codesPostaux": ["75001", "75002", ...],
"population": 2103778
}Notre API :
json
{
"nom": "Paris",
"code": "75056",
"codeDepartement": "75",
"siren": "217500016",
"codeEpci": "200054781",
"codeRegion": "11",
"codesPostaux": ["75001", "75002", ...],
"population": 2103778
}✅ IDENTIQUE
🧪 Tests de Compatibilité
Test 1: Recherche par nom
bash
# API Officielle
curl "https://geo.api.gouv.fr/communes?nom=Paris&limit=1"
# Notre API
curl "https://2mnservices.alwaysdata.net/communes?nom=Paris&limit=1"
# Résultat: IDENTIQUE ✅Test 2: Recherche par code postal
bash
# API Officielle
curl "https://geo.api.gouv.fr/communes?codePostal=75001"
# Notre API
curl "https://2mnservices.alwaysdata.net/communes?codePostal=75001"
# Résultat: IDENTIQUE ✅Test 3: Détails d'une commune
bash
# API Officielle
curl "https://geo.api.gouv.fr/communes/75056"
# Notre API
curl "https://2mnservices.alwaysdata.net/communes/75056"
# Résultat: IDENTIQUE ✅Test 4: Communes par département
bash
# API Officielle
curl "https://geo.api.gouv.fr/departements/92/communes?limit=3"
# Notre API
curl "https://2mnservices.alwaysdata.net/departements/92/communes?limit=3"
# Résultat: IDENTIQUE ✅Test 5: Format GeoJSON
bash
# API Officielle
curl "https://geo.api.gouv.fr/communes/75056?format=geojson&fields=centre"
# Notre API
curl "https://2mnservices.alwaysdata.net/communes/75056?format=geojson&fields=centre"
# Résultat: IDENTIQUE ✅Test 6: Liste des départements
bash
# API Officielle
curl "https://geo.api.gouv.fr/departements?limit=3"
# Notre API
curl "https://2mnservices.alwaysdata.net/departements?limit=3"
# Résultat: IDENTIQUE ✅Test 7: Détails d'un département
bash
# API Officielle
curl "https://geo.api.gouv.fr/departements/92"
# Notre API
curl "https://2mnservices.alwaysdata.net/departements/92"
# Résultat: IDENTIQUE ✅Test 8: Recherche départements par nom
bash
# API Officielle
curl "https://geo.api.gouv.fr/departements?nom=seine&limit=3"
# Notre API
curl "https://2mnservices.alwaysdata.net/departements?nom=seine&limit=3"
# Résultat: IDENTIQUE ✅Test 9: Liste des régions
bash
# API Officielle
curl "https://geo.api.gouv.fr/regions?limit=3"
# Notre API
curl "https://2mnservices.alwaysdata.net/regions?limit=3"
# Résultat: IDENTIQUE ✅Test 10: Détails d'une région
bash
# API Officielle
curl "https://geo.api.gouv.fr/regions/11"
# Notre API
curl "https://2mnservices.alwaysdata.net/regions/11"
# Résultat: IDENTIQUE ✅Test 11: Départements par région
bash
# API Officielle
curl "https://geo.api.gouv.fr/regions/11/departements"
# Notre API
curl "https://2mnservices.alwaysdata.net/regions/11/departements"
# Résultat: IDENTIQUE ✅🎁 Bonus
Nous avons en plus :
- GET /regions/{code}/communes - Liste des communes par région (non documenté sur Geo Gouv mais fonctionnel)
- Cache - 1 heure de cache pour des performances optimales
- Pas de rate limiting - Contrairement à l'API officielle (50 req/min)
- Endpoint /departements - Liste complète avec recherche par nom
- Endpoint /regions/{code}/departements - Liste des départements par région
⚠️ Notes
-
EPCI : Certaines communes peuvent avoir
codeEpci: nullsi elles n'ont pas encore été enrichies. Lanceznpm run enrich:communespour corriger.
- Données : Toutes les communes enrichies ont les mêmes données exactes que l'API officielle.
-
Remplacement : Vous pouvez remplacer
https://geo.api.gouv.frparhttps://2mnservices.alwaysdata.netdans vos apps sans aucune modification de code !
🚀 Utilisation
javascript
// Avant (API Geo Gouv)
const response = await fetch('https://geo.api.gouv.fr/communes?nom=Paris&limit=1');
// Après (Notre API)
const response = await fetch('https://2mnservices.alwaysdata.net/communes?nom=Paris&limit=1');
// Même résultat, même format, 100% compatible !