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.3.0.tar.gz (9.0 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.3.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: permisapi_client-0.3.0.tar.gz
  • Upload date:
  • Size: 9.0 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.3.0.tar.gz
Algorithm Hash digest
SHA256 741efc31c19e3d920ad8cbc82109407b5f70c678696704a6ffcd8a56dd3bad86
MD5 36f100710ae0a2e95b09c12198e9c444
BLAKE2b-256 cecd7c42a38f2fb696fdce03b99f69a1fce725aee4e066ecf7a43ea3a6b58584

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for permisapi_client-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b6b69b4efe8d324ab452c66cede7d98ea978e0f8e077563cc447254439ed39af
MD5 8ce1326f3b73f09d1c2d64f5e284c786
BLAKE2b-256 877aa2221737d6174a30111d2051a3eccde84a8e92bcb4d04c4445694a6932f9

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