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"])

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.1.0.tar.gz (7.2 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.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for permisapi_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 75e05055e6508267b7a4d51a22a834ee5933754691a8406b0def53dcaaca3862
MD5 e75c74694db8a37fb99c63bc5b3204b4
BLAKE2b-256 189a019b8bf89c7bdf833908494f2bc59196690699acb2aa5269317e6faa2e6c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for permisapi_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90b1917c686340033b5d6fec08ff35edec3472677e0a3af82b3c819d471a0f37
MD5 748975811798159ffeca651371775e4b
BLAKE2b-256 570cda042b14b78882fa7958a80f83c05d91377625a5d8ef74918f3b63a96018

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