Skip to main content

FlyPush Python server SDK - send push notifications from your backend

Project description

flypush (Python)

FlyPush Python server SDK — send push notifications from your backend.

Installation

pip install flypush

Zero dependencies — uses only the Python standard library.

Quick start

from flypush import FlyPush
from flypush.models import SendOptions, NotificationTarget

client = FlyPush(api_key="fp_your_api_key")

# Send to all devices
client.notifications.send(SendOptions(
    to=NotificationTarget(type="all"),
    title="Hello!",
    body="Your order has shipped.",
    data={"order_id": "abc123"},
))

# Send to a topic
client.notifications.send(SendOptions(
    to=NotificationTarget(type="topic", topic="breaking-news"),
    title="Breaking News",
    body="Something happened.",
))

# Send to a specific device token
client.notifications.send(SendOptions(
    to=NotificationTarget(type="device", token="device_token_here"),
    title="Personal alert",
    body="Just for you.",
))

Batch send

from flypush.models import BatchItem

client.notifications.send_batch([
    BatchItem(to=NotificationTarget(type="device", token="tok1"), title="Hi Alice", body="..."),
    BatchItem(to=NotificationTarget(type="device", token="tok2"), title="Hi Bob",   body="..."),
])

Device management

from flypush.models import RegisterOptions

device = client.devices.register(RegisterOptions(
    platform="IOS",
    token="apns_token",
    user_id="user_123",
    tags=["premium"],
))

client.devices.update(device["id"], tags=["premium", "beta"])
client.devices.subscribe(device["id"], "sports")
client.devices.unregister(device["id"])

Error handling

from flypush import FlyPushError

try:
    client.notifications.send(...)
except FlyPushError as e:
    print(e.status_code, e.code, str(e))

The SDK automatically retries 5xx errors up to 3 times (2s, 4s, 8s backoff).

Requirements

Python 3.9+, no third-party dependencies.

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

flypush-0.1.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flypush-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file flypush-0.1.0.tar.gz.

File metadata

  • Download URL: flypush-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for flypush-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c6f104e6ea9d9c41ced82422a242334beb7ea31662adf29eb3e55a8fae88793e
MD5 c4463d5dfd15d063ec4d63489fd6f64f
BLAKE2b-256 8a9440db3c7305610b0541aa816ed03b9f4fab21d960e8a21bcc6f1372509455

See more details on using hashes here.

File details

Details for the file flypush-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: flypush-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for flypush-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a3cee893bec18c1dace088851c4b57a1c2301837b771d74ad57c57b20a74431
MD5 45ae144048e1de259c6fbc061672eebb
BLAKE2b-256 d88e1fcc9f5d880a940705ccde3eec78f4cc679b79d6f8873ea4b166f5f35d50

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