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.2.0.tar.gz (8.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.2.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: permisapi_client-0.2.0.tar.gz
  • Upload date:
  • Size: 8.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.2.0.tar.gz
Algorithm Hash digest
SHA256 38ef59dec6c8e053d7b7f871d62dfb211402bcd1e7bdc9437bc99c3cca0eadcf
MD5 f1bc5c27f2e196b3c8cbe446fd3f3940
BLAKE2b-256 83866eccd71a3649b2d79f53bbd37577fb5da3c493e6cba31dd5d9c36f92a079

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for permisapi_client-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 40ca1cbd57d98d2ee13c92ae368c36f3eaa14caecc8df9cc66c2d7efbf9a99de
MD5 732a7c7789b47b6e6e4586e818ebf4f1
BLAKE2b-256 de16ef2f04e10bf8e047d7bfc295e646c133a9e99aacb26633a95816b351fc0b

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