stream-net 6.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package stream-net --version 6.0.0                
NuGet\Install-Package stream-net -Version 6.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="stream-net" Version="6.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add stream-net --version 6.0.0                
#r "nuget: stream-net, 6.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install stream-net as a Cake Addin
#addin nuget:?package=stream-net&version=6.0.0

// Install stream-net as a Cake Tool
#tool nuget:?package=stream-net&version=6.0.0                

Official .NET SDK for Stream

Build status NuGet Badge

<p align="center"> <img src="./assets/logo.svg" width="50%" height="50%"> </p> <p align="center"> Official .NET API client for Stream, a service for building scalable newsfeeds and activity streams. <br /> <a href="https://getstream.io/activity-feeds/docs/"><strong>Explore the docs ยป</strong></a> <br /> <br /> <a href="https://github.com/GetStream/stream-net/tree/master/samples">Code Samples</a> ยท <a href="https://github.com/GetStream/stream-net/issues">Report Bug</a> ยท <a href="https://github.com/GetStream/stream-net/issues">Request Feature</a> </p>

๐Ÿšจ Breaking changes in v5.0 <

In v5.0.0, we have refactored the library to be more maintainable in the future. Most importantly, we got rid of some complex internal logic (such as tricky json serialization and deserialization, code organization improvements etc.). Also, we made the library more modern such as adding Async postfix to async methods. All public methods have documentation now and a link to the official docs now. This README file's code snippets are updated to reflect the new changes.

Breaking changes:

  • All async methods have Async postfix.
  • Model classes have been moved into Stream.Models namespace.
  • All client classes have interfaces now, and Ref() methods are not static anymore. This will make it easier to the consumers of this library to unit test them.

๐Ÿ“ 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).

โš™๏ธ Installation

$ nuget install stream-net

โœจ Getting started

// Create a client, find your API keys here https://getstream.io/dashboard/
var client = new StreamClient("YOUR_API_KEY", "API_KEY_SECRET");
// From this IStreamClient instance you can access a variety of API endpoints,
// and it is also a factory class for other classes, such as IBatch, ICollections
// IReactions, IStreamFeed etc. Note: all of these clients can be used as a
// singleton as they do not store state.
// Let's take a look at IStreamFeed now.

// Reference a feed
var userFeed1 = client.Feed("user", "1");

// Get 20 activities starting from activity with id last_id (fast id offset pagination)
var results = await userFeed1.GetActivitiesAsync(0, 20, FeedFilter.Where().IdLessThan(last_id));

// Get 10 activities starting from the 5th (slow offset pagination)
var results = await userFeed1.GetActivitiesAsync(5, 10);

// Create a new activity
var activity = new Activity("1", "like", "3")
{
    ForeignId = "post:42"
};

await userFeed1.AddActivityAsync(activity);

// Create a complex activity
var activity = new Activity("1", "run", "1")
{
    ForeignId = "run:1"
};
var course = new Dictionary<string, object>();
course["name"] = "Shevlin Park";
course["distance"] = 10;
activity.SetData("course", course);
await userFeed1.AddActivityAsync(activity);

// Remove an activity by its id
await userFeed1.RemoveActivityAsync("e561de8f-00f1-11e4-b400-0cc47a024be0");

// Remove activities by their foreign_id
await userFeed1.RemoveActivityAsync("post:42", true);

// Let user 1 start following user 42's flat feed
await userFeed1.FollowFeedAsync("flat", "42");

// Let user 1 stop following user 42's flat feed
await userFeed1.UnfollowFeedAsync("flat", "42");

// Retrieve first 10 followers of a feed
await userFeed1.FollowersAsync(0, 10);

// Retrieve 2 to 10 followers
await userFeed1.FollowersAsync(2, 10);

// Retrieve 10 feeds followed by $user_feed_1
await userFeed1.FollowingAsync(0, 10);

