- API Basics
- Endpoints
- Advanced
API Basics
Introduction to the REST API
Welcome to Stream's REST API documentation!
Please note
The REST documentation is recommended for advanced users that want to write their own API clients.
Have a look below at the official clients, framework integrations, and community-contributed libraries.
Always feel free to get in touch at support@getstream.io if you have questions.
Are you looking for a ready-made client or framework library?
If you're looking to get started quickly, official clients are available for a whole host of languages including Ruby, JavaScript, Python, Java, PHP, Go, C# and more. Framework integrations are also available for Rails, Django, and Laravel.
First steps
1. Complete 'Getting Started'
Before you start writing your client, we recommend that you complete the getting started tutorial. It explains the core API concepts, and allows you to get familiar with Stream.
2. Review Official Clients
Reviewing the official Stream API clients is a great source of inspiration for writing your own client.
A good starting point is the official JavaScript client as it runs its test suite in the browser.
With the official JS client, you can see the tests and examine how the API requests are structured in your browser's network tab.
To see the tests, simply clone the stream-js package, and open test/browser/test.html
in your browser.
You can review all of our open-source libraries at the official Stream GitHub page.
3. Browse Documentation
Stream's API consists of two authentication methods and eight REST endpoints.
Be sure to review the basics.
Authentication Methods:
- Application
- Feed
REST Endpoints:
- Activities
- Feed
- Feed Detail
- Followers
- Following
- Following Detail
- Batch Activity Add
- Batch Follow
- Reactions
- Reactions Detail
- Reactions pagination
- Open Graph
- Collection
- Collection Detail
- Batch Collection
- Files
- Images
- User
- User Detail
Get stuck? No worries at all, feel free to contact support at any time.
Basics
Base API URL: https://api.stream-io-api.com/api/v1.0/
Location Support
The Stream API is currently available in 3 regions:
- us-east
- eu-west
- singapore
Examples:
https://us-east-api.stream-io-api.com/api/v1.0/
https://eu-west-api.stream-io-api.com/api/v1.0/
https://singapore-api.stream-io-api.com/api/v1.0/
Common Parameters
The following common GET parameters should be sent for every request:
Name | Type | Description |
---|---|---|
api_key | string | YOUR_API_KEY |
Note: Every request should also include the appropriate authorization header.
JSON for POST Data
All POST data must be JSON encoded.
This allows you to send complex data structures to the Stream API endpoint!
Authentication
API Keys and Token
Every API request to Stream must include: the API Key of the app performing the request and an authentication token generated using the API Key secret.
Token must be a JWT token including a signature generated with the HS256 algorithm.
You can find more information on JWT at jwt.io/introduction. Libraries to generate JWT are available for most programming languages. The full list is available here. The authentication token must include the correct claims (also called payload). A token valid for a type of request or for a user_id might not be valid for another one. Your application should generate the appropriate token; when using client-side auth, each user should have its own unique token.
Sending an authenticated request
All API requests to Stream must include a query parameter called api_key
with the API Key in use.
Once the token is generated correctly it is used to authenticate a request. This is done by setting two HTTP headers on the request:
Stream-Auth-Type: jwt
Authorization: <token>
Important: Some JWT libraries prefix the generated token with the string "Bearer". This prefix should be removed before sending the request to Stream.
When dealing with authentication tokens, you should keep in mind that tokens are like passwords. Never share tokens with untrusted parties.
Stream uses JWT to provide two types of authentication:
Server-Side Authentication
Requests from a back-end application to the Stream API for a specific single resource use Server-Side Authentication to authenticate requests.
JWT usage for server-side authentication
For server-side authentication, the application should send a token that is signed with the API Secret of the Stream app. This token must include a permission scope compatible to the request that is being performed. Permission scopes scopes are defined using the following fields: resource
, action
and feed_id
.
The resource
field of the JWT payload allows you to define which API endpoints can be accessed, you can pick one of the following:
Resource Name | API Endpoint |
---|---|
activities | Activities Endpoint |
feed | Feed Endpoint |
follower | Following + Followers Endpoint |
* | Allow access to any resource |
The action
field of the JWT payload allows you to define which HTTP verbs are allowed by a request:
Action Name | HTTP Verb(s) |
---|---|
read | GET, OPTIONS, HEAD |
write | POST, PUT, PATCH |
delete | DELETE |
* | The JWT has permission to all HTTP verbs |
The feed_id
field in the JWT payload specifies for which feed/resource the permissions specified before are granted. The value of this field should be a concatenation of the feed group's slug
and the user_id
of the feed instance. For example, if your feed group is called "news" and your user ID is 1234, the resulting concatenation would be "news1234". Similarly to the resource
and action
field, a single *
character will grant the permissions on all feeds.
Token examples
Below are some example tokens for different use cases:
These examples use a fake flat feed called "fake_flat_feed"
// A token which allows every possible action on all feeds. Useful for
// development and server side, but unsuitable for usage on client applications.
{
"resource": "*",
"action": "*",
"feed_id": "*"
}
// the resulting JWT encoded string would look like this:
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyZXNvdXJjZSI6IioiLCJhY3Rpb24iOiIqIiwiZmVlZF9pZCI6IioifQ.FnH6LrB0ORV8Jb8P3Nca1Ks5wdPA0oMEArd7voCHnQo"
// A token which allows reading, modification and deletion of activities on
// the "fake_flat_feed" feed with a user id 123.
{
"resource": "feed",
"action": "*",
"feed_id": "fake_flat_feed123"
}
// the resulting JWT encoded string would look like this:
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyZXNvdXJjZSI6ImZlZWQiLCJhY3Rpb24iOiIqIiwiZmVlZF9pZCI6ImZha2VfZmxhdF9mZWVkMTIzIn0.YF8a4kY2mFaDemx4zhM8PURWbPDIRoeuwHB9lvtoDlU"
// A token which allows reading the followers of the "fake_flat_feed" feed for user 123.
{
"resource": "follower",
"action": "read",
"feed_id": "fake_flat_feed123"
}
// the resulting JWT encoded string would look like this:
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyZXNvdXJjZSI6ImZvbGxvd2VyIiwiYWN0aW9uIjoicmVhZCIsImZlZWRfaWQiOiJmYWtlX2ZsYXRfZmVlZDEyMyJ9.M5p4t6MrZC42yFhm4zu4tuWOuXlfK_WBE2SETTlWHHk"
Client-Side Authentication
Requests from a front-end application to the Stream API to certain endpoints use Client-Side Authentication to authenticate requests.
JWT usage for client-side authentication
When using Stream on web or mobile apps, you can use a different kind of auth that allows you to authenticate users instead of your server-side application. This authentication enforces per-user permission checks.
Client-side auth is selected when a JWT token includes user_id
in the payload. You can include additional fields in the JWT payload as long as they don't overlap with the server-side authentication ones.
A common approach is to have your users authenticate with your app server-side and to provision a user token so that API calls to Stream can be done on their behalf directly on your mobile/web app.
Token example
This example uses the userID "bob_johnson_1"
# The token claims contain only user_id
# {
# "user_id": "bob_johnson_1"
# }
// the resulting JWT encoded string would look like this:
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiYm9iX2pvaG5zb25fMSJ9.wyzuDl1sfQOaBzzJQUiQdz00IP31xmq-nfqBfEAF660"
This example uses the userID "bob_johnson_1"
# The token claims contain user_id and extra fields
# {
# "user_id": "bob_johnson_1",
# "user_group": "admins"
# }
// the resulting JWT encoded string would look like this:
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiYm9iX2pvaG5zb25fMSIsInVzZXJfZ3JvdXAiOiJhZG1pbnMifQ.VQ626qhTrmCsjSQ6FDLaV8EKSJDkrGYJScSHeRji5YU"
Endpoints
Activities
The activities endpoint is located at (enrich)/activities/
Authentication method: Server-Side Authentication
Resource Name: activities
The Activities endpoint can be used to update activity data stored by Stream API (POST) or to retrieve specific activities by either ID or the combination of foreign ID and timestamp (GET).
POST
This is useful when you want to update certain activity metadata used during feed ranking. Activities are updated by foreign_id
. Changing the original time
property of the activity is not allowed.
NAME | TYPE | DESCRIPTION | DEFAULT |
---|---|---|---|
activities | list | A JSON encoded list of activities to update. Maximum length is 100. |
The following example uses your API Secret to generate the JWT encoded string
# the JWT token would be built using a payload similar to:
#{
# "resource": "activities",
# "action": "write",
# "feed_id": "*"
#}
curl -i -X POST -d "{\"activities\":[{\"actor\":\"user:789\",\"verb\":\"post\",\"object\":\"story:abc123\",\"foreign_id\":\"story:123\",\"time\":\"2017-02-23T22:57:07.099Z\",\"message\":\"My new message\"}]}" \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/activities/?api_key=YOUR_API_KEY"
GET
URI parameters
NAME | TYPE | DESCRIPTION |
---|---|---|
enrich | string | If URI contains word "enrich", the response will be enriched. |
Query parameters
NAME | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
ids | string | A comma separated list of activity IDs. Maximum length is 100. | ✓ |
foreign_ids | string | A comma separated list of activity foreign IDs. Maximum length is 100, and must match the length of timestamps . | ✓ |
timestamps | string | A comma separated list of activity timestamps. Maximum length is 100, and must match the length of foreign_ids . | ✓ |
withRecentReactions | boolean | If true activity object will have attribute "latest_reactions" that contains list of recently created reactions | ✓ |
recentReactionsLimit | int | Specify number of reactions in the "latest_reactions" attribute, maximum value is 25. | ✓ |
withOwnReactions | boolean | If true activity object will have attribute "own_reactions" that contains list of reactions created by the user himself. | ✓ |
withReactionCounts | boolean | If true activity object will have attribute "reaction_counts" that contains number of reactions for each kind |
The following example uses your API Secret to generate the JWT encoded string
# the JWT token would be built using a payload similar to:
#{
# "resource": "activities",
# "action": "read",
# "feed_id": "*"
#}
# retrieve by ID
curl -i --request GET \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/activities/?api_key=YOUR_API_KEY&ids=4ef6ee4e-79f1-11e8-8080-8001277e7b5f,ae41abaa-a1fe-4186-861a-bd244fe5997d"
# retrieve by foreign ID + timestamp
curl -i --request GET \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/activities/?api_key=YOUR_API_KEY&foreign_ids=like:2,post:3×tamps=2018-07-08T14:09:36.000000,2018-07-09T20:30:40.000000"
Activity
The activity endpoint is located at activity/
Authentication method: Server-Side Authentication
Resource Name: activities
The Activity endpoint can be used to partially update activity data stored by Stream API.
POST
For updating only parts of one or more activities by changing, adding, or removing fields.
NAME | TYPE | DESCRIPTION | DEFAULT |
---|---|---|---|
changes | list | A JSON encoded list of changes to apply. Maximum length is 100. |
Within every change set it is possible to reference the target fields directly or using the dotted notation ("grandfather.father.child"
), given that it respects the existing hierarchy.
Every value of the set
object will replace the original value, while the ones int the unset
list will be removed from the activity.
NAME | TYPE | DESCRIPTION | DEFAULT | OPTIONAL |
---|---|---|---|---|
id | string | The target activity ID. | ✓ | |
foreign_id | string | The target activity foreign ID (matched with time ). | ✓ | |
time | string | The target activity timestamp (matched with foreign_id ). | ✓ | |
set | object | An object containing the set operations, where keys are the target fields and the values are the values to be set. Maximum 25 top level keys. | ✓ | |
unset | list | A list of strings containing the fields to be removed from the activity. Maximum 25 keys. |
Note: the keys of set
and unset
must not collide.
The following example uses your API Secret to generate the JWT encoded string
# the JWT token would be built using a payload similar to:
#{
# "resource": "activities",
# "action": "*",
# "feed_id": "*"
#}
curl -i -X POST -d "{\"changes\": [{\"id\":\"907a8010-1d84-11e9-9457-9cb6d0925edd\",\"set\":{\"product\":{\"sku\":123,\"name\":\"zoo\"},\"colors.red.hex\":\"FF0000\"},\"unset\":[\"popularity\",\"price.usd\"]}, {\"id\":\"65bca63a-7d61-48e8-be9d-c6665a008196\",\"set\":{\"product\":{\"sku\":1234,\"name\":\"foo\"},\"colors.blue.hex\":\"0000FF\"},\"unset\":[\"popularity\",\"price.eur\"]}]}" \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/activity/?api_key=YOUR_API_KEY"
Feed
The feed endpoint is located at (enrich)/feed/(feed_slug)/(user_id)/
Authentication method: Server-Side Authentication
Resource Name: feed
The Feed endpoint is to retrieve activities in a feed (GET), or to submit an activity or list of activities (POST).
GET
For retrieving the activities in a feed the following parameters as shown below are supported.
URI parameters
NAME | TYPE | DESCRIPTION |
---|---|---|
enrich | string | If URI contains word "enrich", the response will be enriched. |
Query parameters
NAME | TYPE | DESCRIPTION | DEFAULT | OPTIONAL |
---|---|---|---|---|
limit | int | The amount of activities requested from the APIs | 25 | ✓ |
id_gte | string | Filter the feed on ids greater than or equal to the given value | ✓ | |
id_gt | string | Filter the feed on ids greater than the given value | ✓ | |
id_lte | string | Filter the feed on ids smaller than or equal to the given value | ✓ | |
id_lt | string | Filter the feed on ids smaller than the given value | ✓ | |
offset | int | The offset | 0 | ✓ |
withRecentReactions | boolean | If true activity object will have attribute "latest_reactions" that contains list of recently created reactions | ✓ | |
recentReactionsLimit | int | Specify number of reactions in the "latest_reactions" attribute, maximum value is 25. | ✓ | |
withOwnReactions | boolean | If true activity object will have attribute "own_reactions" that contains list of reactions created by the user himself. | ✓ | |
withReactionCounts | boolean | If true activity object will have attribute "reaction_counts" that contains number of reactions for each kind | ✓ |
Passing both id_lt[e]
andid_gt[e]
is not supported.
Note on Pagination: Using id_lte
for pagination is preferable to using offset
.
Note on Aggregated Feeds: When using id_lte
to paginate an aggregated feed, use the ID of the group that is returned from the API. Using an ID of an individual activity within the group will not work and result in an error.
If ranking is enabled on your feed group you can supply the ranking method to use by supplying the ranking method's slug on the following GET parameter:
NAME | TYPE | DESCRIPTION | DEFAULT | OPTIONAL |
---|---|---|---|---|
ranking | string | The slug of the ranking method to use | ✓ |
The following example uses a fake aggregated feed within your application called "fake_aggregated_feed", and assumes a user id of 123.
# the JWT token would be built using a payload similar to:
#{
# "resource": "feed",
# "action": "read",
# "feed_id": "fake_aggregated_feed123"
#}
curl -i -X GET \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/feed/fake_aggregated_feed/123/?api_key`={{apiKey}`}"
POST
For the POST request, you can either submit the data for one single activity or a list of activities. In addition to these base fields, extra data will be parsed as custom fields.
NAME | TYPE | DESCRIPTION | DEFAULT | OPTIONAL |
---|---|---|---|---|
actor | string | The actor performing the activity | ||
verb | string | The verb of the activity | ||
object | string | The object of the activity | ||
target | string | The optional target of the activity | ✓ | |
time | string | The optional time of the activity, isoformat | Current time | ✓ |
to | list | See the documentation on Targeting & "TO" support. | ✓ | |
foreign_id | string | A unique ID from your application for this activity. IE: pin:1 or like:300 | ✓ |
When you are sending a list of activities, the parameters are:
NAME | TYPE | DESCRIPTION |
---|---|---|
activities | list | A JSON encoded list of activity data. The data for individual activities is the same as specified above. |
The following example uses a fake flat feed in your application called "fake_flat_feed", and assumes a user id of 123.
# the JWT token would be built using a payload similar to:
#{
# "resource": "feed",
# "action": "write",
# "feed_id": "fake_flat_feed"
#}
curl -i -X POST -d "{\"actor\":\"user:789\",\"verb\":\"post\",\"object\":\"story:abc123\",\"foreign_id\":\"story:123\",\"time\":\"2017-02-23T22:57:07.099Z\",\"message\":\"My Example Post\"}" \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/feed/fake_flat_feed/123/?api_key=YOUR_API_KEY"
Feed Detail
The feed detail endpoint is located atfeed/(feed_slug)/(user_id)/(activity_id|foreign_id)/
Authentication method: Server-Side Authentication
Resource Name: feed
The Feed Detail endpoint allows you to delete activities. The Stream API allows you to delete activities by the activity id generated by Stream, or by the foreign id you generate and put within your activity:
- The activity id is returned to you in the response when the activity is first created.
- The foreign id is a unique reference which represents the activity in your database.
Note: By setting foreign ids you ensure uniqueness and no longer need to store the Stream-generated activity id in your database. Read more about foreign ids versus activity ids over at the Stream general docs.
DELETE
Note: Deleting an activity using your foreign id requires setting a foreign_id
URL query parameter to "1":
NAME | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
foreign_id | string | Send a value of 1 to indicate you want to delete by foreign id | ✓ |
The following example uses a fake flat feed in your application called "fake_flat_feed", and assumes a user id of 789 and foreign id of "abc123".
# the JWT token would be built using a payload similar to:
#{
# "resource": "feed",
# "action": "delete",
# "feed_id": "fake_flat_feed789"
#}
curl -i -X DELETE \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/feed/fake_flat_feed/789/abc123/?foreign_id=1&api_key=`YOUR_API_KEY`"
Followers
The followers endpoint is located at feed/(feed_slug)/(user_id)/followers/
Authentication method: Server-Side Authentication
Resource Name: follower
The Followers endpoint is used to retrieve a paginated list of the given feed's followers (ie, which other feeds follow this feed). The resource is limited to the most recent 500 results.
GET
NAME | TYPE | DESCRIPTION | DEFAULT | OPTIONAL |
---|---|---|---|---|
limit | int | The amount of feeds following this feed requested from the APIs | 25 | ✓ |
offset | int | The offset, max 400 | 0 | ✓ |
The following example uses a fake flat feed in your application called "fake_flat_feed", and assumes a user ID of 789
# the JWT token would be built using a payload similar to:
#{
# "resource": "follower",
# "action": "read",
# "feed_id": "fake_flat_feed123"
#}
curl -i -X GET \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/feed/fake_flat_feed/123/followers/?api_key`={{apiKey}`}"
Following
The following endpoint is located at feed/(feed_slug)/(user_id)/follows/
Authentication method: Server-Side Authentication
Resource Name: follower
The Following endpoint is for retrieving a list of feeds that this feed follows (GET), or to follow a target feed (POST). The resource is limited to the most recent 500 results.
GET
Returns a paginated list of the feeds which this feed is following.
NAME | TYPE | DESCRIPTION | DEFAULT | OPTIONAL |
---|---|---|---|---|
limit | int | The amount of followed feeds requested from the APIs | 25 | ✓ |
offset | int | The offset, max 400 | 0 | ✓ |
filter | string | List of comma separated feed ids to filter on. IE user:1,user:2. Allows you to check if a certain feed is followed. | ✓ |
The following example uses a ('flat',) feed in your application called "fake_flat_feed" and assumes a user id 123.
# the JWT token would be built using a payload similar to:
#{
# "resource": "follower",
# "action": "read",
# "feed_id": "fake_flat_feed123"
#}
curl -i -X GET \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/feed/fake_flat_feed/123/follows/?api_key`={{apiKey}`}"
POST
Follows a target feed.
NAME | TYPE | DESCRIPTION | DEFAULT | OPTIONAL |
---|---|---|---|---|
target | string | The target feed this feed should follow. For example user:44. | ||
activity_copy_limit | integer | How many activities should be copied from the target feed, max 1000 | 100 | ✓ |
The following example uses a ('flat',) feed in your application called "fake_flat_feed" and assumes a user id 123 follows another user with an id of 789. The example will also set the activity_copy_limit to 100.
# the JWT token would be built using a payload similar to:
#{
# "resource": "follower",
# "action": "write",
# "feed_id": "fake_flat_feed123"
#}
curl -i -X POST -d "{\"target\":\"fake_flat_feed:789\"}" \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/feed/fake_flat_feed/123/follows/?api_key`={{apiKey}`}&activity_copy_limit=100"
Following Detail
The following detail endpoint is located at feed/(feed_slug)/(user_id)/following/(target)/
Authentication method: Server-Side Authentication
Resource Name: follower
The Following Detail endpoint allows you to unfollow a target feed.
DELETE
NAME | TYPE | DESCRIPTION | DEFAULT | OPTIONAL |
---|---|---|---|---|
keep_history | string | When provided the activities from target feed will not be kept in the feed | ✓ |
Target is in the syntax of [feed]:[id]
. For example, "user:1".
Note: Unfollow target's activities are purged from the feed unless the keep_history
parameter is provided.
The following example uses a ('flat',) feed in your application called "fake_flat_feed" and assumes a user id 123 is going to unfollow another user with an id of 789.
# the JWT token would be built using a payload similar to:
#{
# "resource": "follower",
# "action": "delete",
# "feed_id": "fake_flat_feed123"
#}
curl -i -X DELETE \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/feed/fake_flat_feed/123/follows/fake_flat_feed:789/?api_key=YOUR_API_KEY"
Batch Activity Add
The batch follow endpoint is located at feed/add_to_many/
Authentication method: Server-Side Authentication
Resource Name: feed
Feed ID: *
The Batch Activity Add endpoint allows you to add an activity to multiple feeds in one single request.
Batch Activity Add has a limit of 5,000 target feeds. Requests that exceed this limit will return an error.
POST
NAME | TYPE | DESCRIPTION |
---|---|---|
feeds | list | The list of feeds where the activity will be stored eg. ['user:1', 'flat:2' ] |
activity | object | A JSON encoded activity object (see feed endpoint for reference) |
The following example uses a fake flat feed in your application called "fake_flat_feed", and adds one activity to this feed for users with id values of 123 and 789.
# the JWT token would be built using a payload similar to:
#{
# "resource": "feed",
# "action": "write",
# "feed_id": "*"
#}
curl -i -X POST -d "{\"feeds\":[\"fake_flat_feed:123\",\"fake_flat_feed:789\"],\"activity\":{\"actor\":\"User:2\",\"verb\":\"pin\",\"object\":\"Place:42\",\"target\":\"Board:1\"}}" \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/feed/add_to_many/?api_key=YOUR_API_KEY"
Follow Many
The follow many endpoint is located at follow_many/
Authentication method: Server-Side Authentication
Resource Name: follower
Feed ID: *
The Follow Many endpoint allows you to create multiple follows in one single batch request.
Follow Many has a limit of 2,500 follows per request.
POST
Note: The activity_copy_limit
parameter is a query parameter.
NAME | TYPE | DESCRIPTION | DEFAULT | OPTIONAL |
---|---|---|---|---|
list | A JSON encoded list of a follow object {'source': 'source:id', 'target': 'target:id'} . eg. [{'source': 'flat:1', 'target': 'user:2'}, ] | |||
activity_copy_limit | integer | How many activities should be copied from the target feed, max 1000 | 100 | ✓ |
The following example uses a fake flat feed in your application called "fake_flat_feed", and assumes user 123 will follow other users on that feed who have ids of 456 and 789. We will set the activity_copy_limit to a value of 300.
# the JWT token would be built using a payload similar to:
#{
# "resource": "follower",
# "action": "write",
# "feed_id": "*"
#}
curl -i -X POST -d "[{\"source\":\"flat:123\",\"target\":\"flat:456\"},{\"source\":\"flat:123\",\"target\":\"flat:798\"}]" \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/follow_many/?activity_copy_limit=300&api_key=`YOUR_API_KEY`"
Reaction
The reactions endpoint is located at reaction/
Authentication method: Client-Side Authentication
The reaction endpoint can be used to add reactions to Stream API.
POST
Request data
NAME | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
kind | string | Type of reaction. Must not be empty or longer than 255 characters. | |
activity_id | string | Activity ID for the reaction. Must be a valid activity ID. | |
user_id | string | user_id of the reaction. Must not be empty or longer than 255 characters. | |
data | object | Extra data of the reaction | ✓ |
target_feeds | list | Target feeds for the reaction. List of feed ids (e.g.: timeline:bob) | ✓ |
parent | string | ID of the parent reaction. If provided, it must be the ID of a reaction that has no parents. | ✓ |
Note: when using client-side auth the user_id field must not be provided as the value will be taken from the user token.
Note: If a reaction with the same ID already exists, the request will error with code 409 Conflict
.
Returned reaction object schema
NAME | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
id | string | Reaction ID. | |
kind | string | Type of reaction. | |
activity_id | string | Activity ID for the reaction. | |
user_id | string | user_id of the reaction. | |
user | object | User of the reaction | ✓ |
data | object | Extra data of the reaction | |
created_at | date | When the reaction was created. | |
updated_at | date | When the reaction was last updated. | |
parent | string | ID of the parent reaction. Empty unless the reaction is a child reaction. | |
latest_children | object | Children reactions, grouped by reaction type. | |
children_counts | object | Child reaction count, grouped by reaction kind. |
The following example assumes the user id of "bob" and an activity id of "65bca63a-7d61-48e8-be9d-c6665a008196"
# the JWT token would be built using a payload similar to:
#{
# "user_id": "bob"
#}
curl -i -X POST -d "{\"user_id\":\"bob\",\"kind\":\"like\",\"activity_id\": \"65bca63a-7d61-48e8-be9d-c6665a008196\",\"data\":{\"extra\":\"data\"}}"\
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/reaction/?api_key=YOUR_API_KEY"
Reaction detail
The reactions endpoint is located at reaction/(id)/
Authentication method: Client-Side Authentication
The reaction detail endpoint can be used to retrieve (GET) a reaction, update (PUT) reaction data and target feeds and delete (DELETE) reactions.
GET
The returned object schema is described in the reactions endpoint
The following example assumes the user id of "bob" and a reaction id of "65bca63a-7d61-48e8-be9d-c6665a008196"
# the JWT token would be built using a payload similar to:
#{
# "user_id": "bob"
#}
curl -i -X GET \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/reaction/65bca63a-7d61-48e8-be9d-c6665a008196/?api_key=YOUR_API_KEY"
DELETE
Will return an empty response on success.
The following example assumes the user id of "bob" and a reaction id of "65bca63a-7d61-48e8-be9d-c6665a008196"
# the JWT token would be built using a payload similar to:
#{
# "user_id": "bob"
#}
curl -i -X DELETE \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/reaction/65bca63a-7d61-48e8-be9d-c6665a008196/?api_key=YOUR_API_KEY"
PUT
Request data
NAME | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
data | object | Extra data of the reaction | |
target_feeds | list | Target feeds for the reaction. List of feed ids (e.g.: timeline:bob) | ✓ |
Returns the updated reaction object. The object schema is described in the reactions endpoint
The following example assumes the user id of "bob" and a reaction id of "65bca63a-7d61-48e8-be9d-c6665a008196"
# the JWT token would be built using a payload similar to:
#{
# "user_id": "bob"
#}
curl -i -X PUT -d "{\"data\":{\"extra\":\"modified\"},\"target_feeds\":[\"user:jimmy\"]}"\
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/reaction/65bca63a-7d61-48e8-be9d-c6665a008196/?api_key=YOUR_API_KEY"
Reaction pagination
The Reaction pagination endpoint is located at reaction/(lookup_attr)/(lookup_value)/(kind)/
Authentication method: Client-Side Authentication
The reaction pagination endpoint can be used to fetch (GET) reactions based on certain criteria.
GET
URI parameters
NAME | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
lookup_attr | string | Name of the reaction attribute to paginate on. Can be activity_id , reaction_id or user_id . | |
lookup_value | string | Value to use depending if paginating reactions for an activity, from a user or reactions of a reaction. | |
kind | string | Type of reaction( e.g.: like). |
Query parameters
NAME | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
limit | string | Amount of reactions requested from the API. Default: 10. Max: 25. Values larger than the max will be ignored and the max limit will be used. | ✓ |
id_gte | string | Filter the reactions on ids greater than or equal to the given value | ✓ |
id_gt | string | Filter the reactions on ids greater than the given value | ✓ |
id_lte | string | Filter the reactions on ids smaller than or equal to the given value | ✓ |
id_lt | string | Filter the reactions on ids smaller than the given value | ✓ |
with_activity_data | boolean | Returns the activity data when lookup_attr is activity_id | ✓ |
Note: passing both id_lt[e]
andid_gt[e]
is not supported.
Note: when using id_lt[e]
the reactions are ordered by the created_at
field, in descending order.
Note: when using id_gt[e]
the reactions are ordered by the created_at
field, in ascending order.
Response object
NAME | TYPE | DESCRIPTION |
---|---|---|
results | list | List of reactions. The reaction object schema can be found here |
activity | object | The activity data, this field is returned only when with_activity_data is sent. |
next | string | A url string that can be used to fetch the next page of reactions. |
The following example assumes the user id of "bob" and a reaction id of "65bca63a-7d61-48e8-be9d-c6665a008196"
# the JWT token would be built using a payload similar to:
#{
# "user_id": "bob"
#}
curl -i -X GET \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/reaction/user_id/bob/?api_key=YOUR_API_KEY&id_lte=65bca63a-7d61-48e8-be9d-c6665a008196"
Open Graph
The Open Graph endpoint is located at og/
Authentication method: Client-Side Authentication
The Open Graph endpoint can be used to scrape (GET) open graph data from a website.
The Open Graph protocol enables any web page to become a rich object in a social graph. More information can be found here.
GET
Query parameters
NAME | TYPE | DESCRIPTION |
---|---|---|
url | string | URL to scrape. |
Response object
NAME | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
title | string | Value of the title OG field. | ✓ |
type | string | Value of the type OG field. | ✓ |
url | string | Value of the url OG field. | ✓ |
site | string | Value of the site OG field. | ✓ |
site_name | string | Value of the site_name OG field. | ✓ |
description | string | Value of the description OG field. | ✓ |
determiner | string | Value of the determiner OG field. | ✓ |
locale | string | Value of the locale OG field. | ✓ |
images | list | List of og images | ✓ |
videos | list | List of og videos | ✓ |
audios | list | List of og audios | ✓ |
OG Image object
NAME | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
image | string | Value of the image OG field. | ✓ |
url | string | Value of the url OG field. | ✓ |
secure_url | string | Value of the secure_url OG field. | ✓ |
width | string | Value of the width OG field. | ✓ |
height | string | Value of the height OG field. | ✓ |
type | string | Value of the type OG field. | ✓ |
alt | string | Value of the alt OG field. | ✓ |
OG Video object
NAME | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
image | string | Value of the image OG field. | ✓ |
url | string | Value of the url OG field. | ✓ |
secure_url | string | Value of the secure_url OG field. | ✓ |
width | string | Value of the width OG field. | ✓ |
height | string | Value of the height OG field. | ✓ |
type | string | Value of the type OG field. | ✓ |
alt | string | Value of the alt OG field. | ✓ |
OG Audio object
NAME | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
audio | string | Value of the audio OG field. | ✓ |
url | string | Value of the url OG field. | ✓ |
secure_url | string | Value of the secure_url OG field. | ✓ |
type | string | Value of the type OG field. | ✓ |
The following example assumes the user id of "bob" and a reaction id of "65bca63a-7d61-48e8-be9d-c6665a008196"
# the JWT token would be built using a payload similar to:
#{
# "user_id": "bob"
#}
curl -i -X GET \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/og/?api_key=YOUR_API_KEY&url=http://ogp.me"
Collection
The collection endpoint is located at collections/(collection_name)/
Authentication method: Client-Side Authentication
The collection endpoint can be used to add collection objects(POST) to a specific collection.
POST
Request data
NAME | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
id | string | Collection object ID | ✓ |
user_id | string | user_id of the collection object. | |
data | object | Collection object data |
Note: when using client-side auth the user_id field must not be provided as the value will be taken from the user token.
Note: If a collection object with the same ID already exists, the request will error with code 409 Conflict
.
Returned collection object schema
NAME | TYPE | DESCRIPTION |
---|---|---|
collection | string | Collection name |
id | string | Collection object ID. |
foreign_id | string | ForeignID of the collection object. The format is <collection_name>:<collection_object_id> |
data | object | Collection object data |
created_at | date | When the collection object was created. |
updated_at | date | When the collection object was last updated. |
The following example assumes the user id of "bob" and the collection name "col1".
# the JWT token would be built using a payload similar to:
#{
# "user_id": "bob"
#}
curl -i -X POST -d "{\"data\":{\"extra\":\"fields\",\"flag\":false}}"\
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/collections/col1/?api_key=YOUR_API_KEY"
Collection detail
The collection endpoint is located at collections/(collection_name)/(id)/
Authentication method: Client-Side Authentication
The collection detail endpoint can be used can be used to retrieve (GET), update (PUT) and delete (DELETE) collection objects.
GET
The returned object schema is described in the collection endpoint.
The following example assumes the user id of "bob",the collection name "col1" and the collection object id "123".
# the JWT token would be built using a payload similar to:
#{
# "user_id": "bob"
#}
curl -i -X GET \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/collections/col1/123/?api_key=YOUR_API_KEY"
PUT
Request data
NAME | TYPE | DESCRIPTION |
---|---|---|
data | object | Collection object data |
The returned object schema is described in the collection endpoint.
The following example assumes the user id of "bob",the collection name "col1" and the collection object id "123".
# the JWT token would be built using a payload similar to:
#{
# "user_id": "bob"
#}
curl -i -X PUT -d "{\"data\":{\"modified\":\"fields\",\"modified\":true}}"\
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/collections/col1/123/?api_key=YOUR_API_KEY"
DELETE
Will return an empty response on success.
The following example assumes the user id of "bob",the collection name "col1" and the collection object id "123".
# the JWT token would be built using a payload similar to:
#{
# "user_id": "bob"
#}
curl -i -X DELETE \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/collections/col1/123/?api_key=YOUR_API_KEY"
Collections batch
The collections endpoint is located at collections/
Authentication method: Server-Side Authentication
Resource Name: collections
Feed ID: *
The collections detail endpoint can be used can be used to retrieve (GET), upsert (POST) and delete (DELETE) multiple collection objects at once.
GET
Query parameters
NAME | TYPE | DESCRIPTION |
---|---|---|
foreign_ids | string | Comma separated list of foreign ids. A foreign id has the format <collection_name>:<collection_object_id> . The maximum number of foreign ids is 1000. E.g.: collection1:id1,collection1:id2,collection3:id5 |
Returned object schema
NAME | TYPE | DESCRIPTION |
---|---|---|
response | object | Response object containing a data field which is an array of collection objects. The schema for the objects can be found in the collection docs. |
Example response object:
{
"response": {
"data": [
{
"collection": "collection1",
"created_at": "2018-11-29T12:03:52.792967Z",
"data": {
"flag": false,
"field": "value"
},
"foreign_id": "collection1:id1",
"id": "asdf",
"updated_at": "2018-11-29T12:28:20.735841Z"
}
]
}
}
The following example assumes the collection "col1" with object ids "id1" and "id2" and the collection "col3" with object id "id5"
# the JWT token would be built using a payload similar to:
#{
# "resource": "collections",
# "action": "read",
# "feed_id": "*"
#}
curl -i -X GET \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/collections/?api_key=YOUR_API_KEY&&foreign_ids=col1:id1,col2:id2,col3:id5"
POST
Request data
NAME | TYPE | DESCRIPTION |
---|---|---|
data | object | A map between collection names and the collection objects that will be upserted |
Example request data:
{
"data": {
"collection1": [
{
"id": "id1",
"data": {
"field": "value",
"flag": false
},
"user_id": "user1"
},
{
"id": "id2",
"data": {
"field": "modify"
}
}
],
"collection2": [
{
"id": "id23",
"data": {
"user": "data"
}
}
]
}
}
Note: You cannot have collection objects with the same id within the same collection.
The endpoint returns a clone of the data
field from the request data upon success.
The following example assumes the collection "col1" with object ids "id1" and "id2" and the collection "col3" with object id "id5"
# the JWT token would be built using a payload similar to:
#{
# "resource": "collections",
# "action": "write",
# "feed_id": "*"
#}
curl -i -X POST -d "{\"data\":{\"col1\":[{\"id\":\"id1\",\"data\":{\"field\":\"value\",\"flag\":false},\"user_id\":\"user1\"},{\"id\":\"id2\",\"data\":{\"field\":\"modify\"}}],\"collection3\":[{\"id\":\"id5\",\"data\":{\"user\":\"data\"}}]}}"\
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/collections/?api_key=YOUR_API_KEY"
DELETE
Note: You can only delete objects from a single collection per request.
Query parameters
NAME | TYPE | DESCRIPTION |
---|---|---|
collection_name | string | The name of the collection. |
ids | string | Comma separated list of collection object ids. E.g.: id1,id2,id3 |
Will return an empty response on success.
The following example assumes the collection "col1" with object ids "id1" and "id2"
# the JWT token would be built using a payload similar to:
#{
# "resource": "collections",
# "action": "delete",
# "feed_id": "*"
#}
curl -i -X DELETE \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/collections/?api_key=YOUR_API_KEY&&collection_name=col1&ids=id1,id2"
Files
The files endpoint is located at files/
Authentication method: Server-Side Authentication
Resource Name: files
Feed ID: *
Authentication method: Client-Side Authentication
The files endpoint can be used can be used to upload (POST) and delete (DELETE) files to and from Stream API.
POST
Request data
NAME | TYPE | DESCRIPTION |
---|---|---|
file | file | File to upload. Must be sent as form data (Content-Type: multipart/form-data ). |
Returned object schema
NAME | TYPE | DESCRIPTION |
---|---|---|
file | string | Publicly reachable CDN URL of the uploaded file. |
The following example assumes the user id of "bob" and the local file path "some_file".
# the JWT token would be built using a payload similar to:
#{
# "user_id": "bob"
#}
curl -i -X POST \
-F "file=@some_file" \
-H "Content-Type: multipart/form-data" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/files/?api_key=YOUR_API_KEY"
DELETE
Query parameters
NAME | TYPE | DESCRIPTION |
---|---|---|
url | string | URL of the file to delete. This is the URL returned by the POST request. |
Will return an empty response on success.
The following example assumes the user id of "bob" and the file url "https://cdn.example.com/file/".
# the JWT token would be built using a payload similar to:
#{
# "user_id": "bob"
#}
curl -i -X DELETE \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/files/?api_key=YOUR_API_KEY&url=https://cdn.example.com/file"
# You can also use server-side authentication.
# the JWT token would be built using a payload similar to:
#{
# "resource": "files",
# "action": "delete",
# "feed_id": "*"
#}
curl -i -X DELETE \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/files/?api_key=YOUR_API_KEY&url=https://cdn.example.com/file"
Images
The images endpoint is located at images/
Authentication method: Server-Side Authentication
Resource Name: files
Feed ID: *
Authentication method: Client-Side Authentication
The images endpoint can be used can be used to process(GET), upload (POST) and delete (DELETE) images.
GET
Query parameters
NAME | TYPE | DESCRIPTION | DEFAULT | OPTIONAL |
---|---|---|---|---|
url | string | URL of the image to process. This is the URL returned by the POST request. | ||
resize | string | Strategy used to adapt the image the new dimensions. Allowed values are: clip, crop, scale, fill. | clip | ✓ |
crop | string | Cropping modes as a comma separated list. Allowed values are top, bottom, left, right, center. | center | ✓ |
w | number | Width of the processed image. | ✓ | |
h | number | Geight of the processed image. | ✓ |
Returned object schema
NAME | TYPE | DESCRIPTION |
---|---|---|
file | string | Publicly reachable CDN URL of the processed image. |
POST
Request data
NAME | TYPE | DESCRIPTION |
---|---|---|
file | file | Image to upload. Must be sent as form data (Content-Type: multipart/form-data ). |
Returned object schema
NAME | TYPE | DESCRIPTION |
---|---|---|
file | string | Publicly reachable CDN URL of the uploaded image. |
The following example assumes the user id of "bob" and the local image path "some_image".
# the JWT token would be built using a payload similar to:
#{
# "user_id": "bob"
#}
curl -i -X POST \
-F "file=@some_image" \
-H "Content-Type: multipart/form-data" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/images/?api_key=YOUR_API_KEY"
DELETE
Query parameters
NAME | TYPE | DESCRIPTION |
---|---|---|
url | string | URL of the image to delete. This is the URL returned by the POST request. |
Will return an empty response on success.
The following example assumes the user id of "bob" and the image url "https://cdn.example.com/image/".
# the JWT token would be built using a payload similar to:
#{
# "user_id": "bob"
#}
curl -i -X DELETE \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/images/?api_key=YOUR_API_KEY&url=https://cdn.example.com/image"
# You can also use server-side authentication.
# the JWT token would be built using a payload similar to:
#{
# "resource": "files",
# "action": "delete",
# "feed_id": "*"
#}
curl -i -X DELETE \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/images/?api_key=YOUR_API_KEY&url=https://cdn.example.com/image"
User
The user endpoint is located at user/
Authentication method: Server-Side Authentication
Resource Name: users
Feed ID: *
Authentication method: Client-Side Authentication
The user endpoint can be used to add a user(POST) via Stream API.
POST
Request data
NAME | TYPE | DESCRIPTION |
---|---|---|
id | string | User ID. Must not be empty or longer than 255 characters. |
data | object | User additional data. |
Query parameters
NAME | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
get_or_create | boolean | If true, if a user with the same ID already exists, it will be returned. Otherwise, the endpoint will return 409 Conflict . | ✓ |
Response object schema
NAME | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
id | string | User ID. | |
data | object | User additional data. | |
created_at | date | When the user was created. | |
updated_at | date | When the user was last updated. | |
followers_count | number | Number of users that follow this user. | ✓ |
following_count | number | Number of users this user is following. | ✓ |
The following example assumes the user id of "bob".
# the JWT token would be built using a payload similar to:
#{
# "resource": "users"
# "action": "write"
# "feed_id": "*"
#}
curl -i -X POST -d "{\"id\":\"bob\","\"data\":{\"extra\":\"fields\",\"flag\":false}}"\
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/user/?api_key=YOUR_API_KEY"
User detail
The user detail endpoint is located at user/(id)/
Authentication method: Server-Side Authentication
Resource Name: users
Feed ID: *
Authentication method: Client-Side Authentication
The user detail endpoint can be used can be used to retrieve (GET), update (PUT) and delete (DELETE) a user.
GET
Query parameters
NAME | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
with_follow_counts | boolean | If true, the following_count and followers_count will be included in the response. | ✓ |
The returned object schema is described in the user endpoint.
The following example assumes the user id of "bob".
# the JWT token would be built using a payload similar to:
#{
# "user_id": "bob"
#}
curl -i -X GET \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/user/bob/?api_key=YOUR_API_KEY"
PUT
Note: You can only change a user's data
field.
Request data
NAME | TYPE | DESCRIPTION |
---|---|---|
data | object | User data field. |
The returned object schema is described in the user endpoint.
The following example assumes the user id of "bob".
# the JWT token would be built using a payload similar to:
#{
# "user_id": "bob"
#}
curl -i -X PUT -d "{\"data\":{\"modified\":\"fields\",\"modified\":true}}"\
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/user/bob/?api_key=YOUR_API_KEY"
DELETE
Will return an empty response on success.
The following example assumes the user id of "bob".
# the JWT token would be built using a payload similar to:
#{
# "user_id": "bob"
#}
curl -i -X DELETE \
-H "Content-Type: application/json" \
-H "Stream-Auth-Type: jwt" \
-H "Authorization: TOKEN" \
"https://APP_REGION-api.stream-io-api.com/api/v1.0/user/bob/?api_key=YOUR_API_KEY"
Advanced
Options
All clients should support several options:
API Location (Region)
Location/Region should be configurable when initializing the Stream client.
Request Timeout
The request timeout should be configurable. We recommend 3 seconds as a default.
On average, it takes ~60ms to retrieve your feed. However, it is possible for network latency to spike, which is why we recommend setting a timeout.
Best Practices
Here's a brief list of best practices that we recommend when building a new API SDK for interacting with Stream:
Test Code Coverage (>95%)
We recommend building both unit and integration tests, and ensuring a code coverage above 95%.
Code Examples - Every API Endpoint
Document the API calls for every operation.
Check out the README of the stream-python repo for a good starting point.
Input Validation
Feed slugs and user ids need to match the \w+ regular expression. Your client should validate input before sending an API call.
Error Mapping
Errors from the Stream API should be mapped to exception classes and properly raised.
Software Licensing
We recommend using the MIT or BSD license when releasing open-source software.
Offering Support
If you release your software as open-source, and place it on GitHub, we ask that you pay close attention to any issues and pull requests by other community members. If your SDK gains significant support, we may also request to take over your open-source project as an officially-supported library so we can assist with support efforts.
Naming Conventions
We try to keep our variable names consistent amongst the various API clients, except in the case where common lint-checker software will raise too many errors. This section explains some common terminology we use in our SDK libraries.
NAME | DESCRIPTION |
---|---|
api_key | The API key, it can be safely shared with untrusted entities |
api_secret | The API secret, it is used to generate the feed tokens |
app_id | A reference to the application id in Stream. This is only used for realtime notifications |
api_version | The version of the API For example: v1.0 |
client | The client class that manages API calls and authentication |
feed | An instance of a feed pointing to a reference of user id and feed slug |
feed_slug | The name of the feed group, for instance user, trending, flat etc. For example: flat |
user_id | The owner of the given feed |
feed_id | The combination of feed slug and user id separated by a colon For example: flat:1 |
token | The JWT auth token for a specific feed. It is created by signing the base 64 encoded JWT header and payload with the api_secret For example: yuXEO2nNOrcwd36sgq8nMC1e2qU |
signature | Combination of feed_id (without colon) and the token For example: flat123 yuXEO2nNOrcwd36sgq8nMC1e2qU |
signer | The class responsible for creating tokens |
foreign_id | The foreign id of an activity, used in conjunction with a time attribute in an activity, is used to generate a unique reference for updating and deleting activities |
location | The name of the API location For example: us-east, us-west etc |
STREAM_URL | The environment variable containing all details to initialize a client. This is only used for Heroku For example: https://ahj2ndz7gsan:secret@us-east.stream-io-api.com/?app_id=1 |