Python Server SDK

Installation

The Beams Python server SDK is available on PyPi here.

You can install this SDK by using pip:

bash

1
$ pip install pusher_push_notifications

Reference

class PushNotifications

Constructs a new Beams client instance using your instance id and secret key (you can get these from the dashboard)

Arguments

  • instance_id(string): The unique identifier for your Push notifications instance. This can be found in the dashboard under "keys".
  • secret_key(string): The secret key your server will use to access your Beams instance. This can be found in the dashboard under "keys".

Example

Python

1
2
3
4
pn_client = PushNotifications(
    instance_id='YOUR_INSTANCE_ID_HERE',
    secret_key='YOUR_SECRET_KEY_HERE',
)

PushNotifications.publish

Sends broadcast notifications to groups of subscribed devices using Interests

Arguments

  • interests(list<string> | Min length=1, Max length=100): List of interests to send the push notification to, ranging from 1 to 100 per publish request. See Interests
  • publish_body(dictionary): A dictionary containing the publish request body. See publish API reference

Returns
A dictionary containing the publish response body. See publish API reference

Example

Python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
response = pn_client.publish(
  interests=['hello'],
  publish_body={
    'apns': {
      'aps': {
        'alert': 'Hello!',
      },
    },
    'fcm': {
      'notification': {
        'title': 'Hello',
        'body': 'Hello, world!',
      },
    },
  },
)

print(response['publishId'])

Did you find this document useful?

We are always striving to create the most accurate and informative docs as possible. If there is something especially wrong (or right) here then please let us know.