stream-net
6.5.3
See the version list below for details.
dotnet add package stream-net --version 6.5.3
NuGet\Install-Package stream-net -Version 6.5.3
<PackageReference Include="stream-net" Version="6.5.3" />
paket add stream-net --version 6.5.3
#r "nuget: stream-net, 6.5.3"
// Install stream-net as a Cake Addin #addin nuget:?package=stream-net&version=6.5.3 // Install stream-net as a Cake Tool #tool nuget:?package=stream-net&version=6.5.3
Official .NET SDK for Stream
<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).
๐ก Note: this is a library for the Feeds product. The Chat SDKs can be found here.
โ๏ธ 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 | Versions 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. |
-
.NETFramework 4.5
- Newtonsoft.Json (>= 13.0.1)
-
.NETFramework 4.6
- Newtonsoft.Json (>= 13.0.1)
-
.NETFramework 4.7
- Newtonsoft.Json (>= 13.0.1)
-
.NETFramework 4.8
- Newtonsoft.Json (>= 13.0.1)
-
.NETStandard 1.6
- NETStandard.Library (>= 1.6.1)
- Newtonsoft.Json (>= 13.0.1)
-
.NETStandard 2.0
- Newtonsoft.Json (>= 13.0.1)
-
.NETStandard 2.1
- Newtonsoft.Json (>= 13.0.1)
-
net5.0
- Newtonsoft.Json (>= 13.0.1)
-
net6.0
- Newtonsoft.Json (>= 13.0.1)
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,605 | 10/17/2024 |
6.9.2 | 6,367 | 8/5/2024 |
6.8.3 | 18,545 | 4/23/2024 |
6.8.2-prerelease | 105 | 4/12/2024 |
6.8.1 | 12,178 | 2/27/2024 |
6.7.0 | 23,128 | 9/22/2023 |
6.6.0-prerelease | 149 | 7/31/2023 |
6.5.3 | 11,158 | 5/16/2023 |
6.5.2 | 13,445 | 2/1/2023 |
6.5.1 | 15,354 | 10/4/2022 |
6.5.0 | 12,509 | 6/28/2022 |
6.4.0 | 2,176 | 6/24/2022 |
6.3.0 | 557 | 6/22/2022 |
6.2.0 | 4,451 | 6/2/2022 |
6.1.2 | 1,365 | 5/24/2022 |
6.1.1 | 477 | 5/24/2022 |
6.1.0 | 465 | 5/24/2022 |
6.0.0 | 10,338 | 3/18/2022 |
5.0.0 | 1,754 | 2/28/2022 |
4.8.0 | 4,258 | 2/23/2022 |
4.7.0 | 2,500 | 2/4/2022 |
4.6.0 | 3,918 | 1/13/2022 |
4.5.0 | 4,879 | 11/19/2021 |
4.4.1 | 957 | 11/1/2021 |
4.3.0 | 14,039 | 3/10/2021 |
4.2.0 | 1,178 | 2/26/2021 |
4.1.1 | 393 | 2/26/2021 |
4.1.0 | 401 | 2/26/2021 |
4.0.0 | 1,382 | 2/5/2021 |
3.1.0 | 1,785 | 2/1/2021 |
3.0.1 | 509 | 1/15/2021 |
3.0.0 | 510 | 1/8/2021 |
2.13.0 | 538 | 1/7/2021 |
2.12.0 | 199,243 | 10/16/2020 |
2.11.0 | 78,943 | 6/6/2019 |
2.10.1 | 1,003 | 5/15/2019 |
2.10.0 | 601 | 5/15/2019 |
2.9.1 | 4,319 | 1/25/2019 |
2.8.0 | 1,278 | 12/14/2018 |
2.7.0 | 1,302 | 12/5/2018 |
2.6.0 | 1,097 | 10/30/2018 |
2.5.0 | 753 | 10/30/2018 |
2.4.0 | 910 | 10/2/2018 |
2.3.0 | 888 | 9/20/2018 |
2.2.1 | 2,483 | 7/30/2018 |
2.2.0 | 848 | 7/30/2018 |
2.1.3 | 889 | 7/27/2018 |
2.1.2 | 862 | 7/27/2018 |
2.1.0 | 890 | 7/27/2018 |
2.0.4 | 928 | 7/25/2018 |
2.0.3 | 10,848 | 1/12/2018 |
2.0.1 | 1,016 | 11/17/2017 |
2.0.0 | 1,014 | 11/17/2017 |
1.3.2 | 4,551 | 12/23/2016 |
1.3.1 | 1,114 | 11/29/2016 |
1.3.0 | 1,128 | 10/4/2016 |
1.2.3 | 74 | 8/5/2024 |
1.2.2 | 1,290 | 2/11/2016 |
1.2.1 | 1,316 | 12/4/2015 |
1.1.1 | 1,208 | 6/24/2015 |
1.1.0 | 1,016 | 6/23/2015 |
1.0.8 | 1,057 | 6/23/2015 |
1.0.7 | 1,108 | 6/23/2015 |
1.0.6 | 1,472 | 6/1/2015 |
1.0.5 | 1,032 | 5/28/2015 |
1.0.4 | 1,053 | 5/18/2015 |
1.0.3 | 1,083 | 5/18/2015 |
1.0.2 | 1,081 | 4/6/2015 |
1.0.1 | 1,157 | 3/10/2015 |
1.0.0 | 1,095 | 3/9/2015 |
## [6.5.3](https://github.com/GetStream/stream-net/compare/6.5.2...6.5.3) (2023-05-16)
#