• Stars
    star
    43
  • Rank 623,371 (Top 13 %)
  • Language
    C#
  • License
    Other
  • Created about 5 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Stream Chat official .NET API Client

Official .NET SDK for Stream Chat

.github/workflows/ci.yaml NuGet Badge

Official .NET API client for Stream Chat, a service for building chat applications.
Explore the docs Β»

Code Samples Β· Report Bug Β· Request Feature

πŸ“ About Stream

You can sign up for a Stream account at our Get Started page.

You can use this library to access chat API endpoints server-side.

For the client-side integrations (web and mobile) have a look at the JavaScript, iOS and Android SDK libraries (docs).


🚨 Breaking changes in v1.0 <

The library received many changes in v1.0 to make it easier to use and more maintanable in the future. The main change is that both Channel and Client classes have been separated into small modules that we call clients. (This resambles the structure of our Java library as well.) Main changes:

  • Channel and Client classes are gone, and have been organized into smaller clients in StreamChat.Clients namespace.
  • These clients do not maintain state as Channel used to did earlier where it kept the channelType and channelId in the memory. So this means that you'll need to pass in channelType and channelId to a lot of method calls in IChannelClient.
  • Async method names have Async suffix now.
  • All public methods and classes have documentation.
  • Identifiers has been renamed from ID to Id to follow Microsoft's naming guide. Such as userID -> userId.
  • A lot of data classes have been renamed to make more sense. Such as ChannelObject -> Channel.
  • Data classes have been moved to StreamChat.Models namespace.
  • Full feature parity: all backend APIs are available.
  • Returned values are type of ApiResponse and expose rate limit informaiton with GetRateLimit() method.
  • The folder structure of the project has been reorganized to follow Microsoft's recommendation.
  • Unit tests have been improved. They are smaller, more focused and have cleanup methods.
  • Added .NET 6.0 support.

The proper usage of the library:

var clientFactory = new StreamClientFactory("YourApiKey", "YourApiSecret");
// Note: all client instances can be used as a singleton for the lifetime
// of your application as they don't maintain state.
var userClient = clientFactory.GetUserClient();
var channelClient = clientFactory.GetChannelClient();
var messageClient = clientFactory.GetMessageClient();
var reactionClient = clientFactory.GetReactionClient();

var jamesBond = await userClient.UpsertAsync(new UserRequest { Id = "james_bond" });
var agentM = await userClient.UpsertAsync(new UserRequest { Id = "agent_m" });

var channel = await channelClient.GetOrCreateAsync("messaging", "superHeroChannel", createdBy: jamesBond.Id);
await channelClient.AddMembersAsync(channel.Type, channel.Id, jamesBond.Id, agentM.Id);

var message = await messageClient.SendMessageAsync(channel.Type, channel.Id, jamesBond.Id, "I need a new quest Agent M.");
await reactionClient.SendReactionAsync(message.Id, "like", agentM.Id);

βš™οΈ Installation

$ dotnet add package stream-chat-net

πŸ’‘ Tip: you can find code samples in the samples folder.

✨ Getting started

Import

using StreamChat.Clients;

Initialize client

// Client factory instantiation.
var clientFactory = new StreamClientFactory("YourApiKey", "YourApiSecret");

// Or you can configure some options such as custom HttpClient, HTTP timeouts etc.
var clientFactory = new StreamClientFactory("YourApiKey", "YourApiSecret", opts => opts.Timeout = TimeSpan.FromSeconds(5));

// Get clients from client factory. Note: all clients can be used as a singleton in your application.
var channelClient = clientFactory.GetChannelClient();
var messageClient = clientFactory.GetMessageClient();

Generate a token for client-side usage

var userClient = clientFactory.GetUserClient();

// Without expiration
var token = userClient.CreateToken("bob-1");

// With expiration
var token = userClient.CreateToken("bob-1", expiration: DateTimeOffset.UtcNow.AddHours(1));

Create/Update users

var userClient = clientFactory.GetUserClient();

var bob = new UserRequest
{
    Id = "bob-1",
    Role = Role.Admin,
    Teams = new[] { "red", "blue" } // if multi-tenant enabled
};
bob.SetData("age", 27);

await userClient.UpsertAsync(bob);

// Batch update is also supported
var jane = new UserRequest { Id = "jane"};
var june = new UserRequest { Id = "june"};
var users = await userClient.UpsertManyAsync(new[] { bob, jane, june });

GDPR-like User endpoints

var userClient = clientFactory.GetUserClient();

