# Getting Started

## Learn How Easy It Can Be To Build Scalable Newsfeeds and Activity Streams

Stream has official clients for JS/Node, Ruby, Python, PHP, Go, Java and C#/.NET.

## Setup

Let's get set up! First, install the client as specified below:

<Tabs>

```csharp label="C#"
// add the stream-net to your project:
// https://www.nuget.org/packages/stream-net/
<PackageReference Include="stream-net" Version="6.5.3" />
```

```js label="JavaScript"
// install via npm
npm install getstream

// or yarn
yarn add getstream

// or download the UMD built version from Github
https://raw.githubusercontent.com/GetStream/stream-js/master/dist/js/getstream.js
```

```ruby label="Ruby"
# install directly with gem
gem install "stream-ruby"

# or add this to your Gemfile and then run bundler
gem "stream-ruby"
```

```python label="Python"
// pip install stream-python
```

```php label="PHP"
// install using composer
composer require get-stream/stream
```

```java label="Java"
// Add the following dependency and repository to your pom.xml file

<dependency>
  <groupId>io.getstream.client</groupId>
  <artifactId>stream-java</artifactId>
  <version>3.0.0</version>
</dependency>
```

```go label="Go"
// install from the command line
go get github.com/GetStream/stream-go2/v8

// import it in your code
import stream "github.com/GetStream/stream-go2/v8"
```

</Tabs>

<admonition type="info">

