{"library":"pyfcm","title":"PyFCM - Firebase Cloud Messaging Client","description":"PyFCM is an active Python client library for Firebase Cloud Messaging (FCM), currently at version 2.1.0. It provides a convenient interface for sending push notifications and data messages to Android, iOS, and web clients. The library's release cadence is tied to significant FCM API changes, ensuring compatibility with the latest Firebase services.","language":"python","status":"active","last_verified":"Mon May 18","install":{"commands":["pip install pyfcm"],"cli":null},"imports":["from pyfcm import FCMNotification"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom pyfcm import FCMNotification\n\n# For FCM v1 API, authentication uses a service account JSON file.\n# Set GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of your service account JSON file.\n# Ensure your service account has 'Firebase Cloud Messaging API' enabled and 'Firebase Cloud Messaging Sender' role.\n# A project_id is also required.\n\nservice_account_path = os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', '')\nproject_id = os.environ.get('FCM_PROJECT_ID', 'your-project-id') # Replace with your Firebase Project ID\nfcm_token = os.environ.get('FCM_DEVICE_TOKEN', 'YOUR_DEVICE_REGISTRATION_ID') # Replace with a device token\n\nif not service_account_path:\n    print(\"WARNING: GOOGLE_APPLICATION_CREDENTIALS environment variable not set. Using dummy service_account_file for example.\")\n    # For a runnable example without actual auth, you might provide a non-existent path,\n    # but real usage *requires* a valid service account file.\n    # For testing, ensure you have a valid service_account_path and project_id.\n\n# Initialize FCMNotification with service account file and project ID for FCM v1 API\ntry:\n    push_service = FCMNotification(service_account_file=service_account_path, project_id=project_id)\n\n    # Send a notification message to a single device\n    notification_title = \"Test Notification\"\n    notification_body = \"This is a test message from PyFCM!\"\n\n    result = push_service.notify(\n        fcm_token=fcm_token,\n        notification_title=notification_title,\n        notification_body=notification_body\n    )\n\n    print(\"Notification sent. Result:\", result)\n\n    # Send a data message (handled by the client app)\n    data_payload = {\"score\": \"100\", \"time\": \"10:00\"}\n    data_result = push_service.notify(\n        fcm_token=fcm_token,\n        data_payload=data_payload\n    )\n    print(\"Data message sent. Result:\", data_result)\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to send both notification and data messages to a single FCM device using PyFCM's `FCMNotification` class. It leverages the FCM v1 API, requiring a Firebase service account JSON file (specified via `GOOGLE_APPLICATION_CREDENTIALS` environment variable) and your Firebase project ID for authentication. The `notify()` method is the unified entry point for sending messages.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-18","installed_version":"2.1.0","pypi_latest":"2.1.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":5.7,"avg_import_s":1.11,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pyfcm","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.94,"mem_mb":14.7,"disk_size":"50.7M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pyfcm","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":6.5,"import_time_s":0.65,"mem_mb":14.7,"disk_size":"53M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pyfcm","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.29,"mem_mb":16.6,"disk_size":"55.1M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pyfcm","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":5.5,"import_time_s":1.21,"mem_mb":16.6,"disk_size":"57M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pyfcm","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.35,"mem_mb":19.2,"disk_size":"46.6M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pyfcm","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":4.3,"import_time_s":1.35,"mem_mb":19.2,"disk_size":"49M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pyfcm","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.35,"mem_mb":20.2,"disk_size":"46.0M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pyfcm","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":4.5,"import_time_s":1.36,"mem_mb":20.2,"disk_size":"48M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pyfcm","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":0.83,"mem_mb":14.5,"disk_size":"51.6M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pyfcm","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":7.8,"import_time_s":0.81,"mem_mb":14.5,"disk_size":"54M"}]}}