// Retrieve 10 feeds followed by $user_feed_1 starting from the 10th (2nd page)
await userFeed1.FollowingAsync(10, 20);

// Check if $user_feed_1 follows specific feeds
await userFeed1.FollowingAsync(0, 2, new[] { "user:42", "user:43" });

// Follow stats
// Count the number of users following this feed
// Count the number of tags are followed by this feed
var stats = await userFeed1.FollowStatsAsync(new[] { "user" }, new[] { "tags" });
Console.WriteLine(stats.Results.Followers.Count);
Console.WriteLine(stats.Results.Following.Count);

// Retrieve activities by their ids
var ids = new[] { "e561de8f-00f1-11e4-b400-0cc47a024be0", "a34ndjsh-00f1-11e4-b400-0c9jdnbn0eb0" };
var activities = await client.Batch.GetActivitiesByIdAsync(ids);

// Retrieve activities by their ForeignID/Time
var foreignIDTimes = new[] { new ForeignIdTime("fid-1", DateTime.Parse("2000-08-19T16:32:32")), new ForeignIdTime("fid-2", DateTime.Parse("2000-08-21T16:32:32")) };
var activities = await client.Batch.GetActivitiesByForeignIdAsync(foreignIDTimes);

// Partially update an activity
var set = new Dictionary<string, object>();
set.Add("custom_field", "new value");
var unset = new[] { "field to remove" };

// By id
await client.ActivityPartialUpdateAsync("e561de8f-00f1-11e4-b400-0cc47a024be0", null, set, unset);

// By foreign id and time
var fidTime = new ForeignIdTime("fid-1", DateTime.Parse("2000-08-19T16:32:32"));
await client.ActivityPartialUpdateAsync(null, fidTime, set, unset);

// Add a reaction to an activity
var activityData = new Activity("bob", "cook", "burger")
{
    ForeignId = "post:42"
};
var activity = await userFeed1.AddActivityAsync(activity);
var r = await client.Reactions.AddAsync("comment", activity.Id, "john");

// Add a reaction to a reaction
var child = await client.Reactions.AddChildAsync(r, "upvote", "john");

// Enrich feed results
var userData = new Dictionary<string, object>()
{
    {"is_admin", true},
    {"nickname","bobby"}
};
var u = await client.Users.AddAsync("timmy", userData);
var userRef = u.Ref();
var a = new Activity(userRef, "add", "post");
var plainActivity = await userFeed1.AddActivityAsync(a);
// Here plainActivity.Actor is just a plain string containing the user ref
var enriched = await userFeed1.GetEnrichedFlatActivitiesAsync();
var actor = enriched.Results.First();
var userID = actor.GetData<string>("id");
var data = actor.GetData<Dictionary<string, object>>("data"); //this is `userData`

// Enrich feed results with reactions
var activityData = new Activity("bob", "cook", "burger")
{
    ForeignId = "post:42"
};
var activity = await userFeed1.AddActivityAsync(activity);
var com = await client.Reactions.AddAsync("comment", activity.Id, "john");
var like = await client.Reactions.AddAsync("like", activity.Id, "maria");

// Fetch reaction counts grouped by reaction kind
var enriched = await userFeed1.GetEnrichedFlatActivitiesAsync(GetOptions.Default.WithReaction(ReactionOption.With().Counts()));
var enrichedActivity = enriched.Results.First();
Console.WriteLine(enrichedActivity.ReactionCounts["like"]); // 1
Console.WriteLine(enrichedActivity.ReactionCounts["comment"]); // 1

// Fetch reactions grouped by reaction kind
var enriched = await userFeed1.GetEnrichedFlatActivitiesAsync(GetOptions.Default.WithReaction(ReactionOption.With().Own()));
var enrichedActivity = enriched.Results.First();
Console.WriteLine(enrichedActivity.OwnReactions["like"]); // is the $like reaction
Console.WriteLine(enrichedActivity.OwnReactions["comment"]); // is the $comment reaction

