From 99ffa582f8053f63b3dc3fad1c8bbf4ae3b48dbf Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Mon, 6 Nov 2023 11:43:48 +0100 Subject: [PATCH 01/27] Add info about Stream, link repositories --- .../video/docusaurus/docs/api/basics/get_started.mdx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx index a56845da..353b69e7 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx @@ -10,6 +10,10 @@ import TabItem from '@theme/TabItem'; import RTMP from '../_common_/rtmp.mdx'; import Broadcast from '../_common_/broadcast.mdx'; +Stream powers [Chat Messaging](https://getstream.io/chat/), [Video & Audio](https://getstream.io/video/), and [Activity Feeds](https://getstream.io/activity-feeds/) for billions of global end-users across thousands of different apps. + +Stream’s global edge network ensures a faster and more reliable experience for your video calls and livestreams. Excellent developer experience and docs enable you to build in-app video calling in days. Scale to millions of users and thousands of call participants. + For the average Stream integration, the development work focuses on code that executes in the client. However, some tasks must be executed from the server for safety (for example, token generation). Stream provides server-side SDKs to help execute these tasks. @@ -39,6 +43,11 @@ pip install getstream +Something doesn't work? You can open a GitHub issue: + +- [Python SDK](https://github.com/GetStream/stream-py) +- [Node SDK](https://github.com/GetStream/stream-node) + ## Creating client To create a server-side client, you'll need your **API key** and **secret**. Both of them can be found in your [Stream Dashboard](https://dashboard.getstream.io/). From a9a3d2c105ea461584c951fd7c10ddd223fb798a Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Mon, 6 Nov 2023 13:38:21 +0100 Subject: [PATCH 02/27] update get started page --- .../docs/api/basics/get_started.mdx | 166 +++++++----------- 1 file changed, 68 insertions(+), 98 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx index 353b69e7..fd06aeb1 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx @@ -56,6 +56,8 @@ To create a server-side client, you'll need your **API key** and **secret**. Bot ```js +import { StreamClient } from '@stream-io/node-sdk'; + const apiKey = ''; const secret = ''; client = new StreamClient(apiKey, secret); @@ -73,7 +75,9 @@ client = Stream(api_key="your_api_key", api_secret="your_api_secret") -## Creating user tokens +## Creating users and user tokens + +To create a user you need to provide an ID, and their role. Optionally you can also specify their name and an image, these fields are recognized and rendered by the default SDK components. It's also possible to add any other custom data. Tokens need to be generated server-side. Typically, you integrate this into the part of your codebase where you log in or register users. The tokens provide a way to authenticate a user or give access to a specific set of video/audio calls. @@ -82,18 +86,39 @@ Tokens need to be generated server-side. Typically, you integrate this into the ```js const userId = 'john'; -// exp and iat are optional +const newUser: UserObjectRequest = { + id: userId, + role: 'user', + custom: { + color: 'red', + }, + name: 'John', + image: 'link/to/profile/image', +}; +await client.upsertUsers({ + users: { + [newUser.id]: newUser, + }, +}); + +// exp is optional // the token will be valid for 1hour const exp = Math.round(new Date().getTime() / 1000) + 60 * 60; -const iat = Math.round(new Date().getTime() / 1000); -client.createToken(userId, exp, iat); +client.createToken(userId, exp); ``` ```py +users = {} +user = UserRequest( +id='john', role="user", custom={"color": "red"}, name="John",image= "link/to/profile/image", +) +users[user.id] = user +client.upsert_users(users=users) + token = client.create_token("admin-user") ``` @@ -104,10 +129,12 @@ token = client.create_token("admin-user") You can create a call by providing the call type and an ID: -- The [call type](call_types/builtin) controls which features are enabled and sets up permissions. +- The [call type](call_types/builtin) controls which features are enabled and sets up permissions. Call type settings and permissions can be set from API, or using the [Stream Dashboard](https://dashboard.getstream.io/). - Calls IDs can be reused, which means they can be joined multiple times, so it's possible to set up recurring calls. -You can optionally restrict call access by providing a list of users. +You can optionally restrict call access by providing a list of existing users. + +It's also possible to store any custom data with the call object. @@ -123,7 +150,11 @@ call.create({ data: { created_by_id: 'john' } }); call.create({ data: { created_by_id: 'john', + // Call members need to be existing users members: [{ user_id: 'john', role: 'admin' }, { user_id: 'jack' }], + custom: { + color: 'blue', + }, }, }); ``` @@ -164,10 +195,15 @@ curl -X POST "https://video.stream-io-api.com/video/call/default/${CALL_ID}?api_ ## Adding members to a call +You can restrict call access by defining a list of members who are allowed to join the call. Call members need to be existing users. Every call member has a call-level role, [you can configure roles](call_types/permissions/) on the call type. + +Call members can receive [push notifications](../../call_types/settings/#push-notifications-settings). + ```js +// Call members need to be existing users call.updateCallMembers({ update_members: [{ user_id: 'sara' }, { user_id: 'emily', role: 'admin' }], }); @@ -200,11 +236,34 @@ curl -X PUT "https://video.stream-io-api.com/video/call/default/${CALL_ID}/membe -## Updating a call +## Remove members + + + + +```js +call.updateCallMembers({ + remove_members: ['sara'], +}); +``` + + + -- Most of the call type settings can be overridden on a call level. +```py +call.update_members( + members=[ + MemberRequest(user_id: 'jack', role: 'admin') + ] +) +``` + + + -- Custom data can also be stored for calls. +## Updating a call + +Default call settings are inherited from the [call type](call_types/settings/). These settings can be overridden if necessary. @@ -256,92 +315,3 @@ curl -X PUT "https://video.stream-io-api.com/video/call/default/${CALL_ID}?api_k - -## Streaming - -Broadcasting serves are a means of transmitting live or pre-recorded content to a wide audience. - -We can choose from two approaches to broadcasting the media: - -- [HLS](https://en.wikipedia.org/wiki/HTTP_Live_Streaming) - slight delay, better buffering -- [WebRTC](https://webrtc.org/) - lower latency, less reliability - -It is up to the integrators to decide, what approach will be used in their apps for the audience to consume the streams. - -For more information see the [Streaming section](streaming/overview/). - -The following example shows how to start and stop HLS broadcasting: - - - -Almost all livestream software and hardware supports RTMPS. Our API supports using third-party software for streaming using RTMPS. For more information, reference the [Streaming section](streaming/overview/). - -The following example shows how to get the RTMP address that you need to provide for the third-party software: - - - -## Recording - -Calls can be recorded for later use. Calls recording can be started/stopped via API calls or configured to start automatically when the first user joins the call. - -For more information, see the [Recordings section](recording/calls/). - -The following example shows how to start and stop recording: - - - - -```js -call.startRecording(); - -// to stop recording -call.stopRecording(); -``` - - - - -```py -call.start_recording() - -// to stop recording -call.stop_recording() -``` - - - - -```bash -curl -X POST "https://video.stream-io-api.com/video/call/default/${CALL_ID}/start_recording?api_key=${API_KEY}" \ --H "Authorization: ${JWT_TOKEN}" -``` - - - - -The following example shows how to query existing recordings: - - - - -```js -call.listRecordings(); -``` - - - - -```py -recordings = call.list_recordings() -``` - - - - -```bash -curl -X GET "https://video.stream-io-api.com/video/call/default/${CALL_ID}/${SESSION_ID}/recordings?api_key=${API_KEY}" \ --H "Authorization: ${JWT_TOKEN}" -``` - - - From d1264a549bc024886722cc9fdfed670f98504fa9 Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Mon, 6 Nov 2023 14:41:38 +0100 Subject: [PATCH 03/27] Update authentication page --- .../docs/api/basics/authentication.mdx | 74 +++++++------------ 1 file changed, 28 insertions(+), 46 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx index da3ae4dc..3e3e32d0 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx @@ -128,50 +128,32 @@ client.update_users_partial( ## Anonymous users -Anonymous users are users that are not authenticated. It's common to use this for watching a livestream or similar where you aren't authenticated. Anonymous users can be connected using client-side SDKs. +Anonymous users are users that are not authenticated. It's common to use this for watching a livestream or similar where you aren't authenticated. Anonymous users can be connected using client-side SDKs. Anonymous users are not counted toward your MAU. ## Guest users -Guest users are temporary user accounts. You can use it to temporarily give someone a name and image when joining a call. Guest users can aslso be created client-side. +Guest users are temporary user accounts. You can use it to temporarily give someone a name and image when joining a call. Guest users can also be created client-side. Guest users are counted towards your MAU usage. - - - -```js -const guest: UserObjectRequest = { - id: '', - name: '', - custom: { - color: 'red', - }, -}; - -const guest = (await client.createGuest({ user: guest })).user; -``` +## Deactivating and deleting users - - +While it is usually safer for data retention to deactivate a user, some use cases require completely deleting a user and their data. -```py -guest = UserRequest( - id = '', - name= '', - custom= { - "color": 'red', - }, -) +Deactivating a user means: -guest = (client.video.create_guest(user=guest)).user -``` +- the user can't connect to Stream API +- their data will be retained +- a deactivated user can be reactivated - - +Deleting a user means: -## Deactivating and deleting users +- the user can't connect to Stream API +- their data won't appear in user queries -While it is usually safer for data retention to deactivate a user, some use cases require completely deleting a user and their data. +Delete has the following opitions: -Once a user has been deleted, it cannot be un-deleted, and the user_id cannot be used again. +- Mark messages deleted: delete all the messages the user sent +- Delete conversation channels: delete all 1:1 channels with the deleted user +- Hard delete: by default the user and it's data is soft deleted, and the user can be restored. If this flag is set to `true`, all user data is removed, and the user can't be restored. @@ -181,7 +163,15 @@ client.deactivateUser({ user_id: '', }); +//reactivate +client.reactivateUsers({ + user_ids: [''], +}); + client.deleteUser({ userId: '' }); + +//restore +client.restoreUsers({ user_ids: [''] }); ``` @@ -216,8 +206,7 @@ const userId = 'john'; // exp and iat are optional // the token will be valid for 1hour const exp = Math.round(new Date().getTime() / 1000) + 60 * 60; -const iat = Math.round(new Date().getTime() / 1000); -client.createToken(userId, exp, iat); +client.createToken(userId, exp); ``` @@ -242,7 +231,7 @@ client.create_token(user_id = user_id, exp = exp, iat = iat) ## Call tokens -Call tokens contain a list of call IDs. If a user is authenticated with a call token, they can only access the specified calls. +Call tokens contain a list of call IDs. If a user is authenticated with a call token, they can only access the specified calls. They are helpful if you want to limit call access, but you want to avoid managing call members (an example: a pay-pre-view link for livestreams, with hundreds of thousands of expected viewers). @@ -252,11 +241,10 @@ const userId = 'john'; // exp and iat are optional // the token will be valid for 1hour const exp = Math.round(new Date().getTime() / 1000) + 60 * 60; -const iat = Math.round(new Date().getTime() / 1000); const call_cids = ['default:call1', 'livestream:call2']; -client.createCallToken(userId, call_cids, exp, iat); +client.createCallToken(userId, call_cids, exp); ``` @@ -267,19 +255,13 @@ import time user_id = 'john' -# exp and iat are optional, token will be valid for 1 hour +# exp is optional, token will be valid for 1 hour exp = int(time.time()) + 60 * 60 -iat = int(time.time()) call_cids = ['default:call1', 'livestream:call2'] -client.create_token(user_id=user_id, exp, iat, call_cids) +client.create_token(user_id=user_id, exp, undefined, call_cids) ``` - -## Provisioning token in production - -Your authentication service is responsible for generating tokens for your users. It is highly recommended to always create tokens with an expiration. -All SDKs make it easy to automatically re-fetch tokens from your backend servers with token providers when they expire. From 1a681259099bdccdfe53093c9389b183b5d70992 Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Mon, 6 Nov 2023 14:50:51 +0100 Subject: [PATCH 04/27] update authentication page --- docusaurus/video/docusaurus/docs/api/basics/authentication.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx index 3e3e32d0..22e665ed 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx @@ -132,7 +132,7 @@ Anonymous users are users that are not authenticated. It's common to use this fo ## Guest users -Guest users are temporary user accounts. You can use it to temporarily give someone a name and image when joining a call. Guest users can also be created client-side. Guest users are counted towards your MAU usage. +Guest users are temporary user accounts. You can use it to temporarily give someone a name and image when joining a call. Guest users can be created client-side. Guest users are counted towards your MAU usage. ## Deactivating and deleting users From 84dd1971b4ceb20357695666b7a2e3805059ff59 Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Mon, 6 Nov 2023 15:34:38 +0100 Subject: [PATCH 05/27] Update exp and iat examples --- .../video/docusaurus/docs/api/basics/authentication.mdx | 6 ++---- docusaurus/video/docusaurus/docs/api/basics/get_started.mdx | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx index 22e665ed..5f1bcdfa 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx @@ -203,8 +203,7 @@ You can optionally provide ```js const userId = 'john'; -// exp and iat are optional -// the token will be valid for 1hour +// exp is optional (by default the token is valid for an hour) const exp = Math.round(new Date().getTime() / 1000) + 60 * 60; client.createToken(userId, exp); ``` @@ -238,8 +237,7 @@ Call tokens contain a list of call IDs. If a user is authenticated with a call t ```js const userId = 'john'; -// exp and iat are optional -// the token will be valid for 1hour +// exp is optional (by default the token is valid for an hour) const exp = Math.round(new Date().getTime() / 1000) + 60 * 60; const call_cids = ['default:call1', 'livestream:call2']; diff --git a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx index fd06aeb1..717bb16f 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx @@ -101,8 +101,7 @@ await client.upsertUsers({ }, }); -// exp is optional -// the token will be valid for 1hour +// exp is optional (by default the token is valid for an hour) const exp = Math.round(new Date().getTime() / 1000) + 60 * 60; client.createToken(userId, exp); From 996c8573d769509e0fb654c6a6929450d96e4c75 Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Mon, 6 Nov 2023 15:36:12 +0100 Subject: [PATCH 06/27] Revert accidental Python changes --- .../video/docusaurus/docs/api/basics/authentication.mdx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx index 5f1bcdfa..cf5176d9 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx @@ -253,12 +253,13 @@ import time user_id = 'john' -# exp is optional, token will be valid for 1 hour +# exp and iat are optional, token will be valid for 1 hour exp = int(time.time()) + 60 * 60 +iat = int(time.time()) call_cids = ['default:call1', 'livestream:call2'] -client.create_token(user_id=user_id, exp, undefined, call_cids) +client.create_token(user_id=user_id, exp, iat, call_cids) ``` From 2b9702276028c6e5fd2318948d26a9145b172948 Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Tue, 7 Nov 2023 10:51:23 +0100 Subject: [PATCH 07/27] add timeout to node client --- .../video/docusaurus/docs/api/basics/authentication.mdx | 3 ++- docusaurus/video/docusaurus/docs/api/basics/get_started.mdx | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx index cf5176d9..277f833b 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx @@ -153,7 +153,8 @@ Delete has the following opitions: - Mark messages deleted: delete all the messages the user sent - Delete conversation channels: delete all 1:1 channels with the deleted user -- Hard delete: by default the user and it's data is soft deleted, and the user can be restored. If this flag is set to `true`, all user data is removed, and the user can't be restored. +- Hard delete: by default the user and its data is soft deleted, and the user can be restored. If this flag is set to `true`, all user data is removed, and the user can't be restored. +- New channel owner ID: channels owned by hard-deleted users will be transferred to this userID diff --git a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx index 717bb16f..5cd2d4a6 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx @@ -52,6 +52,8 @@ Something doesn't work? You can open a GitHub issue: To create a server-side client, you'll need your **API key** and **secret**. Both of them can be found in your [Stream Dashboard](https://dashboard.getstream.io/). +You can optionally pass a timeout for the API requests, the default timeout is 3000ms. + @@ -61,6 +63,10 @@ import { StreamClient } from '@stream-io/node-sdk'; const apiKey = ''; const secret = ''; client = new StreamClient(apiKey, secret); + +// optionally add timeout to API requests +// the default timeout is 3000ms +client = new StreamClient(apiKey, secret, { timeout: 3000 }); ``` From 253dd36ab6ad8fed1306d1fa73fce610f3e5a377 Mon Sep 17 00:00:00 2001 From: sachaarbonel Date: Tue, 7 Nov 2023 11:44:25 +0100 Subject: [PATCH 08/27] update python docs --- .../video/docusaurus/docs/api/_common_/rtmp.mdx | 4 ++-- .../docs/api/basics/authentication.mdx | 14 ++++++++++---- .../docusaurus/docs/api/basics/get_started.mdx | 17 +++++++++++++++-- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx b/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx index 7b9202d8..f14ddc7b 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx @@ -21,11 +21,11 @@ const address = resp.call.ingress.rtmp.address.replace( ```py -response = call.create(GetOrCreateCallRequest( +response = call.create( data=CallRequest( created_by_id="sacha", ), - ),) + ) rtmp_url = response.data().call.ingress.rtmp.address ``` diff --git a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx index 277f833b..e63e2470 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx @@ -184,7 +184,15 @@ client.deactivate_user( user_id= '', ) +// reactivate +client.reactivate_users( + user_ids= [''], +) + client.delete_user( user_id= '' ) + +//restore +client.restore_users( user_ids= [''] ) ``` @@ -221,9 +229,8 @@ user_id = 'john' # exp and iat are optional # the token will be valid for 1 hour exp = int(time.time()) + 60 * 60 -iat = int(time.time()) -client.create_token(user_id = user_id, exp = exp, iat = iat) +client.create_token(user_id = user_id, expiration = exp) ``` @@ -256,11 +263,10 @@ user_id = 'john' # exp and iat are optional, token will be valid for 1 hour exp = int(time.time()) + 60 * 60 -iat = int(time.time()) call_cids = ['default:call1', 'livestream:call2'] -client.create_token(user_id=user_id, exp, iat, call_cids) +client.create_cal_token(user_id=user_id, expiration=exp,call_cids= call_cids) ``` diff --git a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx index 5cd2d4a6..97c228f8 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx @@ -75,7 +75,7 @@ client = new StreamClient(apiKey, secret, { timeout: 3000 }); ```py from getstream import Stream -client = Stream(api_key="your_api_key", api_secret="your_api_secret") +client = Stream(api_key="your_api_key", api_secret="your_api_secret", timeout=3.0) ``` @@ -176,6 +176,19 @@ response = call.create( created_by_id="sacha", ), ) + +//optionally provide additional data +response = call.create( + data=CallRequest( + created_by_id="sacha", + // Call members need to be existing users + members=[ + MemberRequest(user_id: "john", role: "admin"), + MemberRequest(user_id: "jack"), + ], + custom={"color": "blue"}, + ), +) ``` @@ -257,7 +270,7 @@ call.updateCallMembers({ ```py call.update_members( - members=[ + remove_members=[ MemberRequest(user_id: 'jack', role: 'admin') ] ) From 48667ca19d4e0d9b5eaceac6abefa256857068e3 Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Tue, 7 Nov 2023 13:55:14 +0100 Subject: [PATCH 09/27] Update token options --- .../video/docusaurus/docs/api/basics/authentication.mdx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx index e63e2470..4da28718 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx @@ -202,10 +202,7 @@ client.restore_users( user_ids= [''] ) Stream uses JWT (JSON Web Tokens) to authenticate chat users, enabling them to log in. Knowing whether a user is authorized to perform certain actions is managed separately via a role-based permissions system. Tokens need to be generated server-side. -You can optionally provide - -- Expiration time. By default tokens don't have an expiration date. -- Issued at date, which is necessary if you manually want to revoke tokens. By default, the issued at date is set to the current date. +You can optionally provide an expiration time. By default, tokens are valid for 1 hour. From 8155d04f71c6c112cf195f96ee96e8392b6515fa Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Tue, 7 Nov 2023 14:38:23 +0100 Subject: [PATCH 10/27] add token provider example to node --- .../video/docusaurus/docs/api/basics/authentication.mdx | 4 ++++ docusaurus/video/docusaurus/docs/api/basics/get_started.mdx | 2 ++ 2 files changed, 6 insertions(+) diff --git a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx index 4da28718..84d6050e 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx @@ -233,6 +233,10 @@ client.create_token(user_id = user_id, expiration = exp) +You need to provide the generated tokens to the client SDKs. Stream SDKs accept a token provider, that can be called to retrieve and renew tokens. You need to implement the token provider in your own application, this is usually an HTTP endpoint. + +Example [token provider for the Node SDK using Express](https://codesandbox.io/p/sandbox/stream-node-token-provider-example-f9cl27). + ## Call tokens Call tokens contain a list of call IDs. If a user is authenticated with a call token, they can only access the specified calls. They are helpful if you want to limit call access, but you want to avoid managing call members (an example: a pay-pre-view link for livestreams, with hundreds of thousands of expected viewers). diff --git a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx index 97c228f8..2c944e3c 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx @@ -59,6 +59,8 @@ You can optionally pass a timeout for the API requests, the default timeout is 3 ```js import { StreamClient } from '@stream-io/node-sdk'; +// or +// const { StreamClient } = require("@stream-io/node-sdk"); const apiKey = ''; const secret = ''; From c3f9e050976b1ac0c02d2f533ba860fc175e000c Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Tue, 7 Nov 2023 16:12:14 +0100 Subject: [PATCH 11/27] update delete users docs --- .../docusaurus/docs/api/basics/authentication.mdx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx index 84d6050e..a26f0012 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx @@ -151,10 +151,12 @@ Deleting a user means: Delete has the following opitions: -- Mark messages deleted: delete all the messages the user sent -- Delete conversation channels: delete all 1:1 channels with the deleted user -- Hard delete: by default the user and its data is soft deleted, and the user can be restored. If this flag is set to `true`, all user data is removed, and the user can't be restored. -- New channel owner ID: channels owned by hard-deleted users will be transferred to this userID +| Name | Type | Description | Optional | +| ---------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | +| `user` | Enum (soft, pruning, hard) | - Soft: marks user as deleted and retains all user data.
- Pruning: marks user as deleted and nullifies user information.
- Hard: deletes user completely - this requires hard option for messages and conversation as well. | Yes | +| `conversations` | Enum (soft, hard) | - Soft: marks all conversation channels as deleted (same effect as Delete Channels with 'hard' option disabled).
- Hard: deletes channel and all its data completely including messages (same effect as Delete Channels with 'hard' option enabled). | Yes | +| `messages` | Enum (soft, pruning, hard) | - Soft: marks all user messages as deleted without removing any related message data.
- Pruning: marks all user messages as deleted, nullifies message information and removes some message data such as reactions and flags.
- Hard: deletes messages completely with all related information. | Yes | +| `new_channel_owner_id` | string | Channels owned by hard-deleted users will be transferred to this userID. If you doesn't provide a value, the channel owner will have a system generated ID like `delete-user-8219f6578a7395g` | Yes | @@ -169,7 +171,7 @@ client.reactivateUsers({ user_ids: [''], }); -client.deleteUser({ userId: '' }); +client.deleteUsers({ user_ids: [''] }); //restore client.restoreUsers({ user_ids: [''] }); From 15ec0a4420b9f3a7d0b08592856b5484ae14af04 Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Tue, 7 Nov 2023 16:37:00 +0100 Subject: [PATCH 12/27] share data between get stared and calls page --- .../docs/api/_common_/create-call.mdx | 81 +++++++ .../docs/api/_common_/manage-call-members.mdx | 70 ++++++ .../docs/api/_common_/update-call.mdx | 55 +++++ .../docusaurus/docs/api/basics/calls.mdx | 191 +--------------- .../docs/api/basics/get_started.mdx | 203 +----------------- 5 files changed, 219 insertions(+), 381 deletions(-) create mode 100644 docusaurus/video/docusaurus/docs/api/_common_/create-call.mdx create mode 100644 docusaurus/video/docusaurus/docs/api/_common_/manage-call-members.mdx create mode 100644 docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx diff --git a/docusaurus/video/docusaurus/docs/api/_common_/create-call.mdx b/docusaurus/video/docusaurus/docs/api/_common_/create-call.mdx new file mode 100644 index 00000000..bb31a425 --- /dev/null +++ b/docusaurus/video/docusaurus/docs/api/_common_/create-call.mdx @@ -0,0 +1,81 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +You can create a call by providing the call type and an ID: + +- The [call type](/api/call_types/builtin) controls which features are enabled and sets up permissions. Call type settings and permissions can be set from API, or using the [Stream Dashboard](https://dashboard.getstream.io/). +- Calls IDs can be reused, which means they can be joined multiple times, so it's possible to set up recurring calls. + +You can optionally restrict call access by providing a list of existing users. + +It's also possible to store any custom data with the call object. + + + + +```js +const callType = 'default'; +const callId = 'my-first-call'; +const call = client.video.call(callType, callId); + +call.create({ data: { created_by_id: 'john' } }); + +// optionally provide additional data +call.create({ + data: { + created_by_id: 'john', + // Call members need to be existing users + members: [{ user_id: 'john', role: 'admin' }, { user_id: 'jack' }], + custom: { + color: 'blue', + }, + }, +}); +``` + + + + +```py +from getstream.models.call_request import CallRequest + +call = client.video.call("default", "id") +response = call.create( + data=CallRequest( + created_by_id="sacha", + ), +) + +//optionally provide additional data +response = call.create( + data=CallRequest( + created_by_id="sacha", + // Call members need to be existing users + members=[ + MemberRequest(user_id: "john", role: "admin"), + MemberRequest(user_id: "jack"), + ], + custom={"color": "blue"}, + ), +) +``` + + + + + +```bash +curl -X POST "https://video.stream-io-api.com/video/call/default/${CALL_ID}?api_key=${API_KEY}" \ +-H "Content-Type: application/json" \ +-H "Authorization: ${JWT_TOKEN}" \ +-d '{ + "data": { + "created_by_id": "sacha@getstream.io", + "settings_override": { "audio": { "access_request_enabled": false } } + }, + "members": [ { "role": "speaker", "user_id": "sacha@getstream.io" } ] +}' +``` + + + diff --git a/docusaurus/video/docusaurus/docs/api/_common_/manage-call-members.mdx b/docusaurus/video/docusaurus/docs/api/_common_/manage-call-members.mdx new file mode 100644 index 00000000..393218e7 --- /dev/null +++ b/docusaurus/video/docusaurus/docs/api/_common_/manage-call-members.mdx @@ -0,0 +1,70 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +You can restrict call access by defining a list of members who are allowed to join the call. Call members need to be existing users. Every call member has a call-level role, [you can configure roles](/api/call_types/permissions/) on the call type. + +Call members can receive [push notifications](/api/call_types/settings/#push-notifications-settings). + + + + +```js +// Call members need to be existing users +call.updateCallMembers({ + // You can add new members + // You can also update the role of existing members + update_members: [{ user_id: 'sara' }, { user_id: 'emily', role: 'admin' }], +}); +``` + + + + +```py +call.update_members(update_members=[ + MemberRequest(user_id: "sara"), + MemberRequest(user_id: "emily", role: "admin")]) +``` + + + + +```bash +curl -X PUT "https://video.stream-io-api.com/video/call/default/${CALL_ID}/members?api_key=${API_KEY}" \ +-H "Content-Type: application/json" \ +-H "Authorization: ${JWT_TOKEN}" \ +-d '{ + "update_members": [ + { "user_id": "sara" }, + { "user_id": "emily", "role": "admin" } + ] +}' +``` + + + + +You can also remove call members: + + + + +```js +call.updateCallMembers({ + remove_members: ['sara'], +}); +``` + + + + +```py +call.update_members( + remove_members=[ + MemberRequest(user_id: 'jack', role: 'admin') + ] +) +``` + + + diff --git a/docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx b/docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx new file mode 100644 index 00000000..09d2607c --- /dev/null +++ b/docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx @@ -0,0 +1,55 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +Default call settings are inherited from the [call type](/api/call_types/settings/). These settings can be overridden if necessary. + + + + +```js +call.update({ + settings_override: { + audio: { mic_default_on: true, default_device: 'speaker' }, + }, +}); + +// or to update custom data +call.update({ custom: { color: 'red' } }); +``` + + + + +```py +call.update( +settings_override=CallSettingsRequest( + audio=AudioSettingsRequest( + mic_default_on=True, + default_device="speaker", + ), +) +) + +// or to update custom data +call.update(custom: { 'color': 'red' }); +``` + + + + +```bash +curl -X PUT "https://video.stream-io-api.com/video/call/default/${CALL_ID}?api_key=${API_KEY}" \ +-H "Content-Type: application/json" \ +-H "Authorization: ${JWT_TOKEN}" \ +-d '{ + "settings_override": { + "audio": { + "mic_default_on": true + } + } +}' + +``` + + + diff --git a/docusaurus/video/docusaurus/docs/api/basics/calls.mdx b/docusaurus/video/docusaurus/docs/api/basics/calls.mdx index acc81029..b5a91f06 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/calls.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/calls.mdx @@ -7,200 +7,21 @@ title: Calls import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; +import CreateCall from '../_common_/create-call.mdx'; +import CallMembers from '../_common_/manage-call-members.mdx'; +import UpdateCall from '../_common_/update-call.mdx'; ## Creating calls -You can create a call by providing the call type and an ID: - -- The [call type](call_types/builtin) controls which features are enabled and sets up permissions. -- Calls IDs can be reused, which means they can be joined multiple times, so it's possible to set up recurring calls. - -You can optionally restrict call access by providing a list of users. - - - - -```js -const callType = 'default'; -const callId = 'my-first-call'; -const call = client.video.call(callType, callId); - -call.create({ data: { created_by_id: 'john' } }); -// or -call.getOrCreate({ data: { created_by_id: 'john' } }); - -// optionally provide additional data -call.create({ - data: { - created_by_id: 'john', - members: [{ user_id: 'john', role: 'admin' }, { user_id: 'jack' }], - }, -}); -``` - - - - -```py -# create a call -call.create( - data=CallRequest( - created_by_id='john' - ) -) -# create a call with more data -call.create( - data=CallRequest( - created_by_id='john', - members=[ - MemberRequest( - user_id: 'john', - role: 'admin' - ), - MemberRequest( - user_id: 'jack' - ) - ] - ), -) -``` - - - - - -```bash -curl -X POST "https://video.stream-io-api.com/video/call/default/${CALL_ID}?api_key=${API_KEY}" \ --H "Content-Type: application/json" \ --H "Authorization: ${JWT_TOKEN}" \ --d '{ - "data": { - "created_by_id": "sacha@getstream.io", - "settings_override": { "audio": { "access_request_enabled": false } } - }, - "members": [ { "role": "speaker", "user_id": "sacha@getstream.io" } ] -}' -``` - - - + ## Updating calls -- Most of the call type settings can be overridden on a call level. -- Custom data can also be stored for calls. - - - - -```js -call.update({ - settings_override: { - audio: { mic_default_on: true, default_device: 'speaker' }, - }, -}); - -// or to update custom data -call.update({ custom: { color: 'red' } }); -``` - - - - -```py -# update call settings -call.update( - settings_override=CallSettingsRequest( - audio=AudioSettingsRequest( - mic_default_on=True, - ), - ), -) - -# update call with custom data -call.update( - custom={'color': 'red'} -) -``` - - - - -```bash -curl -X PUT "https://video.stream-io-api.com/video/call/default/${CALL_ID}?api_key=${API_KEY}" \ --H "Content-Type: application/json" \ --H "Authorization: ${JWT_TOKEN}" \ --d '{ - "settings_override": { - "audio": { - "mic_default_on": true - } - } -}' - -``` - - - + ## Manage call members -Call members can be added and removed as necessary. Their roles can also be changed. - - - - -```js -// update or add call members -call.updateCallMembers({ - update_members: [{ user_id: 'sara' }, { user_id: 'jack', role: 'admin' }], -}); - -// remove call members -call.updateCallMembers({ - remove_members: ['sara'], -}); -``` - - - - -```py -# update or add call members - -call.update_members( - members=[ - MemberRequest(user_id: 'sara'), - MemberRequest(user_id: 'jack', role: 'admin') - ] -) - -# remove call members -# Assuming the updated call members are 'sara' and 'jack' -call.update_members( - members=[ - MemberRequest(user_id: 'jack', role: 'admin') - ] -) -``` - - - - -```bash -curl -X PUT "https://video.stream-io-api.com/video/call/default/${CALL_ID}/members?api_key=${API_KEY}" \ --H "Content-Type: application/json" \ --H "Authorization: ${JWT_TOKEN}" \ --d '{ - "update_members": [ - { "user_id": "sara" }, - { "user_id": "emily", "role": "admin" } - ] -}' -``` - - - + ## Query calls diff --git a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx index 2c944e3c..c8204e93 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx @@ -9,6 +9,9 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import RTMP from '../_common_/rtmp.mdx'; import Broadcast from '../_common_/broadcast.mdx'; +import CreateCall from '../_common_/create-call.mdx'; +import CallMembers from '../_common_/manage-call-members.mdx'; +import UpdateCall from '../_common_/update-call.mdx'; Stream powers [Chat Messaging](https://getstream.io/chat/), [Video & Audio](https://getstream.io/video/), and [Activity Feeds](https://getstream.io/activity-feeds/) for billions of global end-users across thousands of different apps. @@ -134,204 +137,12 @@ token = client.create_token("admin-user") ## Creating a call -You can create a call by providing the call type and an ID: + -- The [call type](call_types/builtin) controls which features are enabled and sets up permissions. Call type settings and permissions can be set from API, or using the [Stream Dashboard](https://dashboard.getstream.io/). -- Calls IDs can be reused, which means they can be joined multiple times, so it's possible to set up recurring calls. +## Call members -You can optionally restrict call access by providing a list of existing users. - -It's also possible to store any custom data with the call object. - - - - -```js -const callType = 'default'; -const callId = 'my-first-call'; -const call = client.video.call(callType, callId); - -call.create({ data: { created_by_id: 'john' } }); - -// optionally provide additional data -call.create({ - data: { - created_by_id: 'john', - // Call members need to be existing users - members: [{ user_id: 'john', role: 'admin' }, { user_id: 'jack' }], - custom: { - color: 'blue', - }, - }, -}); -``` - - - - -```py -from getstream.models.call_request import CallRequest - -call = client.video.call("default", "id") -response = call.create( - data=CallRequest( - created_by_id="sacha", - ), -) - -//optionally provide additional data -response = call.create( - data=CallRequest( - created_by_id="sacha", - // Call members need to be existing users - members=[ - MemberRequest(user_id: "john", role: "admin"), - MemberRequest(user_id: "jack"), - ], - custom={"color": "blue"}, - ), -) -``` - - - - - -```bash -curl -X POST "https://video.stream-io-api.com/video/call/default/${CALL_ID}?api_key=${API_KEY}" \ --H "Content-Type: application/json" \ --H "Authorization: ${JWT_TOKEN}" \ --d '{ - "data": { - "created_by_id": "sacha@getstream.io", - "settings_override": { "audio": { "access_request_enabled": false } } - }, - "members": [ { "role": "speaker", "user_id": "sacha@getstream.io" } ] -}' -``` - - - - -## Adding members to a call - -You can restrict call access by defining a list of members who are allowed to join the call. Call members need to be existing users. Every call member has a call-level role, [you can configure roles](call_types/permissions/) on the call type. - -Call members can receive [push notifications](../../call_types/settings/#push-notifications-settings). - - - - -```js -// Call members need to be existing users -call.updateCallMembers({ - update_members: [{ user_id: 'sara' }, { user_id: 'emily', role: 'admin' }], -}); -``` - - - - -```py -call.update_members(update_members=[ - MemberRequest(user_id: "sara"), - MemberRequest(user_id: "emily", role: "admin")]) -``` - - - - -```bash -curl -X PUT "https://video.stream-io-api.com/video/call/default/${CALL_ID}/members?api_key=${API_KEY}" \ --H "Content-Type: application/json" \ --H "Authorization: ${JWT_TOKEN}" \ --d '{ - "update_members": [ - { "user_id": "sara" }, - { "user_id": "emily", "role": "admin" } - ] -}' -``` - - - - -## Remove members - - - - -```js -call.updateCallMembers({ - remove_members: ['sara'], -}); -``` - - - - -```py -call.update_members( - remove_members=[ - MemberRequest(user_id: 'jack', role: 'admin') - ] -) -``` - - - + ## Updating a call -Default call settings are inherited from the [call type](call_types/settings/). These settings can be overridden if necessary. - - - - -```js -call.update({ - settings_override: { - audio: { mic_default_on: true, default_device: 'speaker' }, - }, -}); - -// or to update custom data -call.update({ custom: { color: 'red' } }); -``` - - - - -```py -call.update( -settings_override=CallSettingsRequest( - audio=AudioSettingsRequest( - mic_default_on=True, - default_device="speaker", - ), -) -) - -// or to update custom data -call.update(custom: { 'color': 'red' }); -``` - - - - -```bash -curl -X PUT "https://video.stream-io-api.com/video/call/default/${CALL_ID}?api_key=${API_KEY}" \ --H "Content-Type: application/json" \ --H "Authorization: ${JWT_TOKEN}" \ --d '{ - "settings_override": { - "audio": { - "mic_default_on": true - } - } -}' - -``` - - - + From e5846dce6668c139ec5f472968237dde82e0850a Mon Sep 17 00:00:00 2001 From: sachaarbonel Date: Tue, 7 Nov 2023 18:16:34 +0100 Subject: [PATCH 13/27] typos --- docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx | 2 +- .../video/docusaurus/docs/api/basics/authentication.mdx | 4 ++-- .../video/docusaurus/docs/api/recording/recording_calls.mdx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx b/docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx index 09d2607c..f0cf92e3 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx @@ -31,7 +31,7 @@ settings_override=CallSettingsRequest( ) // or to update custom data -call.update(custom: { 'color': 'red' }); +call.update(custom= { 'color': 'red' }) ``` diff --git a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx index a26f0012..7a86f956 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx @@ -186,14 +186,14 @@ client.deactivate_user( user_id= '', ) -// reactivate +# reactivate client.reactivate_users( user_ids= [''], ) client.delete_user( user_id= '' ) -//restore +# restore client.restore_users( user_ids= [''] ) ``` diff --git a/docusaurus/video/docusaurus/docs/api/recording/recording_calls.mdx b/docusaurus/video/docusaurus/docs/api/recording/recording_calls.mdx index 530bde6d..9752c808 100644 --- a/docusaurus/video/docusaurus/docs/api/recording/recording_calls.mdx +++ b/docusaurus/video/docusaurus/docs/api/recording/recording_calls.mdx @@ -68,7 +68,7 @@ call.listRecordings(); ```py -call.list_recordings(); +call.list_recordings() ``` From fdd6e82ac24fcb103cefd7019049c92fc5ecb273 Mon Sep 17 00:00:00 2001 From: sachaarbonel Date: Wed, 8 Nov 2023 11:04:49 +0100 Subject: [PATCH 14/27] typos --- docusaurus/video/docusaurus/docs/api/_common_/broadcast.mdx | 2 +- .../video/docusaurus/docs/api/_common_/create-call.mdx | 4 ++-- docusaurus/video/docusaurus/docs/api/_common_/go_live.mdx | 2 +- .../video/docusaurus/docs/api/_common_/update-call.mdx | 2 +- .../video/docusaurus/docs/api/basics/authentication.mdx | 2 +- .../video/docusaurus/docs/api/call_types/geofencing.mdx | 2 +- .../video/docusaurus/docs/api/call_types/manage-types.mdx | 2 +- .../video/docusaurus/docs/api/call_types/settings.mdx | 2 +- .../video/docusaurus/docs/api/moderation/overview.mdx | 6 +++--- docusaurus/video/docusaurus/docs/api/streaming/overview.mdx | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/_common_/broadcast.mdx b/docusaurus/video/docusaurus/docs/api/_common_/broadcast.mdx index e19a8bef..90967231 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/broadcast.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/broadcast.mdx @@ -17,7 +17,7 @@ call.stopHLSBroadcasting(); ```py call.start_broadcasting() -// to end broadcasting +# to end broadcasting call.stop_broadcasting() ``` diff --git a/docusaurus/video/docusaurus/docs/api/_common_/create-call.mdx b/docusaurus/video/docusaurus/docs/api/_common_/create-call.mdx index bb31a425..7ede25a1 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/create-call.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/create-call.mdx @@ -46,11 +46,11 @@ response = call.create( ), ) -//optionally provide additional data +# optionally provide additional data response = call.create( data=CallRequest( created_by_id="sacha", - // Call members need to be existing users + # Call members need to be existing users members=[ MemberRequest(user_id: "john", role: "admin"), MemberRequest(user_id: "jack"), diff --git a/docusaurus/video/docusaurus/docs/api/_common_/go_live.mdx b/docusaurus/video/docusaurus/docs/api/_common_/go_live.mdx index 2e560a19..71fc7261 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/go_live.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/go_live.mdx @@ -15,7 +15,7 @@ call.goLive({ start_hls: true, start_recording: true }); ```py -call.go_live() +call.go_live(start_hls=True, start_recording=True) ``` diff --git a/docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx b/docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx index f0cf92e3..6a81c2d7 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx @@ -30,7 +30,7 @@ settings_override=CallSettingsRequest( ) ) -// or to update custom data +# or to update custom data call.update(custom= { 'color': 'red' }) ``` diff --git a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx index 7a86f956..a1c63668 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx @@ -109,7 +109,7 @@ user = UserRequest( users[user.id] = user client.upsert_users(users=users) -// or +# or client.update_users_partial( users= [ { diff --git a/docusaurus/video/docusaurus/docs/api/call_types/geofencing.mdx b/docusaurus/video/docusaurus/docs/api/call_types/geofencing.mdx index 95b4c445..28d98afb 100644 --- a/docusaurus/video/docusaurus/docs/api/call_types/geofencing.mdx +++ b/docusaurus/video/docusaurus/docs/api/call_types/geofencing.mdx @@ -63,7 +63,7 @@ client.video.create_call_type( ), ) -//override settings on call level +# override settings on call level call.create( data = CallRequest( created_by_id= 'john', diff --git a/docusaurus/video/docusaurus/docs/api/call_types/manage-types.mdx b/docusaurus/video/docusaurus/docs/api/call_types/manage-types.mdx index 9af84900..ff8e54bc 100644 --- a/docusaurus/video/docusaurus/docs/api/call_types/manage-types.mdx +++ b/docusaurus/video/docusaurus/docs/api/call_types/manage-types.mdx @@ -26,7 +26,7 @@ client.getCallType({name: 'livestream'}); ```py client.video.list_call_types() -//or +# or client.get_call_type(name= 'livestream') ``` diff --git a/docusaurus/video/docusaurus/docs/api/call_types/settings.mdx b/docusaurus/video/docusaurus/docs/api/call_types/settings.mdx index b5747e1d..9b923205 100644 --- a/docusaurus/video/docusaurus/docs/api/call_types/settings.mdx +++ b/docusaurus/video/docusaurus/docs/api/call_types/settings.mdx @@ -65,7 +65,7 @@ client.video.create_call_type( ), ) -// override settings on call level +# override settings on call level call.create( data=CallRequest( created_by_id= 'john', diff --git a/docusaurus/video/docusaurus/docs/api/moderation/overview.mdx b/docusaurus/video/docusaurus/docs/api/moderation/overview.mdx index f18d9703..c14050fe 100644 --- a/docusaurus/video/docusaurus/docs/api/moderation/overview.mdx +++ b/docusaurus/video/docusaurus/docs/api/moderation/overview.mdx @@ -37,10 +37,10 @@ call.unblockUser({ user_id: 'sara' }); ```py -// Block user +# Block user call.block_user( user_id='sara' ) -// Unblock user +# Unblock user call.unblock_user( user_id= 'sara' ) ``` @@ -95,7 +95,7 @@ call.muteUsers({ ```py -// You can specify which kind of stream(s) to mute +# You can specify which kind of stream(s) to mute call.mute_users( mute_all_users= True, audio=True, diff --git a/docusaurus/video/docusaurus/docs/api/streaming/overview.mdx b/docusaurus/video/docusaurus/docs/api/streaming/overview.mdx index 507755bd..798403f9 100644 --- a/docusaurus/video/docusaurus/docs/api/streaming/overview.mdx +++ b/docusaurus/video/docusaurus/docs/api/streaming/overview.mdx @@ -50,7 +50,7 @@ call = client.video.call('livestream', callId) response = call.create( data= CallRequest( created_by_id= 'john', - // You can add multiple hosts if you want to + # You can add multiple hosts if you want to members= [MemberRequest( user_id= 'john', role= 'host' )], ), ) From 22ca07545e10b2d18f5a8668bca2deea1186f721 Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Wed, 8 Nov 2023 11:52:17 +0100 Subject: [PATCH 15/27] test --- docusaurus/video/docusaurus/docs/api/basics/calls.mdx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/basics/calls.mdx b/docusaurus/video/docusaurus/docs/api/basics/calls.mdx index b5a91f06..677ed3bb 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/calls.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/calls.mdx @@ -10,6 +10,7 @@ import TabItem from '@theme/TabItem'; import CreateCall from '../_common_/create-call.mdx'; import CallMembers from '../_common_/manage-call-members.mdx'; import UpdateCall from '../_common_/update-call.mdx'; +import FilterConditions from '../../../shared/_filter-operators.mdx'; ## Creating calls @@ -89,7 +90,7 @@ client.query_calls( -Filter expressions support multiple match criteria, and it's also possible to combine filters. For more information, visit the [filter operators](https://getstream.io/chat/docs/node/query_syntax_operators/?language=javascript) guide. + ## Query call members @@ -149,4 +150,4 @@ call.query_members(
-Filter expressions support multiple match criteria, and it's also possible to combine filters. For more information, visit the [filter operators](https://getstream.io/chat/docs/node/query_syntax_operators/?language=javascript) guide. + From 57a3351ca246c5eeac65b05e2aa09027a1fe6690 Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Wed, 8 Nov 2023 12:23:09 +0100 Subject: [PATCH 16/27] Update query examples --- .../docusaurus/docs/api/basics/calls.mdx | 88 +++++++++++++++++-- 1 file changed, 82 insertions(+), 6 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/basics/calls.mdx b/docusaurus/video/docusaurus/docs/api/basics/calls.mdx index 677ed3bb..70faf291 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/calls.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/calls.mdx @@ -11,6 +11,8 @@ import CreateCall from '../_common_/create-call.mdx'; import CallMembers from '../_common_/manage-call-members.mdx'; import UpdateCall from '../_common_/update-call.mdx'; import FilterConditions from '../../../shared/_filter-operators.mdx'; +import CallFilters from '../../../shared/video/_call-filters.mdx'; +import CallMemberFilters from '../../../shared/video/_call-member-filters.mdx'; ## Creating calls @@ -32,8 +34,12 @@ For many video calling, live stream, or audio rooms apps, you'll want to show: - Calls that are currently live - Popular live streams / audio rooms with a link to the recording +### Examples + Below you can find a few examples of different queries: +#### Sorting and pagination + @@ -53,11 +59,6 @@ client.video.queryCalls({ ...queryCallsReq, next: response.next, }); - -// filtering -client.video.queryCalls({ - filter_conditions: { backstage: { $eq: false } }, -}); ``` @@ -80,8 +81,27 @@ client.query_calls( limit=2, next=response.data().next ) +``` -# filtering + + + +#### Query live calls + + + + +```js +client.video.queryCalls({ + filter_conditions: { backstage: { $eq: false } }, +}); +``` + + + + + +```py client.query_calls( filter_conditions={'backstage': {'$eq': False}} ) @@ -90,6 +110,58 @@ client.query_calls( +#### Query upcoming calls + + + + +```js +const mins30 = 1000 * 60 * 60 * 30; +const inNext30mins = new Date(Date.now() + mins30); +client.video.queryCalls({ + filter_conditions: { + starts_at: { $gt: inNext30mins.toISOString() }, + }, +}); +``` + + + + + +```py + +``` + + + + +#### Query ongoing calls + + + + +```js +client.video.queryCalls({ + filter_conditions: { ongoing: { $eq: true } }, +}); +``` + + + + + +```py + +``` + + + + +### Possible filter options + + + ## Query call members @@ -150,4 +222,8 @@ call.query_members( +### Possible filter options + + + From ff2dc992faddad9ec791d1154c6979a77010e5b3 Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Wed, 8 Nov 2023 14:00:56 +0100 Subject: [PATCH 17/27] Update calls page --- .../video/docusaurus/docs/api/basics/calls.mdx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/basics/calls.mdx b/docusaurus/video/docusaurus/docs/api/basics/calls.mdx index 70faf291..ffac59be 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/calls.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/calls.mdx @@ -13,6 +13,8 @@ import UpdateCall from '../_common_/update-call.mdx'; import FilterConditions from '../../../shared/_filter-operators.mdx'; import CallFilters from '../../../shared/video/_call-filters.mdx'; import CallMemberFilters from '../../../shared/video/_call-member-filters.mdx'; +import CallSort from '../../../shared/video/_call-sort-fields.mdx'; +import CallMemberSort from '../../../shared/video/_call-member-sort-fields.mdx'; ## Creating calls @@ -158,7 +160,11 @@ client.video.queryCalls({ -### Possible filter options +### Sort options + + + +### Filter options @@ -222,7 +228,11 @@ call.query_members( -### Possible filter options +### Sort options + + + +### Filter options From 9a161b976ab852421aa79f22a1d19f77f58b7e82 Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Wed, 8 Nov 2023 14:37:05 +0100 Subject: [PATCH 18/27] Update streaming section --- .../docusaurus/docs/api/_common_/rtmp.mdx | 5 ++-- .../docs/api/streaming/overview.mdx | 26 +++++++++---------- .../docusaurus/docs/api/streaming/rtmp.mdx | 6 +++-- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx b/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx index f14ddc7b..18a8d6f2 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx @@ -1,12 +1,11 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; - ```js -const resp = await call.getOrCreate({ data: { created_by_id: 'john' } }); +const resp = await call.get(); // user ID of an existing user const userId = 'jane'; const token = client.createToken(userId); @@ -30,4 +29,4 @@ rtmp_url = response.data().call.ingress.rtmp.address ``` - \ No newline at end of file + diff --git a/docusaurus/video/docusaurus/docs/api/streaming/overview.mdx b/docusaurus/video/docusaurus/docs/api/streaming/overview.mdx index 798403f9..f1051f29 100644 --- a/docusaurus/video/docusaurus/docs/api/streaming/overview.mdx +++ b/docusaurus/video/docusaurus/docs/api/streaming/overview.mdx @@ -13,14 +13,20 @@ import RTMP from '../_common_/rtmp.mdx'; In this section, we are going to explain how you can use Stream to power different livestream use cases. -Stream video allows you to power ultra-low-latency streaming (hundreds of milliseconds). This is made possible by our worldwide edge infrastructure, which supports WebRTC for consuming and sending video. +Stream supports HLS and WebRTC-based livestreams. + +Using WebRTC yields the best user experience: + +- Stream video allows you to power ultra-low-latency streaming (hundreds of milliseconds). This is made possible by our worldwide edge infrastructure, which supports WebRTC for consuming and sending video. +- WebRTC livestreams can be interactive (users can send reactions, messages, etc.). This is not possible with other protocols (such as HLS). + +[Let us know if you wish to use other streaming protocols.](https://github.com/GetStream/protocol/discussions/127) Other important features related to livestream that are discussed in this section: - Multiple streams & co-hosts - RTMP in and WebRTC input - Exporting to HLS -- Recording ## Quickstart @@ -55,6 +61,7 @@ response = call.create( ), ) ``` + @@ -71,19 +78,14 @@ All we need to do in this case is call the `GoLive` method on the call object, a For more information, see the [Backstage page](../backstage). -### Test watching the stream +### Sending video from browser or mobile with WebRTC -The Stream API supports two different kinds of streams: +For testing purposes, you can use this [simple example host application](https://codesandbox.io/s/javascript-livestream-host-3hs4vt). You can open the application multiple times which allows you to have multiple hosts, who can send multiple audio/video streams. Don't forget to provide the necessary credentials before testing. -- [WebRTC](../webrtc) -- [HLS](../hls) +### Watching the stream For testing purposes, you can use this [simple example application](https://codesandbox.io/s/javascript-livestream-viewer-lwzgmw) that can play WebRTC and HLS streams as well. Don't forget to provide the necessary credentials before testing. -### Test sending video via WebRTC - -For testing purposes, you can use this [simple example host application](https://codesandbox.io/s/javascript-livestream-host-3hs4vt). You can open the application multiple times which allows you to have multiple hosts, who can send multiple audio/video streams. Don't forget to provide the necessary credentials before testing. - ### Test sending video via RTMP using OBS Almost all livestream software and hardware supports RTMP. Our API supports using third-party software for streaming using RTMP. @@ -105,7 +107,3 @@ Press start streaming in OBS. The RTMP stream will now show up in your call just You can test the livestream with the test application linked above. For more information on this topic, see the [RTMP page](../rtmp). - -## Recording - -Liverstreams (and any other calls) can be recorded for later use. For more information see the [Recording section](../../recording/calls). diff --git a/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx b/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx index 90637567..99468cb4 100644 --- a/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx +++ b/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx @@ -2,16 +2,18 @@ id: rtmp sidebar_position: 3 slug: /streaming/rtmp -title: RTMP +title: RTMP input --- import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -## RTMP support overview +## RTMP input support overview Almost all livestream software and hardware supports RTMP. Our API supports using third-party software for streaming using RTMP. +_Please not that this page is about publishing video/audio using RTMP, **NOT** watching livestreams using RTMP._ + ## RTMP publishing This is how you can acquire the necessary information for publishing RTMP using a third-party software. From 18698b84bb5179512ed310d41930b642bc35fbe3 Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Wed, 8 Nov 2023 14:51:05 +0100 Subject: [PATCH 19/27] Update RTMP code snippets --- docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx | 5 +++++ docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx b/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx index 18a8d6f2..b9c0fde4 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx @@ -8,6 +8,11 @@ import TabItem from '@theme/TabItem'; const resp = await call.get(); // user ID of an existing user const userId = 'jane'; +await client.upsertUsers({ + users: { + [userId]: { id: userId }, + }, +}); const token = client.createToken(userId); const address = resp.call.ingress.rtmp.address.replace( diff --git a/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx b/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx index 99468cb4..40bc130b 100644 --- a/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx +++ b/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx @@ -25,6 +25,11 @@ This is how you can acquire the necessary information for publishing RTMP using const resp = await call.getOrCreate({ data: { created_by_id: 'john' } }); // user ID of an existing user const userId = 'jane'; +await client.upsertUsers({ + users: { + [userId]: { id: userId }, + }, +}); const token = client.createToken(userId); const address = resp.call.ingress.rtmp.address.replace( From fa899ae36bc635c0b21dd57147e010295bab52bd Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Wed, 8 Nov 2023 15:12:39 +0100 Subject: [PATCH 20/27] update examples --- .../docusaurus/docs/api/_common_/manage-call-members.mdx | 2 ++ .../video/docusaurus/docs/api/basics/authentication.mdx | 1 - .../video/docusaurus/docs/api/basics/get_started.mdx | 7 +++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/_common_/manage-call-members.mdx b/docusaurus/video/docusaurus/docs/api/_common_/manage-call-members.mdx index 393218e7..4370193e 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/manage-call-members.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/manage-call-members.mdx @@ -21,6 +21,8 @@ call.updateCallMembers({ ```py +# Call members need to be existing users +# You can also update the role of existing members call.update_members(update_members=[ MemberRequest(user_id: "sara"), MemberRequest(user_id: "emily", role: "admin")]) diff --git a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx index a1c63668..a7262804 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx @@ -225,7 +225,6 @@ import time # user ID user_id = 'john' -# exp and iat are optional # the token will be valid for 1 hour exp = int(time.time()) + 60 * 60 diff --git a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx index c8204e93..eaf1a01f 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx @@ -124,12 +124,15 @@ client.createToken(userId, exp); ```py users = {} user = UserRequest( -id='john', role="user", custom={"color": "red"}, name="John",image= "link/to/profile/image", +id="john", role="user", custom={"color": "red"}, name="John",image= "link/to/profile/image", ) users[user.id] = user client.upsert_users(users=users) -token = client.create_token("admin-user") +# the token will be valid for 1 hour +exp = int(time.time()) + 60 * 60 + +client.create_token(user_id = "john", expiration = exp) ``` From da959900abb5c1ed3bea23b9dd8ce45b86d4e726 Mon Sep 17 00:00:00 2001 From: sachaarbonel Date: Thu, 9 Nov 2023 10:04:35 +0100 Subject: [PATCH 21/27] python: update query calls --- .../video/docusaurus/docs/api/basics/calls.mdx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/basics/calls.mdx b/docusaurus/video/docusaurus/docs/api/basics/calls.mdx index ffac59be..e6995227 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/calls.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/calls.mdx @@ -104,7 +104,7 @@ client.video.queryCalls({ ```py -client.query_calls( +client.video.query_calls( filter_conditions={'backstage': {'$eq': False}} ) ``` @@ -132,6 +132,12 @@ client.video.queryCalls({ ```py +from datetime import datetime, timedelta +min30s = timedelta(minutes=30) +in_next_30_mins = datetime.now() + min30s +client.video.query_calls( + filter_conditions={'starts_at': {'$gt': in_next_30_mins.isoformat()}} +) ``` @@ -154,7 +160,9 @@ client.video.queryCalls({ ```py - +client.video.query_calls( + filter_conditions={'ongoing': {'$eq': True}} +) ``` From 9f3d7f927264b36e7a5c1b8e3d893e6c407e961d Mon Sep 17 00:00:00 2001 From: sachaarbonel Date: Thu, 9 Nov 2023 10:07:28 +0100 Subject: [PATCH 22/27] update rtmp --- .../video/docusaurus/docs/api/_common_/rtmp.mdx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx b/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx index b9c0fde4..1019ff42 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx @@ -25,12 +25,17 @@ const address = resp.call.ingress.rtmp.address.replace( ```py -response = call.create( - data=CallRequest( - created_by_id="sacha", - ), - ) -rtmp_url = response.data().call.ingress.rtmp.address +resp = call.get() +# user ID of an existing user +user_id = 'jane' +client.upsert_users( + users={ + user_id: {'id': user_id} + } +) +token = client.create_token(user_id) + +rtmp_url = response.data().call.ingress.rtmp.address.replace('', token) ``` From c1a6c32a4d55f25e95712eeda5975c620bf58002 Mon Sep 17 00:00:00 2001 From: sachaarbonel Date: Thu, 9 Nov 2023 10:13:28 +0100 Subject: [PATCH 23/27] ensure exp is always set to 1h --- docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx | 6 +++++- docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx b/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx index 1019ff42..acb8d311 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx @@ -33,7 +33,11 @@ client.upsert_users( user_id: {'id': user_id} } ) -token = client.create_token(user_id) + +# the token will be valid for 1 hour +exp = int(time.time()) + 60 * 60 + +token = client.create_token(user_id,expiration=exp) rtmp_url = response.data().call.ingress.rtmp.address.replace('', token) ``` diff --git a/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx b/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx index 40bc130b..35aa38e5 100644 --- a/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx +++ b/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx @@ -51,7 +51,11 @@ response = call.create( # user ID of an existing user userId = 'jane' -token = client.create_token(userId) + +# the token will be valid for 1 hour +exp = int(time.time()) + 60 * 60 + +token = client.create_token(userId, expiration = exp) # replace in rtmp address with actual token address = response.data().call.ingress.rtmp.address.replace('', token) From dec7995668b3bc61cb7aebd5a1c8fed315779b92 Mon Sep 17 00:00:00 2001 From: sachaarbonel Date: Thu, 9 Nov 2023 10:39:12 +0100 Subject: [PATCH 24/27] delete_user -> delete_users --- docusaurus/video/docusaurus/docs/api/basics/authentication.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx index a7262804..1466d773 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx @@ -191,7 +191,7 @@ client.reactivate_users( user_ids= [''], ) -client.delete_user( user_id= '' ) +client.delete_users( user_ids= [''] ) # restore client.restore_users( user_ids= [''] ) From 212777d59ffafa35766165072716480d9b73741e Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Fri, 10 Nov 2023 09:59:37 +0100 Subject: [PATCH 25/27] Update RTMP address --- .../video/docusaurus/docs/api/_common_/rtmp.mdx | 14 ++++++++------ .../video/docusaurus/docs/api/streaming/rtmp.mdx | 13 +++++++------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx b/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx index acb8d311..3dd9713e 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx @@ -6,19 +6,21 @@ import TabItem from '@theme/TabItem'; ```js const resp = await call.get(); -// user ID of an existing user + +// userId of existing user const userId = 'jane'; await client.upsertUsers({ users: { - [userId]: { id: userId }, + [userId]: { + id: userId, + }, }, }); const token = client.createToken(userId); +const rtmpURL = resp.call.ingress.rtmp.address; +const streamKey = token; -const address = resp.call.ingress.rtmp.address.replace( - '', - token, -); +console.log(rtmpURL, streamKey); ``` diff --git a/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx b/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx index 35aa38e5..b7cca54e 100644 --- a/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx +++ b/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx @@ -23,19 +23,20 @@ This is how you can acquire the necessary information for publishing RTMP using ```js const resp = await call.getOrCreate({ data: { created_by_id: 'john' } }); -// user ID of an existing user +// userId of existing user const userId = 'jane'; await client.upsertUsers({ users: { - [userId]: { id: userId }, + [userId]: { + id: userId, + }, }, }); const token = client.createToken(userId); +const rtmpURL = resp.call.ingress.rtmp.address; +const streamKey = token; -const address = resp.call.ingress.rtmp.address.replace( - '', - token, -); +console.log(rtmpURL, streamKey); ``` From 14312c2cc4e4d7db0ff7f5e6ebc40027234c3e3d Mon Sep 17 00:00:00 2001 From: sachaarbonel Date: Fri, 10 Nov 2023 10:12:50 +0100 Subject: [PATCH 26/27] Update RTMP address --- docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx | 4 +++- docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx b/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx index 3dd9713e..b197b8b6 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx @@ -41,7 +41,9 @@ exp = int(time.time()) + 60 * 60 token = client.create_token(user_id,expiration=exp) -rtmp_url = response.data().call.ingress.rtmp.address.replace('', token) +rtmp_url = response.data().call.ingress.rtmp.address +stream_key = token +print(rtmp_url, stream_key) ``` diff --git a/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx b/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx index b7cca54e..38834577 100644 --- a/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx +++ b/docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx @@ -58,8 +58,9 @@ exp = int(time.time()) + 60 * 60 token = client.create_token(userId, expiration = exp) -# replace in rtmp address with actual token -address = response.data().call.ingress.rtmp.address.replace('', token) +rtmp_url = response.data().call.ingress.rtmp.address +stream_key = token +print(rtmp_url, stream_key) ``` From 5745d407b8e69d2fd14fe9d74b5128c91cf52f7b Mon Sep 17 00:00:00 2001 From: sachaarbonel Date: Fri, 10 Nov 2023 13:49:48 +0100 Subject: [PATCH 27/27] django snippet --- .../docs/api/basics/authentication.mdx | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx index 1466d773..c24f6192 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx @@ -220,15 +220,26 @@ client.createToken(userId, exp); ```py +# in this example we use Django +# but you can use any framework you like import time +from django.contrib.auth.decorators import login_required +from django.http import JsonResponse -# user ID -user_id = 'john' +# The user token endpoint is protected with the login_required decorator. +@login_required +def create_user_token(request): + # The 'user_id' is retrieved from the request's user instance. + user_id = request.user.id -# the token will be valid for 1 hour -exp = int(time.time()) + 60 * 60 + # the token will be valid for 1 hour + exp = int(time.time()) + 60 * 60 + # Here client is Stream client and it's called with the 'user_id' and the expiration time. + token = client.create_token(user_id, expiration = exp) + + # The token is then returned in the response. + return JsonResponse({'token': token}) -client.create_token(user_id = user_id, expiration = exp) ```