Skip to main content

Client Python officiel pour PermisAPI : permis de construire France en API REST.

Project description

permisapi-client

Client Python officiel pour PermisAPI : accede aux 311k+ permis de construire France via une API REST moderne.

Installation

pip install permisapi-client

Quickstart

from permisapi_client import PermisAPI

client = PermisAPI(api_key="pk_live_...")  # obtenue sur https://permisapi.fr/#pricing

# Liste
data = client.permits.list(dep_code="75", limit=10)
for permit in data["items"]:
    print(permit["num_pa"], permit["adr_localite_ter"])

# Recherche geographique (PostGIS)
nearby = client.permits.near(lat=48.85, lng=2.35, radius_m=500)

# Detail
permit = client.permits.get("PC 075 115 24 B0001")

# Stats par commune
stats = client.stats.commune("75115")
print(stats["total"], stats["granted"])

# Itere sur toutes les pages
for p in client.permits.iter_all(dep_code="75"):
    print(p["num_pa"])

Cross-ref Pro+ (DVF, Score MDB, PLU, Géorisques)

# Top 5 transactions DVF voisines (5 ans glissants)
dvf = client.permits.dvf("PC07404021K1", limit=5)
for m in dvf["matches"]:
    print(m["valeur_fonciere"], "EUR a", m["distance_m"], "m")

# Score Opportunite Marchand de Biens v0.1 (note 0-100 + tier)
score = client.permits.score_mdb("PC07404021K1")
print(f"Score: {score['score']}/100 ({score['tier']})")

# Zonage urbanisme PLU (constructible vs agricole vs naturelle)
plu = client.permits.plu("PC07404021K1")
if plu["has_plu"]:
    z = plu["zonage"]
    print(f"Zone {z['code']} - constructible: {z['constructible']}")

# Georisques BRGM (inondation, seisme, argile, ICPE proches)
risks = client.permits.risks("PC07404021K1")
print(f"Risk score: {risks['risk_score']}/100 ({risks['risk_tier']})")
for risk in risks["risks"]:
    print(f"- {risk['label']} (PPR: {risk['has_ppr']})")

# Feedback sur le Score MDB (alimente le training V1.0 ML)
client.permits.score_feedback(
    num_pa="PC07404021K1",
    score_received=78,
    tier_received="high",
    useful=False,
    accuracy="too_high",
    comment="SCI familiale, pas un MDB. Le signal SCI=90 est trop generique.",
    recommendation="Distinguer SCI familiale via volume de permis.",
)

Export bulk CSV (Business+)

# Cap par defaut : 100k Business / 1M Enterprise
csv_bytes = client.permits.export(
    dep_code="33",
    permit_type="PC_LOGEMENT",
    date_from="2024-01-01",
    max_rows=5000,
)
with open("bordeaux.csv", "wb") as f:
    f.write(csv_bytes)

MCP server (Claude / ChatGPT / Cursor)

Le serveur MCP officiel (package separe permisapi-mcp) permet a Claude Desktop, Cursor et Windsurf d'appeler PermisAPI en langage naturel :

pip install permisapi-mcp

Configure ta cle dans le client MCP, puis demande directement :

"Liste les permis de logement deposes a Bordeaux ce mois avec un score MDB > 70"

Voir permisapi.fr/mcp pour le setup complet.

Async

import asyncio
from permisapi_client import AsyncPermisAPI

async def main():
    async with AsyncPermisAPI(api_key="pk_live_...") as client:
        data = await client.permits.list(dep_code="75")
        async for p in client.permits.iter_all(dep_code="75"):
            print(p["num_pa"])

asyncio.run(main())

Alertes webhook

alert = client.alerts.create(
    name="Paris 18e renovations",
    center_lat=48.88,
    center_lng=2.35,
    radius_km=3,
    permit_types=["PC_LOGEMENT"],
    webhook_url="https://tonapp.fr/permisapi-hook",
)
# Le webhook_secret n'est renvoye QU'ICI. Stocke-le pour verifier les HMAC.
print(alert["webhook_secret"])

Gestion des erreurs

from permisapi_client import (
    PermisAPI,
    PermisAPIRateLimited,
    PermisAPIQuotaExceeded,
    PermisAPIUnauthorized,
)

try:
    client.permits.list()
except PermisAPIUnauthorized:
    print("Cle API invalide")
except PermisAPIQuotaExceeded as e:
    print(f"Quota mensuel atteint, retry dans {e.retry_after}s")
except PermisAPIRateLimited as e:
    print(f"Burst limit, retry dans {e.retry_after}s")

Licence

MIT. Source : SDES, base Sitadel, data.gouv.fr (Licence Ouverte Etalab).

Liens

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

permisapi_client-0.6.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

permisapi_client-0.6.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file permisapi_client-0.6.0.tar.gz.

File metadata

  • Download URL: permisapi_client-0.6.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for permisapi_client-0.6.0.tar.gz
Algorithm Hash digest
SHA256 bd8c91a04c9832379c72f5764204212e19fbd48457d1facc8799086462a3077e
MD5 fbee0ce1537e57fc8f7defef5cc98b15
BLAKE2b-256 052c483388abc6a36f6c5f7c10f62de81915395de3df547f11bf4c7a9ef086a1

See more details on using hashes here.

File details

Details for the file permisapi_client-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for permisapi_client-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c573b9f4c0ec7e5aedeafbe12804a52d8418d319f60014c56eb31bf86704ebbd
MD5 508b1aff28919463d59c302879c2055a
BLAKE2b-256 e9eb77e5842f47ad653266bd73d90184aba5a0eb4417f0c05571a6abc44649c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page