await userClient.ExportAsync("bob-1");
await userClient.DeactivateAsync("bob-1");
await userClient.ReactivateAsync("bob-1");
await userClient.DeleteAsync("bob-1");

Channel types

var channelTypeClient = clientFactory.GetChannelTypeClient();

var chanTypeConf = new ChannelTypeWithStringCommands
{
    Name = "livechat",
    Automod = Automod.Disabled,
    Commands = new List<string> { Commands.Ban },
    Mutes = true
};
var chanType = await channelTypeClient.CreateChannelTypeAsync(chanTypeConf);

var allChanTypes = await channelTypeClient.ListChannelTypesAsync();

Channels

var channelClient = clientFactory.GetChannelClient();

// Create a channel with members from the start, Bob is the creator
var channel = channelClient.GetOrCreateAsync("messaging", "bob-and-jane", bob.Id, bob.Id, jane.Id);

// Create channel and then add members, Mike is the creator
var channel = channelClient.GetOrCreateAsync("messaging", "bob-and-jane", mike.Id);
channelClient.AddMembersAsync(channel.Type, channel.Id, bob.Id, jane.Id, joe.Id);

Messaging

var messageClient = clientFactory.GetMessageClient();

// Only text
messageClient.SendMessageAsync(channel.Type, channel.Id, bob.Id, "Hey, I'm Bob!");

// With custom data
var msgReq = new MessageRequest { Text = "Hi june!" };
msgReq.SetData("location", "amsterdam");

var bobMessageResp = await messageClient.SendMessageAsync(channelType, channel.Id, msgReq, bob.Id);

// Threads
var juneReply = new MessageRequest { Text = "Long time no see!" };
var juneReplyMessage = await messageClient.SendMessageToThreadAsync(channel.Type, channel.Id, juneReply, june.Id, bobMessageResp.Message.Id)

Reactions

var reactionClient = clientFactory.GetReactionClient();

await reactionClient.SendReactionAsync(message.Id, "like", bob.Id);

var allReactions = await reactionClient.GetReactionsAsync(message.Id);

Moderation

var channelClient = clientFactory.GetChannelClient();
var userClient = clientFactory.GetUserClient();
var flagClient = clientFactory.GetFlagClient();

await channelClient.AddModeratorsAsync(channel.Type, channel.Id, new[] { jane.Id });

await userClient.BanAsync(new BanRequest
{
    Type = channel.Type,
    Id = channel.Id,
    Reason = "reason",
    TargetUserId = bob.Id,
    UserId = jane.Id
});

await flagClient.FlagUserAsync(bob.Id, jane.Id);

Permissions

var permissionClient = clientFactory.GetPermissionClient();

await permissionClient.CreateRoleAsync("channel-boss");

// Assign users to roles (optional message)
await channelClient.AssignRolesAsync(new AssignRoleRequest
{
    AssignRoles = new List<RoleAssignment>
    {
        new RoleAssignment { UserId = bob.ID, ChannelRole = Role.ChannelModerator },
        new RoleAssignment { UserId = june.ID, ChannelRole = "channel-boss" }
    },
    Message = new MessageRequest { Text = "Bob and June just became mods", User = bob }
});

Devices

var deviceClient = clientFactory.GetDeviceClient();

var junePhone = new Device
{
    ID = "iOS Device Token",
    PushProvider = PushProvider.APN,
    UserId = june.ID
};

await deviceClient.AddDeviceAsync(junePhone);

var devices = await deviceClient.GetDevicesAsync(june.Id);

Export Channels

var channelClient = clientFactory.GetChannelClient();
var taskClient = clientFactory.GetTaskClient();

var taskResponse = channelClient.ExportChannelAsync(new ExportChannelRequest { Id = channel.Id, Type = channel.Type });

// Wait for the completion
var complete = false;
var iterations = 0;
AsyncTaskStatusResponse resp = null;
while (!complete && iterations < 1000)
{
    resp = await taskClient.GetTaskStatusAsync(taskResponse.TaskId);
    if (resp.Status == AsyncTaskStatus.Completed)
    {
        complete = true;
        break;
    }
    iterations++;
    await Task.Delay(100);
}

if (complete)
{
    Console.WriteLine(resp.Result["url"]);
}

✍️ Contributing

We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our Contributor License Agreement (CLA) first. See our license file for more details.

Head over to CONTRIBUTING.md for some development tips.

πŸ§‘β€πŸ’» We are hiring!

We've recently closed a $38 million Series B funding round and we keep actively growing. Our APIs are used by more than a billion end-users, and you'll have a chance to make a huge impact on the product within a team of the strongest engineers all over the world.

