Pullkin
Asynchronous Python client for receiving Firebase Cloud Messaging (FCM / GCM) push notifications directly over Google's MCS protocol.
Like Alexander Pushkin — except instead of pushing notifications, Pullkin pulls them in.
Pullkin emulates an Android/Chrome MCS client without requiring a headless browser. It is a clean asynchronous redesign inspired by push_receiver and push-receiver.
Features
- Fully
asyncio-native — built onasyncioTLS streams (mtalk.google.com:5228) andhttpx.AsyncClient. - Multi-app support — attach multiple independent
sender_idconnections on onePullkininstance. - Resilient by default — configurable MCS heartbeats, ACK timeouts, exponential-backoff reconnects, and
persistent_iddeduplication. - Encrypted & unencrypted payloads — handles Web Push
http-ecepayloads and direct Android GCM/FCM data messages seamlessly. - Typed Pydantic models — validate and auto-convert incoming notifications directly via handler type annotations (
Message,NotificationData, generics,Optional/unions). - Flexible execution modes — blocking
run(), non-blocking backgroundstart(), or pull-basedlisten_coroutine().
Who Is Pullkin For?
- End-to-end push testing in CI: Verify that your backend actually delivers real Firebase notifications without maintaining emulators or Appium farms.
- Headless automation & OTP/2FA bots: Receive confirmation codes or status pushes from mobile-first services on a Linux server without Chromium or Electron.
- Multi-app push gateways & monitoring: Listen to multiple Firebase
sender_ids from a single Python process and measure real delivery latency. - When NOT to use Pullkin: If you only want to send push notifications from a backend, use
firebase-admin. Pullkin is specifically for receiving pushes as a client device.
Documentation
Full documentation (and LLM-friendly llms.txt) is hosted on Read the Docs:
- Installation
- Quickstart
- Registration & Tokens
- Listening & Lifecycle
- Handlers & Typed Models
- Migration Guide & Breaking Changelog
- API Reference
Installation
pip install pullkin
Requires Python 3.10–3.15.
Quickstart
import asyncio
from pathlib import Path
from pullkin import Pullkin
from pullkin.models import AppCredentials, Message
from pullkin.proto.mcs_proto import DataMessageStanza
SENDER_ID = "123456789012"
APP_ID = "1:123456789012:android:abcdef1234567890"
API_KEY = "AIzaSyExampleApiKey"
FIREBASE_PROJECT_ID = "my-firebase-project"
ANDROID_CERT = "da39a3ee5e6b4b0d3255bfef95601890afd80709"
APP_NAME = "com.example.app"
CREDS_FILE = Path("credentials.json")
pullkin = Pullkin()
@pullkin.on_notification()
async def handle_notification(message: Message, data_message: DataMessageStanza):
print("Notification:", message.notification)
print("Data:", message.data)
@pullkin.on_persistent_id()
async def save_persistent_id(sender_id: str, persistent_id: str):
# Persist IDs to avoid re-receiving already processed messages after restart
print(f"[{sender_id}] persistent_id={persistent_id}")
async def get_credentials() -> AppCredentials:
if CREDS_FILE.exists():
return AppCredentials.model_validate_json(CREDS_FILE.read_text(encoding="utf-8"))
credentials = await pullkin.register(
sender_id=SENDER_ID,
app_id=APP_ID,
api_key=API_KEY,
firebase_project_id=FIREBASE_PROJECT_ID,
android_cert=ANDROID_CERT,
app_name=APP_NAME,
)
CREDS_FILE.write_text(credentials.model_dump_json(indent=2), encoding="utf-8")
return credentials
async def main():
credentials = await get_credentials()
print("Device token:", credentials.token)
await pullkin.add_app(sender_id=SENDER_ID, credentials=credentials)
try:
await pullkin.run()
finally:
await pullkin.stop()
if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
pass
Note on tokens: Always read the device registration token via
credentials.token(notcredentials.fcm.token). By default,register(..., web_push=False)skips Web Push registration and returns an Android GCM token, socredentials.fcmisNone. See Registration & Tokens for details.
Metadata
Release files for pullkin 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pullkin-1.0.0.tar.gz | 49.5 kB | Without provenance | Details for pullkin-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pullkin-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for pullkin-1.0.0-py3-none-any.whl |
Total release size: 94.0 kB
Release files / pullkin-1.0.0.tar.gz
| Download URL | pullkin-1.0.0.tar.gz |
|---|---|
| Size | 49.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91e015ae42e4b0a3d136602f9e0c5d1a015c8ca2d3e4a92a1e92f9dd95b21dd0
|
|
BLAKE2b-256 checksum How to use checksums |
3d8d54779d9ba110f6bb05598b17189ed2a88f555a198464019d8ebf4b3e09e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / pullkin-1.0.0-py3-none-any.whl
| Download URL | pullkin-1.0.0-py3-none-any.whl |
|---|---|
| Size | 44.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b5ee4fde74e71da53276b26f0fbc4ba9b185b688ae446d78b2fa8cbcc01581f1
|
|
BLAKE2b-256 checksum How to use checksums |
533c08be67b3fd63965ad48f460ee506d70a85dff37fa2a586fd79c4c558dbd2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for pullkin 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.