Welcome to stream-python’s documentation!

Contents:

stream package

Submodules

stream.client module

class stream.client.StreamClient(api_key, api_secret, app_id, version='v1.0', timeout=3.0, base_url=None)[source]

Bases: object

base_url = 'https://getstream.io/api/'
delete(*args, **kwargs)[source]

Shortcut for make request

feed(feed_slug, user_id)[source]

Returns a Feed object

Parameters:
  • feed_slug – the slug of the feed
  • user_id – the user id
get(*args, **kwargs)[source]

Shortcut for make request

get_default_params()[source]

Returns the params with the API key present

get_full_url(relative_url)[source]
get_user_agent()[source]
post(*args, **kwargs)[source]

Shortcut for make request

raise_exception(result, status_code)[source]

Map the exception code to an exception class and raise it If result.exception and result.detail are available use that Otherwise just raise a generic error

stream.exceptions module

exception stream.exceptions.ApiKeyException(error_message, status_code=None)[source]

Bases: stream.exceptions.StreamApiException

Raised when there is an issue with your Access Key

code = 2
status_code = 401
exception stream.exceptions.CustomFieldException(error_message, status_code=None)[source]

Bases: stream.exceptions.StreamApiException

Raised when there are missing or misconfigured custom fields

code = 5
status_code = 400
exception stream.exceptions.FeedConfigException(error_message, status_code=None)[source]

Bases: stream.exceptions.StreamApiException

Raised when there are missing or misconfigured custom fields

code = 6
status_code = 400
exception stream.exceptions.InputException(error_message, status_code=None)[source]

Bases: stream.exceptions.StreamApiException

Raised when you send the wrong data to the API

code = 4
status_code = 400
exception stream.exceptions.SignatureException(error_message, status_code=None)[source]

Bases: stream.exceptions.StreamApiException

Raised when there is an issue with the signature you provided

code = 3
status_code = 401
exception stream.exceptions.SiteSuspendedException(error_message, status_code=None)[source]

Bases: stream.exceptions.StreamApiException

Raised when the site requesting the data is suspended

code = 7
status_code = 401
exception stream.exceptions.StreamApiException(error_message, status_code=None)[source]

Bases: exceptions.Exception

code = 1
stream.exceptions.get_exception_dict()[source]
stream.exceptions.get_exceptions()[source]

stream.feed module

class stream.feed.Feed(client, feed_slug, user_id, token)[source]

Bases: object

add_activities(activity_list)[source]

Adds a list of activities to the feed

Parameters:activity_list – a list with the activity data dicts

Example:

activity_data = [
    {'actor': 1, 'verb': 'tweet', 'object': 1},
    {'actor': 2, 'verb': 'watch', 'object': 2},
]
result = feed.add_activities(activity_data)
add_activity(activity_data)[source]

Adds an activity to the feed, this will also trigger an update to all the feeds which follow this feed

Parameters:activity_data – a dict with the activity data

Example:

activity_data = {'actor': 1, 'verb': 'tweet', 'object': 1}
activity_id = feed.add_activity(activity_data)
add_to_signature(recipients)[source]

Takes a list of recipients such as [‘user:1’, ‘user:2’] and turns it into a list with the tokens included [‘user:1 token’, ‘user:2 token’]

follow(target_feed_slug, target_user_id)[source]

Follows the given feed

Parameters:
  • target_feed_slug – the slug of the target feed
  • target_user_id – the user id
followers(offset=0, limit=25, feeds=None)[source]

Lists the followers for the given feed

following(offset=0, limit=25, feeds=None)[source]

List the feeds which this feed is following

get(**params)[source]

Get the activities in this feed

Example:

# fast pagination using id filtering
feed.get(limit=10, id_lte=100292310)

# slow pagination using offset
feed.get(limit=10, offset=10)
remove_activity(activity_id=None, foreign_id=None)[source]

Removes an activity from the feed

Parameters:activity_id – the activity id to remove from this feed

(note this will also remove the activity from feeds which follow this feed) :param foreign_id: the foreign id you provided when adding the activity

unfollow(target_feed_slug, target_user_id)[source]

Unfollow the given feed

stream.signing module

stream.signing.b64_encode(s)[source]
stream.signing.sign(api_secret, feed_id)[source]

Base64 encoded sha1 signature

Parameters:
  • api_secret – the api secret
  • feed_id – the feed_id to sign (commonly a feed id such as user1)
Example::
signature = sign(‘secret’, ‘user1’)

stream.tests module

stream.utils module

stream.utils.validate_feed_id(feed_id)[source]

Validates the input is in the format of user:1

Parameters:feed_id – a feed such as user:1

Raises ValueError if the format doesnt match

stream.utils.validate_feed_slug(feed_slug)[source]

Validates the feed slug falls into w

stream.utils.validate_user_id(user_id)[source]

Validates the user id falls into w

Module contents

stream.connect(api_key=None, api_secret=None, app_id=None, version='v1.0', timeout=3.0)[source]

Returns a Client object

Parameters:
  • api_key – your api key or heroku url
  • api_secret – the api secret
  • app_id – the app id (used for listening to feed changes)

Indices and tables