Check out our current openings and apply via Stream's website.

More Repositories

1

Winds

A Beautiful Open Source RSS & Podcast App Powered by Getstream.io
JavaScript
8,813
star
2

stream-chat-android

πŸ’¬ Android Chat SDK ➜ Stream Chat API. UI component libraries for chat apps. Kotlin & Jetpack Compose messaging SDK for Android chat
Kotlin
1,345
star
3

vg

Virtualgo: Easy and powerful workspace based development for go
Go
1,311
star
4

whatsApp-clone-compose

πŸ“± WhatsApp clone project demonstrates modern Android development built with Jetpack Compose and Stream Chat/Video SDK for Compose.
Kotlin
1,168
star
5

stream-react-example

Use React and Redux to build your own feature-rich and scalable social network app! Visit cabin.getstream.io for an overview of all 8 tutorials and a live demo.
HTML
923
star
6

stream-chat-flutter

Flutter Chat SDK - Build your own chat app experience using Dart, Flutter and the Stream Chat Messaging API.
Dart
839
star
7

stream-chat-react-native

πŸ’¬ React-Native Chat SDK ➜ Stream Chat. Includes a tutorial on building your own chat app experience using React-Native, React-Navigation and Stream
TypeScript
792
star
8

stream-chat-swift

πŸ’¬ iOS Chat SDK in Swift - Build your own app chat experience for iOS using the official Stream Chat API
Swift
750
star
9

purposeful-ios-animations

