Skip to content

About

Python API client for Scaledrone Realtime Messaging Service

Resources

Stars

4 stars

Watchers

2 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Python API client for Scaledrone Realtime Messaging Service

Resources

Stars

4 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages