Python API client for Scaledrone Realtime Messaging Service
Switch branches/tags
Nothing to show
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
scaledrone Make API use JSON + add new API enpoints Jan 13, 2018
.gitignore Removed python-version from git Jan 23, 2016
README.md Fix room_members_list docs Mar 7, 2018
setup.cfg Added setup.cfg Jan 23, 2016
setup.py Update setup Jan 14, 2018
test.py Make API use JSON + add new API enpoints Jan 13, 2018

README.md

Scaledrone Python API client

Official Scaledrone Python API client. This is a wrapper around the REST API.

Installation

pip install scaledrone

Usage

Create a new instance of Scaledrone passing it the channel_id and secret_key that you can find from the Scaledrone dashboard channel's page.

from scaledrone import Scaledrone

drone = Scaledrone('channel_id', 'secret_key')

Publishing a message

room = 'notifications'
message = {'foo': 'bar'}
response = drone.publish(room, message)

Publishing a message to multiple rooms

rooms = ['room1', 'room2']
message = {'foo': 'bar'}
response = drone.publish(rooms, message)

Getting the number of users in a channel

response = drone.channel_stats()
print(response.json()) # {users_count: 10}

Getting the list of users from all rooms

response = drone.members_list()
print(response.json()) # ["user1", "user2"]

Getting the list of rooms that have users in them

response = drone.rooms_list()
print(response.json()) # ["room1", "room2"]

Getting the list of users in a room

response = drone.room_members_list('my-room')
print(response.json()) # ["user3", "user4"]

Getting the list of rooms and their members

response = drone.all_room_members_list()
print(response.json()) # {"room1": ["user1", "user2"], "room2": ["user1"]}

API Response

The API returns Requests responses.

Testing

python test.py

Uploading a new PyPi version

Update setup.py with the new version. Then upload it:

python setup.py sdist upload -r pypi

Changelog

  • 0.2.0 Implemented latest REST API endpoints. Send data as JSON.
  • 0.1.0 Initial version