# Quick Start

Stream lets you build activity feeds at scale. The largest apps using Stream have over 100 million users.
Stream Activity Feeds scales effectively while giving you more flexibility over the content shown in your feed.

>
> **Tip:** Stream Feeds has two halves. Feed groups, ranking, permissions and push setup are configured on your backend with a [server-side SDK](https://getstream.io/activity-feeds/docs/node/), authenticated with your API secret. The code you ship to your users is a [client SDK](https://getstream.io/activity-feeds/docs/javascript/), and it connects with a token signed on that backend. Whichever half you are here for, this sidebar carries an overview of the other.
>

## Start here

- [Activities](https://getstream.io/activity-feeds/docs/python/activities/): The core content units in Stream Feeds: posts, photos, videos, polls and any custom type you define.
- [Feeds](https://getstream.io/activity-feeds/docs/python/feeds/): Collections of activities: personal, timeline, notification or custom feeds for your use case.
- [Authentication and tokens](https://getstream.io/docs/platform/authentication/): Your backend signs the tokens users connect with, using your API secret.

## Getting started

```python label="Python"
from getstream import Stream

client = Stream(api_key="<API key>", api_secret="<API secret>")

# Create a feed (or get its data if exists)
feed = client.feeds.feed("user", "john")
feed.get_or_create(user_id="john")

# Add activity
response = client.feeds.add_activity(
    type="post",
    feeds=[feed.get_feed_identifier()],
    text="Hello, Stream Feeds!",
    user_id="john"
)
```

## Key concepts

### Activities

[Activities](https://getstream.io/activity-feeds/docs/python/activities/) are the core content units in Stream Feeds. They can represent posts, photos, videos, polls, and any custom content type you define.

### Feeds

[Feeds](https://getstream.io/activity-feeds/docs/python/feeds/) are collections of activities. They can be personal feeds, timeline feeds, [notification feeds](https://getstream.io/activity-feeds/docs/python/notification-feeds/), or custom feeds for your specific use case.

### Real-time updates

Stream Feeds provides [real-time updates](https://getstream.io/activity-feeds/docs/python/events/) through WebSocket connections, ensuring your app stays synchronized with the latest content.

### Social features

Built-in support for [reactions](https://getstream.io/activity-feeds/docs/python/reactions/), [comments](https://getstream.io/activity-feeds/docs/python/comments/), [bookmarks](https://getstream.io/activity-feeds/docs/python/bookmarks/), and [polls](https://getstream.io/activity-feeds/docs/python/polls/) makes it easy to build engaging social experiences.

## Server-side vs client-side

Most API calls can be made client-side. Client-side API calls use the permission system. Server-side API calls have full access.

```mermaid
flowchart LR
  subgraph app[Your app]
    client[Client SDK]
  end
  subgraph backend[Your backend]
    server[Server-side SDK]
  end
  client <--> api[Stream API]
  server --> api
  server -. user token .-> client
```

Most apps will default to making API calls client-side. Engineers will often use server-side to do the following tasks:

- Updating feed groups or feed views for ranking and aggregation
- Syncing users
- Returning tokens for authenticating users
- Writing to feeds that do not belong to the current user (since the user does not have access client side to do this)

## Common use cases

### Social media feed

```python label="Python"
from getstream import Stream

client = Stream(api_key="<API key>", api_secret="<API secret>")

# Create a feed (or get its data if exists)
feed = client.feeds.feed("user", "john")
feed.get_or_create(user_id="john")

# Add activity
response = client.feeds.add_activity(
    type="post",
    feeds=[feed.get_feed_identifier()],
    text="Hello, Stream Feeds!",
    user_id="john"
)
```

### Notification feed

```js label="JavaScript"
// Create a notification feed
const notifications = client.feed("notification", "john");
await notifications.getOrCreate();

// Mark notifications as read
await notifications.markActivity({
  mark_all_read: true,
});
```

### Polls

```python label="Python"
from getstream import Stream

client = Stream(api_key="<API key>", api_secret="<API secret>")

# Create a poll
poll_response = client.create_poll(
    name="What is your favorite color?",
    user_id="john",
    options=[{"text": "Red"}, {"text": "Blue"}, {"text": "Green"}],
)
poll_id = poll_response.data.get("id")

# Attach poll to an activity
activity_response = client.feeds.add_activity(
    type="poll",
    poll_id=poll_id,
    user_id="john",
    feeds=["user:john"],
    text="What is your favorite color?",
)
```

## Advanced features

### Custom activity types

Create custom activity types to represent your app's specific content:

```python label="Python"
from getstream import Stream

client = Stream(api_key="<API key>", api_secret="<API secret>")

# Create a feed (or get its data if exists)
feed = client.feeds.feed("user", "john")
feed.get_or_create(user_id="john")

# Add custom activity
response = client.feeds.add_activity(
    type="workout",
    feeds=[feed.get_feed_identifier()],
    text="Just finished my run",
    user_id="john",
    custom={
        "distance": 5.2,
        "duration": 1800,
        "calories": 450
    }
)
```

### Real-time updates with the state layer

Only for client-side SDKs

```js label="JavaScript"
const feed = client.feed("user", "john");
// Subscribe to WebSocket events for state updates
await feed.getOrCreate({ watch: true });
feed.state.subscribe((state) => {
  // Called everytime the state changes
  console.log(state);
});

// or if you only want to observe part of the state
feed.state.subscribeWithSelector(
  (state) => ({
    activities: state.activities,
  }),
  (state, prevState) => {
    console.log(state.activities, prevState?.activities);
  },
);

// Current state
console.log(feed.state.getLatestValue());
```

## What's next

- [Follow and unfollow](https://getstream.io/activity-feeds/docs/python/follows/): Connect feeds with follow relationships to build timeline experiences.
- [Notification feeds](https://getstream.io/activity-feeds/docs/python/notification-feeds/): Create notification feeds and mark activities as read.
- [Permissions and roles](https://getstream.io/docs/platform/permissions/): The subject, resource and action model, built-in and custom roles.

## FAQ

**Which feed groups are built in?**

`user`, `timeline`, `foryou`, `notification`, `story` and `stories`. The [feeds page](https://getstream.io/activity-feeds/docs/python/feeds/#built-in-feed-groups) describes each.

**Can I rank a feed?**

Yes, on paid plans. A feed group takes a [ranking expression](https://getstream.io/activity-feeds/docs/node/custom-ranking/) such as `decay_linear(time) * popularity`.

**How much custom data fits on an activity?**

The whole activity, built-in and custom fields together, must stay under 10KB at write time. Bigger objects go in [collections](https://getstream.io/activity-feeds/docs/python/collections/), though collection data can't be used in ranking or aggregation.

**Can users comment on and react to activities?**

Yes. [Comments](https://getstream.io/activity-feeds/docs/python/comments/) support threading and [reactions](https://getstream.io/activity-feeds/docs/python/reactions/) work on activities and comments alike.

**How do I migrate from Feeds v2?**

From the [dashboard](https://getstream.io/signin/?product=feeds), which replicates live v2 traffic to v3 while you integrate. The [migration guide](https://getstream.io/activity-feeds/docs/node/v2-to-v3-migration/) covers the phases.

**Can feed content be moderated?**

Yes. Moderation is built in through `client.moderation`. See [moderation](https://getstream.io/activity-feeds/docs/python/moderation/).

---

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