Class: StreamClient

StreamClient

new StreamClient()

Client to connect to Stream api
Source:

Methods

feed(feedSlug, userId, tokenopt, siteIdopt, optionsopt) → {Feed}

Returns a feed object for the given feed id and token
Parameters:
Name Type Attributes Description
feedSlug string The feed slug
userId string The user identifier
token string <optional>
The token
siteId string <optional>
The site identifier
options object <optional>
Additional function options
Properties
Name Type Attributes Description
readOnly boolean <optional>
A boolean indicating whether to generate a read only token for this feed
Source:
Returns:
Type
Feed
Example
client.feed('user', '1', 'token2');

getReadOnlyToken(feedSlug, userId) → {string}

Returns a token that allows only read operations
Parameters:
Name Type Description
feedSlug string The feed slug to get a read only token for
userId string The user identifier
Source:
Returns:
token
Type
string
Example
client.getReadOnlyToken('user', '1');

getReadWriteToken(feedSlug, userId) → {string}

Returns a token that allows read and write operations
Parameters:
Name Type Description
feedSlug string The feed slug to get a read only token for
userId string The user identifier
Source:
Returns:
token
Type
string
Example
client.getReadWriteToken('user', '1');

intialize(apiKey, apiSecretopt, appIdopt, options)

Initialize a client
Parameters:
Name Type Attributes Description
apiKey string the api key
apiSecret string <optional>
the api secret
appId string <optional>
id of the app
options object additional options
Properties
Name Type Description
location string which data center to use
Source:
Examples

initialize is not directly called by via stream.connect, ie:

stream.connect(apiKey, apiSecret)

secret is optional and only used in server side mode

stream.connect(apiKey, null, appId);

off(keyopt)

Remove one or more event handlers
Parameters:
Name Type Attributes Description
key string <optional>
Name of the handler
Source:
Example
client.off() removes all handlers
client.off(name) removes the specified handler

on(event, callback)

Support for global event callbacks This is useful for generic error and loading handling
Parameters:
Name Type Description
event string Name of the event
callback function Function that is called when the event fires
Source:
Example
client.on('request', callback);
client.on('response', callback);