# Pins

## Overview

Sometimes you'll want to pin your favorite activity to a feed. You can pin an activity like this:

```python label="Python"
response = self.test_feed.pin_activity(activity_id, user_id=self.test_user_id)
```

When you read a feed pinned activities are automatically returned:

```python label="Python"
response = self.test_feed.unpin_activity(activity_id, self.test_user_id)
```

## Query pinned activities

`queryPinnedActivities` returns the pinned activities of a feed, with filtering, sorting and pagination. It applies the same read rules as [querying activities](https://getstream.io/activity-feeds/docs/python/query-activities/):

- shadowed and expired activities are returned only to their author
- removed and soft-deleted activities are not returned
- private activities are returned only to their author, and to server-side requests without a user
- activities authored by a user blocked in either direction are not returned

A pin whose activity is hidden is left out of the response, so a page can contain fewer items than `limit`, or none, while `next` is still set. Paginate on `next`, not on the page size.

Server-side requests can pass `user_id` to read the pins as that user sees them. The feed read permission is still checked as a server-side request.

Server-side requests without a user can include hidden pins:

- `include_moderated_activities`: shadowed and removed activities
- `include_soft_deleted_activities`: soft-deleted activities
- `include_expired_activities`: expired activities

>
> **Warning:** These flags are **server-side only**. Client-side requests ignore them, and a request that also sets `user_id` or `user` is rejected.
>

```python label="Python"
response = client.feeds.query_pinned_activities(
    "user",
    "john",
    include_moderated_activities=True,
    include_expired_activities=True,
    limit=20,
)
```

`GetOrCreateFeed` returns pinned activities too (`pinned_activities`), but does not apply these rules.

---

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