Meaningful iOS animations built to inspire you in creating useful animations for your apps. Each of the animations here was cloned with SwiftUI. Have you seen an app animation you love to rebuild and add to this repo?, contact [@amos_gyamfi](https://twitter.com/amos_gyamfi) and [@stefanjblos](https://twitter.com/stefanjblos) on Twitter.
Swift
702
star
10

swiftui-spring-animations

This repository serves as your reference and complete guide for SwiftUI Spring Animations. It demonstrates use cases for the various types of spring animations and spring parameters. No more guessing the values of the parameters for spring animations you create for your next iOS app.
Swift
631
star
11

stream-chat-react

React Chat SDK ➜ Stream Chat πŸ’¬
TypeScript
552
star
12

awesome-saas-services

A curated list of the best in class SaaS services for developers and business owners.
475
star
13

webrtc-android

πŸ›°οΈ A versatile WebRTC pre-compiled Android library that reflects the recent WebRTC updates to facilitate real-time video chat for Android and Compose.
Kotlin
465
star
14

stream-django

Django Client - Build Activity Feeds & Streams with GetStream.io
Python
451
star
15

avatarview-android

✨ Supports loading profile images with fractional styles, shapes, borders, indicators, and initials for Android.
Kotlin
429
star
16

sketchbook-compose

🎨 Jetpack Compose canvas library that helps you draw paths, images on canvas with color pickers and palettes.
Kotlin
417
star
17

webrtc-in-jetpack-compose

πŸ“± This project demonstrates WebRTC protocol to facilitate real-time video communications with Jetpack Compose.
Kotlin
372
star
18

AvengersChat

πŸ’™ Android sample Avengers chat application using Stream Chat SDK based on MVVM (ViewModel, Coroutines, Room, Hilt, Repository) architecture.
Kotlin
365
star
19

stream-draw-android

πŸ›₯ Stream Draw is a real-time multiplayer drawing & chat game app built entirely with Jetpack Compose.
Kotlin
334
star
20

stream-video-android

πŸ“² Android Video SDK. Stream's versatile Core + Compose UI component libraries that allow you to build video calling, audio room, and, live streaming apps based on Webrtc running on Stream's global edge network.
Kotlin
334
star
21

stream-js

JS / Browser Client - Build Activity Feeds & Streams with GetStream.io
JavaScript
325
star
22

react-native-example

React Native Activity Feed example application
JavaScript
321
star
23

stream-laravel

Laravel Client - Build Activity Feeds & Streams with GetStream.io
PHP
314
star
24

effects-library

The Effects Library allows developers to create sophisticated and realistic particle systems such as snow, fire, rain, confetti, fireworks, and smoke with no or minimal effort.
Swift
303
star
25

flutter-samples

A collection of sample apps that use Stream
Dart
290
star
26

stream-chat-swiftui

SwiftUI Chat SDK ➜ Stream Chat πŸ’¬
Swift
279
star
27

stream-rails

Rails Client - Build Activity Feeds & Streams with GetStream.io
Ruby
257
star
28

Streamoji

:godmode: Custom emoji rendering library for iOS apps with support for GIF & still images - plug-in extension for UITextView - performance, cache βœ… - Made with πŸ’˜ by @GetStream
Swift
248
star
29

react-native-bidirectional-infinite-scroll

πŸ“œ React Native - Bidirectional Infinite Smooth Scroll
TypeScript
220
star
30

WhatsApp-Clone-Android

Tutorial which teaches you how to build a whatsapp chat clone on android using Kotlin, viewmodels, navigation component and Stream
Kotlin
218
star
31

butterfly

πŸ¦‹ Butterfly helps you to build adaptive and responsive UIs for Android with Jetpack WindowManager.
Kotlin
213
star
32

slack-clone-react-native

Build a slack clone using react-native, Stream and react-navigation
JavaScript
206
star
33

react-native-activity-feed

Official React Native SDK for Activity Feeds
JavaScript
194
star
34

motionscape-app

MotionScape is your animations playground as a developer. You can see all animations and their parameters in effect with beautifully designed and handcrafted animation examples.
Swift
157
star
35

Android-Samples

πŸ“• Provides a list of samples that utilize modern Android tech stacks and Stream Chat SDK for Android and Compose.
Kotlin
154
star
36

node-express-mongo-api

Starter project for a REST API with Node.js, Express & MongoDB πŸ”‹
JavaScript
151
star
37

stream-chat-js

JS / Browser Client - Build Chat with GetStream.io
TypeScript
149
star
38

stream-php

PHP Client - Build Activity Feeds & Streams with GetStream.io
PHP
139
star
39

stream-python

Python Client - Build Activity Feeds & Streams with GetStream.io
Python
136
star
40

react-activity-feed

Stream React Activity Feed Components
TypeScript
135
star
41

stream-node-orm

NodeJS Client - Build Activity Feeds & Streams with GetStream.io
JavaScript
131
star
42

meeting-room-compose

πŸŽ™οΈ A real-time meeting room app built with Jetpack Compose to demonstrate video communications.
Kotlin
130
star
43

flat-list-mvcp

"maintainVisibleContentPosition" prop support for Android react-native
TypeScript
130
star
44

stream-log

πŸ›₯ A lightweight and extensible logger library for Kotlin and Android.
Kotlin
118
star
45

react-native-samples

A collection of sample apps built using GetStream and React Native
JavaScript
116
star
46

website-react-examples

TypeScript
112
star
47

django_twitter

An example app built using getstream.io
Python
108
star
48

flutter-instagram-clone

An Instagram clone using Flutter and Stream Feeds
Dart
104
star
49

accessible-inclusive-ios-animations

Provide ways to limit animations/motion people find jarring in your apps. This repo demonstrates accessible and inclusive iOS animations/motion with practical examples and best practices.
Swift
104
star
50

Stream-Example-Nodejs

An example app built using getstream.io
JavaScript
96
star
51

twitter-clone

Learn how to build a functional Twitter clone using Stream, 100ms, Algolia, RevenueCat and Mux 😎
Swift
92
star
52

react-native-audio-player

JavaScript
86
star
53

stream-video-swift

SwiftUI Video SDK ➑️ Stream Video πŸ“Ή
Swift
85
star
54

stream-ruby

Ruby Client - Build Activity Feeds & Streams with GetStream.io
Ruby
83
star
55

stream-go2

GetStream.io Go client
Go
82
star
56

stream-result

🚊 Railway-oriented library to easily model and handle success/failure for Kotlin, Android, and Retrofit.
Kotlin
81
star
57

stream-chat-unity

πŸ’¬ Unity Chat Plugin by Stream ➜ These assets are the solution for adding an in-game text chat system to your Unity game.
C#
81
star
58

stream-cli

Configure & manage Stream applications from the command line. πŸš€
Go
80
star
59

mongodb-activity-feed

Activity Feed, Timeline, News Feed, Notification Feed with MongoDB, Node and CRDTs
JavaScript
77
star
60

TinyGraphQL

🌸 Simple and lightweight GraphQL query builder for the Swift language - Made with πŸ’˜ by @GetStream
Swift
76
star
61

slack-clone-expo

Slack clone using Expo, Stream and react-navigation
JavaScript
75
star
62

Android-Video-Samples

πŸ“˜ Provides a collection of samples that utilize modern Android tech stacks and Stream Video SDK for Kotlin and Compose.
Kotlin
75
star
63

stream-feed-flutter

Stream Feed official Flutter SDK. Build your own feed experience using Dart and Flutter.
Dart
69
star
64

stream-chat-go

Stream Chat official Golang API Client
Go
65
star
65

Stream-Example-Py

An example app built using getstream.io
CSS
61
star
66

encrypted-web-chat

A web chat application end-to-end encrypted with the Web Crypto API
JavaScript
59
star
67

fullstack-nextjs-whatsapp-clone

A sample codebase showcasing Stream Chat and Video to resembling WhatsApp, using NextJS, TailwindCSS and Vercel.
TypeScript
58
star
68

stream-tutorial-projects

This repo contains SwiftUI, Jetpack Compose & React Native projects for some of the iOS and Android tutorial series in the Stream Developers YouTube channel (https://youtube.com/playlist?list=PLNBhvhkAJG6tJYnY-5oZ1JCp2fBNbVL_6).
Swift
57
star
69

swift-lambda

Ξ» Write HTTP services in Swift, deploy in seconds - Powered by AWS Lambda Runtime & Serverless Framework - Made with πŸ’˜ by @GetStream
Swift
57
star
70

stream-chat-python

Stream Chat official Python API Client
Python
56
star
71

stream-java

Java Client - Build Activity Feeds & Streams with GetStream.io
Java
53
star
72

SwiftUIMessagesUIClone

The SwiftUI Messages Clone consists of layout and composition clones of the iOS Messages app. It has Messages-like bubble and screen effects, reactions, and animations, all created with SwiftUI.
Swift
53
star
73

android-chat-tutorial

Sample apps for the Stream Chat Android SDK's official tutorial
Java
46
star
74

Stream-Example-Parse

Stream-Example-Parse
JavaScript
46
star
75

Stream-Example-PHP

An example app built using getstream.io https://getstream.io
PHP
46
star
76

stream-meteor

Meteor Client - Build Activity Feeds & Streams with GetStream.io
JavaScript
45
star
77

python-chat-example

Chat with Python, Django and React
JavaScript
44
star
78

SwiftUIChristmasTree

🌲 Pure SwiftUI christmas tree with yearly updates. Enjoy πŸŽ„
Swift
43
star
79

stream-chat-dart

Dart SDK - Build Chat with GetStream.io
Dart
42
star
80

stream-video-js

GetStream JavaScript Video SDK
TypeScript
41
star
81

Stream-Example-Go-Cassandra-API

Go-powered API example using Cassandra
Go
38
star
82

Stream-Example-Rails

An example app built using getstream.io
Ruby
38
star
83

Stream-Example-Android

Java
38
star
84

foldable-chat-android

🦚 Foldable chat Android demonstrates adaptive and responsive UIs with Jetpack WindowManager API.
Kotlin
36
star
85

stream-video-flutter

Flutter Video SDK - Build your own video app experience using Dart, Flutter and the Stream Video Messaging API.
Dart
35
star
86

stream-swift

Swift client for Stream API
Swift
35
star
87

stream-chat-angular

πŸ’¬ Angular Chat SDK ➜ Stream Chat. Build a chat app with ease.
TypeScript
34
star
88

stream-net

NET Client - Build Activity Feeds & Streams with GetStream.io
C#
34
star
89

node-restify-mongo-api

Starter project for a REST API with Node.js, Restify & MongoDB πŸ”‹
JavaScript
32
star
90

stream-chat-unreal

The official Unreal SDK for Stream Chat
C++
32
star
91

build-viking-sample

Sample app for Build Viking.
Dart
31
star
92

SwiftUI-open-voip-animations

SwiftUI animations and UI designs for iOS calling, meeting, audio-room, and live streaming use cases. Find something missing? Let @amos_gyamfi know on Twitter.
29
star
93

swift-activity-feed

Stream Swift iOS Activity Feed Components
Swift
29
star
94

stream-chat-ruby

Stream Chat official Ruby API Client
Ruby
29
star
95

sign-in-with-apple-swift-example

iOS + Node.js authentication using Sign in with Apple
Swift
28
star
96

rate_limiter

A pure dart package to apply useful rate limiting strategies on regular functions.
Dart
28
star
97

combase-v1

Open Source White-Label Customer Support Chat – Powered by Stream Chat πŸ—―οΈ
JavaScript
26
star
98

swiftui-iMessage-clone

Swift
24
star
99

react-twitter-clone

JavaScript
23
star
100

psychotherapy-app-ios

πŸ‘©β€πŸ’ΌπŸ“‘ Psychotherapy app with video and chat built using Stream Chat and Dolby.io
Swift
23
star