// All reactions enrichment can be selected
var enriched = await userFeed1.GetEnrichedFlatActivitiesAsync(GetOptions.Default.WithReaction(ReactionOption.With().Counts().Own().Recent()));

// Personalization
var input = new Dictionary<string, object>
{
    {"feed_slug", "my_personalized_feed"},
    {"user_id", "john"},
    {"limit", 20},
    {"ranking", "my_ranking"}
};
var response = await client.Personalization.GetAsync("my_endpoint", input);

// File & Image Upload
var fileUpload = await client.Files.UploadAsync(stream, name, contentType);
var imageupload = await client.Images.UploadAsync(stream, name, contentType);

// Use fileUpload.File and imageUpload.File afterwards
// Open graph
var og = await client.OgAsync("https://google.com");

โœ๏ธ 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.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.6 is compatible.  netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 is compatible.  net461 was computed.  net462 was computed.  net463 was computed.  net47 is compatible.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on stream-net:

Package Downloads
Softeq.NetKit.NewsFeedService

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.10.1 1,160 10/17/2024
6.9.2 5,924 8/5/2024
6.8.3 17,818 4/23/2024
6.8.2-prerelease 103 4/12/2024
6.8.1 12,002 2/27/2024
6.7.0 22,807 9/22/2023
6.6.0-prerelease 147 7/31/2023
6.5.3 11,110 5/16/2023
6.5.2 13,440 2/1/2023
6.5.1 15,333 10/4/2022
6.5.0 12,507 6/28/2022
6.4.0 2,168 6/24/2022
6.3.0 553 6/22/2022
6.2.0 4,439 6/2/2022
6.1.2 1,363 5/24/2022
6.1.1 473 5/24/2022
6.1.0 463 5/24/2022
6.0.0 10,336 3/18/2022
5.0.0 1,748 2/28/2022
4.8.0 4,256 2/23/2022
4.7.0 2,496 2/4/2022
4.6.0 3,904 1/13/2022
4.5.0 4,876 11/19/2021
4.4.1 955 11/1/2021
4.3.0 14,029 3/10/2021
4.2.0 1,176 2/26/2021
4.1.1 391 2/26/2021
4.1.0 399 2/26/2021
4.0.0 1,380 2/5/2021
3.1.0 1,763 2/1/2021
3.0.1 505 1/15/2021
3.0.0 508 1/8/2021
2.13.0 536 1/7/2021
2.12.0 196,116 10/16/2020
2.11.0 78,737 6/6/2019
2.10.1 996 5/15/2019
2.10.0 599 5/15/2019
2.9.1 4,309 1/25/2019
2.8.0 1,276 12/14/2018
2.7.0 1,300 12/5/2018
2.6.0 1,095 10/30/2018
2.5.0 751 10/30/2018
2.4.0 908 10/2/2018
2.3.0 886 9/20/2018
2.2.1 2,481 7/30/2018
2.2.0 846 7/30/2018
2.1.3 887 7/27/2018
2.1.2 860 7/27/2018
2.1.0 888 7/27/2018
2.0.4 926 7/25/2018
2.0.3 10,846 1/12/2018
2.0.1 1,014 11/17/2017
2.0.0 1,012 11/17/2017
1.3.2 4,544 12/23/2016
1.3.1 1,112 11/29/2016
1.3.0 1,126 10/4/2016
1.2.3 72 8/5/2024
1.2.2 1,288 2/11/2016
1.2.1 1,314 12/4/2015
1.1.1 1,206 6/24/2015
1.1.0 1,014 6/23/2015
1.0.8 1,055 6/23/2015
1.0.7 1,106 6/23/2015
1.0.6 1,470 6/1/2015
1.0.5 1,030 5/28/2015
1.0.4 1,051 5/18/2015
1.0.3 1,081 5/18/2015
1.0.2 1,079 4/6/2015
1.0.1 1,155 3/10/2015
1.0.0 1,091 3/9/2015