All source code can be found on [GitHub](https://github.com/GetStream).

</admonition>

To instantiate the client you need an `API key` and `secret` . You can find the key and secret on the [dashboard.](https://getstream.io/dashboard/) The examples below already include your key and secret.

<Tabs>

```csharp label="C#"
// Create a client, find your API keys here https://getstream.io/dashboard/
// optionally set the region of your app and default timeout
Client = new StreamClient(
  Environment.GetEnvironmentVariable("STREAM_API_KEY"),
  Environment.GetEnvironmentVariable("STREAM_API_SECRET"),
  new StreamClientOptions
  {
    Location = StreamApiLocation.USEast,
    Timeout = 16000,
});
```

```js label="JavaScript"
const stream = require("getstream");

// instantiate a new client (server side)
const client = stream.connect("{{ api_key }}", "{{ api_secret }}");

// OR

import stream from "getstream";

const client = stream.connect("{{ api_key }}", "{{ api_secret }}");
```

```ruby label="Ruby"
# Instantiate a new client (server side)
require 'stream'
client = Stream::Client.new('{{ api_key }}', '{{ api_secret }}', :location => 'us-east')
# Find your API keys here https://getstream.io/dashboard/
```

```python label="Python"
# Instantiate a new client (server side)
import stream
client = stream.connect('{{ api_key }}', '{{ api_secret }}', location='us-east')
# Find your API keys here https://getstream.io/dashboard/
```

```php label="PHP"
// Instantiate a new client (server side)
$client = new GetStream\Stream\Client('{{ api_key }}', '{{ api_secret }}');
// Find your API keys here https://getstream.io/dashboard/
```

```java label="Java"
// import io.getstream.client.Client;

Client client = Client.builder(
 '{{ api_key }}',
 '{{ api_secret }}'
 ).build();
```

```go label="Go"
import stream "github.com/GetStream/stream-go2/v8"

client, err := stream.New("{{ api_key }}", "{{ api_secret }}")
if err != nil {
	panic(err)
}
```

</Tabs>

If you want to use Stream on your mobile or web application, you need to generate a token server-side that the client can use to authenticate as a user of your application.

### Generate User Token Server-Side

This code generates the token for one of your users; a common place to do this is at signup or login. The token is then passed to the frontend.

<Tabs>

```csharp label="C#"
var token = client.CreateUserToken("the-user-id");
```

```js label="JavaScript"
const userToken = client.createUserToken("the-user-id");
```

```ruby label="Ruby"
user_token = client.create_user_session_token('the-user-id')
```

```python label="Python"
user_token = client.create_user_token('the-user-id')
```

```php label="PHP"
$userToken = client->createUserSessionToken("the-user-id");
```

```java label="Java"
Token userToken = client.frontendToken("the-user-id");
```

```go label="Go"
userToken, err := client.CreateUserToken("the-user-id")
```

</Tabs>

### Use Stream API client-side

<Tabs>

```js label="JavaScript"
const stream = require("getstream");

// Instantiate new client with a user token
const client = stream.connect(
  "{{ api_key }}",
  "{{ feed_token }}",
  "{{ app_id }}",
);

// OR

import stream from "getstream";

const client = stream.connect(
  "{{ api_key }}",
  "{{ feed_token }}",
  "{{ app_id }}",
);
```

</Tabs>

<admonition type="info">

More details about authentication can be found in the [REST docs](https://getstream.io/docs_rest/#authentication)

</admonition>

### Quick Start

The quick start below shows you how to build a scalable social network. It highlights the most common API calls:

<Tabs>

```csharp label="C#"
var chrisFeed = client.Feed("user", "chris");

// Add an Activity; message is a custom field - tip: you can add unlimited custom fields!
var activity = new Activity("chris", "add", "picture:10")
{
  ForeignId = "picture:10"
};
activity.SetData("message", "Beautiful bird!");

await chrisFeed.AddActivityAsync(activity);

// Create a following relationship between Jack's "timeline" feed and Chris' "user" feed:
jackTimeline = client.Feed("timeline", "jack");
jackTimeline.FollowFeed("user", "chris");

// Read Jack's timeline and Chris' post appears in the feed:
var activities = await jackTimeline.GetActivitiesAsync(0, 10);

// Remove the activity by referencing the foreign_id you provided:
await chrisFeed.RemoveActivityAsync("picture:10", true);

// for more exaxmples check:
// https://github.com/GetStream/stream-net/blob/master/README.md
```

```js label="JavaScript"
const chris = client.feed("user", "chris");

// Add an Activity; message is a custom field - tip: you can add unlimited custom fields!
await chris.addActivity({
  actor: "chris",
  verb: "add",
  object: "picture:10",
  foreign_id: "picture:10",
  message: "Beautiful bird!",
});

// Create a following relationship between Jack's "timeline" feed and Chris' "user" feed:
const jack = client.feed("timeline", "jack");
await jack.follow("user", "chris");

// Read Jack's timeline and Chris' post appears in the feed:
const results = await jack.get({ limit: 10 });

// Remove an Activity by referencing it's Foreign Id:
await chris.removeActivity({ foreignId: "picture:10" });
```

```ruby label="Ruby"
chris = client.feed('user', 'chris')

# Add an Activity; message is a custom field - tip: you can add unlimited custom fields!
activity_data = { :actor => 'chris', :verb => 'add', :object => 'picture:10', :foreign_id => 'picture:10', :message => 'Beautiful bird!' }
chris.add_activity(activity_data);

# Create a following relationship between Jack's "timeline" feed and Chris' "user" feed:
jack = client.feed('timeline', 'jack')
jack.follow('user', 'chris')

# Read Jack's timeline and Chris' post appears in the feed:
activities = jack.get(:limit => 10)

# Remove an Activity by referencing it's foreign_id
chris.remove_activity('picture:10', foreign_id=true)
```

```python label="Python"
chris = client.feed("user", "chris")

# Add an Activity; message is a custom field - tip: you can add unlimited custom fields!
chris.add_activity({
 "actor": "chris",
 "verb": "add",
 "object": "picture:10",
 "foreign_id": "picture:10",
 "message": "Beautiful bird!"
})

# Create a following relationship between Jack's "timeline" feed and Chris' "user" feed:
jack = client.feed("timeline", "jack")
jack.follow('user', "chris")

# Read Jack's timeline and Chris' post appears in the feed:
activities = jack.get(limit=10)["results"]

# Remove an Activity by referencing it's foreign_id
chris.remove_activity(foreign_id="picture:10")
```

```java label="Java"
FlatFeed chris = client.flatFeed("user", "chris");
// Add an Activity; message is a custom field - tip: you can add unlimited custom fields!
chris.addActivity(Activity.builder()
    .actor("chris")
    .verb("add")
    .object("picture:10")
    .foreignID("picture:10")
    .extraField("message", "Beautiful bird!")
    .build());

// Create a following relationship between Jack's "timeline" feed and Chris' "user" feed:
FlatFeed jack = client.flatFeed("timeline", "jack");
ack.follow(chris).join();

// Read Jack's timeline and Chris' post appears in the feed:
List<Activity> response = jack.getActivities(new Pagination().limit(10)).join();
for (Activity activity : response) {
    // ...
}

// Remove an Activity by referencing it's foreign_id
chris.removeActivityByForeignID("picture:10").join();
```

```go label="Go"
chris, err := client.FlatFeed("user", "chris")
	if err != nil {
		panic(err)
	}

	// Add an Activity; message is a custom field - tip: you can add unlimited custom fields!
	_, err = chris.AddActivity(context.TODO(), stream.Activity{
		Actor:   "chris",
		Verb:   "add",
		Object:  "picture:10",
		ForeignID: "picture:10",
		Extra: map[string]any{
			"message": "Beautiful bird!",
		},
	})
	if err != nil {
		panic(err)
	}

	// Create a following relationship between Jack's "timeline" feed and Chris' "user" feed:
	jack, err := client.FlatFeed("timeline", "jack")
	if err != nil {
		panic(err)
	}

	_, err = jack.Follow(context.TODO(), chris)
	if err != nil {
		panic(err)
	}

	// Read Jack's timeline and Chris' post appears in the feed:
	resp, err := jack.GetActivities(context.TODO(), stream.WithActivitiesLimit(10))
	if err != nil {
		panic(err)
	}
	for _, activity := range resp.Results {
		fmt.Println(activity)
	}

	// Remove an Activity by referencing it's foreign_id
	_, err = chris.RemoveActivityByForeignID(context.TODO(), "picture:10")
	if err != nil {
		panic(err)
	}
```

```php label="PHP"
$chris = $client->feed('user', 'chris');

// Add an Activity; message is a custom field - tip: you can add unlimited custom fields!
$data = [
 "actor" => "chris",
 "verb" => "add",
 "object" => "picture:10",
 "foreign_id" => "picture:10",
 "message" => "Beautiful bird!",
];

$chris->addActivity($data);

// Create a following relationship between Jack's "timeline" feed and Chris' "user" feed:
$jack = $client->feed('timeline', 'jack');
$jack->follow('user', 'chris');

// Read Jack's timeline and Chris' post appears in the feed:
$activities = $jack->getActivities(10)['results'];

// Remove the activity by referencing the foreign_id you provided:
$chris->removeActivity("picture:10", true);
```

</Tabs>

That was a good deal of information at once. The [getting started](https://getstream.io/get_started/) docs provide a more detailed and interactive explanation.


---

This page was last updated at 2026-07-10T16:04:50.829Z.

For the most recent version of this documentation, visit [https://getstream.io/activity-feeds/docs/javascript/v2/](https://getstream.io/activity-feeds/docs/javascript/v2/).