activities(activities)

Updates all supplied activities on the getstream-io api

parameter type description
activities array

list of activities to update

Returns

Promise

activities(activities, callback)

Adds the given activities to the feed and calls the specified callback

parameter type description
activities Array

Array of activities to add

callback requestCallback

Callback to call on completion

Returns

Promise :

XHR request object

activity(activity, callback)

Adds the given activity to the feed and calls the specified callback

parameter type description
activity object

The activity to add

callback requestCallback

Callback to call on completion

Returns

Promise :

Promise object

apiKey(apiKey, [apiSecret], [appId], [options])

Initialize a client

parameter type description
apiKey string

the api key

apiSecret [string]

the api secret

appId [string]

id of the app

options [object]

additional options

options.location [string]

which data center to use

options.expireTokens [boolean] (default false)

whether to use a JWT timestamp field (i.e. iat)

Examples

<caption>initialize is not directly called by via stream.connect, ie:</caption>
stream.connect(apiKey, apiSecret)
<caption>secret is optional and only used in server side mode</caption>
stream.connect(apiKey, null, appId);

appId(callback)

Subscribes to any changes in the feed, return a promise

parameter type description
callback function

Callback to call on completion

Returns

Promise :

Promise object

Examples

feed.subscribe(callback).then(function(){
		console.log('we are now listening to changes');
});

client(client, feedSlug, userId, [token])

Initialize a feed object

parameter type description
client StreamClient

The stream client this feed is constructed from

feedSlug string

The feed slug

userId string

The user id

token [string]

The authentication token

description

Get the current user agent

Returns

string :

current user agent

event(event, callback)

Support for global event callbacks This is useful for generic error and loading handling

parameter type description
event string

Name of the event

callback function

Function that is called when the event fires

Examples

client.on('request', callback);
client.on('response', callback);

feedId(feedSlug, userId)

Returns a token that allows read and write operations

parameter type description
feedSlug string

The feed slug to get a read only token for

userId string

The user identifier

Returns

string :

token

Examples

client.getReadWriteToken('user', '1');

feedId(feedSlug, userId)

Returns a token that allows only read operations

parameter type description
feedSlug string

The feed slug to get a read only token for

userId string

The user identifier

Returns

string :

token

Examples

client.getReadOnlyToken('user', '1');

identifier(activityId, callback)

Removes the activity by activityId

parameter type description
activityId string

Identifier of activity to remove

callback requestCallback

Callback to call on completion

Returns

Promise :

Promise object

Examples

feed.removeActivity(activityId);
feed.removeActivity({'foreign_id': foreignId});

key([key])

Remove one or more event handlers

parameter type description
key [string]

Name of the handler

Examples

client.off() removes all handlers
client.off(name) removes the specified handler

options(options, callback)

Reads the feed

parameter type description
options object

Additional options

callback requestCallback

Callback to call on completion

Returns

Promise :

Promise object

Examples

feed.get({limit: 10, id_lte: 'activity-id'})
feed.get({limit: 10, mark_seen: true})

options(options, callback)

List the followers of this feed

parameter type description
options object

Additional options

options.filter string

Filter to apply on search operation

callback requestCallback

Callback to call on completion

Returns

Promise :

Promise object

Examples

feed.followers({limit:10, filter: ['user:1', 'user:2']}, callback);

options(options, callback)

List which feeds this feed is following

parameter type description
options object

Additional options

options.filter string

Filter to apply on search operation

callback requestCallback

Callback to call on completion

Returns

Promise :

Promise object

Examples

feed.following({limit:10, filter: ['user:1', 'user:2']}, callback);

options(feedSlug, userId, [token], [siteId], [options])

Returns a feed object for the given feed id and token

parameter type description
feedSlug string

The feed slug

userId string

The user identifier

token [string]

The token

siteId [string]

The site identifier

options [object]

Additional function options

options.readOnly [boolean]

A boolean indicating whether to generate a read only token for this feed

Returns

StreamFeed

Examples

client.feed('user', '1', 'token2');

process(apiKey, [apiSecret], [appId], [options])

Create StreamClient

parameter type description
apiKey string

API key

apiSecret [string]

API secret (only use this on the server)

appId [string]

Application identifier

options [object]

Additional options

options.location [string]

Datacenter location

Returns

StreamClient :

StreamClient

Examples

<caption>Basic usage</caption>
stream.connect(apiKey, apiSecret);
<caption>or if you want to be able to subscribe and listen</caption>
stream.connect(apiKey, apiSecret, appId);
<caption>or on Heroku</caption>
stream.connect(streamURL);
<caption>where streamURL looks like</caption>
"https://thierry:pass@gestream.io/?app=1"

StreamClient([errors], response, body)

parameter type description
errors [object]
response object
body object

StreamClient

StreamClient

Client to connect to Stream api

StreamFeed

Manage api calls for specific feeds The feed object contains convenience functions such add activity, remove activity etc

updateActivities(activity)

Updates one activity on the getstream-io api

parameter type description
activity object

The activity to update

Returns

Promise

uri(targetUrl, userId, events)

Creates a redirect url for tracking the given events in the context of an email using Stream's analytics platform. Learn more at getstream.io/personalization

parameter type description
targetUrl string

Target url

userId string

User id to track

events array

List of events to track

Returns

string :

The redirect url

validateFeedSlug(targetSlug, targetUserId, options, callback)

Follows the given target feed

parameter type description
targetSlug string

Slug of the target feed

targetUserId string

User identifier of the target feed

options object

Additional options

options.activityCopyLimit number

Limit the amount of activities copied over on follow

callback requestCallback

Callback to call on completion

Returns

Promise :

Promise object

Examples

feed.follow('user', '1');
feed.follow('user', '1', callback);
feed.follow('user', '1', options, callback);

validateFeedSlug(targetSlug, targetUserId, callback)

Unfollow the given feed

parameter type description
targetSlug string

Slug of the target feed

targetUserId string

[description]

callback requestCallback

Callback to call on completion

Returns

object :

XHR request object

Examples

feed.unfollow('user', '2', callback);