{"library":"posthoganalytics","title":"PostHog Python SDK","description":"The official Python SDK for PostHog, enabling integration into any Python application for product analytics, feature flags, and session recording. It's actively maintained with frequent minor releases, often addressing specific framework integrations or new AI/LLM-related tracking features.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install posthoganalytics"],"cli":null},"imports":["import posthoganalytics","from posthoganalytics import Posthog"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nimport posthoganalytics\n\n# Initialize PostHog client\nposthoganalytics.init(\n    os.environ.get('POSTHOG_API_KEY', 'phc_YOUR_API_KEY'),\n    host=os.environ.get('POSTHOG_HOST', 'https://app.posthog.com')\n)\n\n# Capture an event\nposthoganalytics.capture(\n    'test-user-id',\n    'my_event', \n    {'property_key': 'property_value'}\n)\n\n# Identify a user\nposthoganalytics.identify(\n    'test-user-id',\n    {'email': 'test@example.com', 'name': 'Test User'}\n)\n\n# Ensure all events are sent before exiting\nposthoganalytics.flush()\nprint('PostHog events captured and flushed.')\n","lang":"python","description":"This quickstart demonstrates how to initialize the PostHog client, capture a custom event, and identify a user. It's crucial to call `posthoganalytics.flush()` in short-lived scripts to ensure events are sent before the program terminates. For long-running applications, `flush()` is handled automatically at intervals.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"6.9.3","pypi_latest":"7.14.2","is_stale":true,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":2.6,"avg_import_s":0.7,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"posthoganalytics","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.67,"mem_mb":12.2,"disk_size":"24.3M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"posthoganalytics","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.7,"import_time_s":0.49,"mem_mb":12.2,"disk_size":"25M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"posthoganalytics","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.86,"mem_mb":13.6,"disk_size":"27.0M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"posthoganalytics","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.6,"import_time_s":0.74,"mem_mb":13.6,"disk_size":"27M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"posthoganalytics","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.77,"mem_mb":13.3,"disk_size":"18.7M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"posthoganalytics","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.3,"import_time_s":0.78,"mem_mb":13.3,"disk_size":"19M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"posthoganalytics","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.74,"mem_mb":13.7,"disk_size":"18.4M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"posthoganalytics","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.4,"import_time_s":0.71,"mem_mb":13.7,"disk_size":"19M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"posthoganalytics","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.65,"mem_mb":13.3,"disk_size":"23.4M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"posthoganalytics","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3,"import_time_s":0.6,"mem_mb":13.3,"disk_size":"24M"}]}}