{"id":13937317,"url":"https://github.com/GetStream/stream-python","last_synced_at":"2025-07-19T23:31:41.249Z","repository":{"id":17444575,"uuid":"20218230","full_name":"GetStream/stream-python","owner":"GetStream","description":"Python Client - Build Activity Feeds \u0026 Streams with GetStream.io","archived":false,"fork":false,"pushed_at":"2023-10-25T16:58:59.000Z","size":574,"stargazers_count":142,"open_issues_count":2,"forks_count":40,"subscribers_count":43,"default_branch":"main","last_synced_at":"2024-09-19T03:25:33.222Z","etag":null,"topics":["activity-feed","feed","getstream-io","news-feed","notification-feed","python","stream-python","timeline"],"latest_commit_sha":null,"homepage":"https://getstream.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GetStream.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-05-27T11:51:50.000Z","updated_at":"2024-07-03T03:09:45.000Z","dependencies_parsed_at":"2022-09-18T06:55:09.659Z","dependency_job_id":"fe01e0d4-b517-4f82-bd56-3dbed22c4dc8","html_url":"https://github.com/GetStream/stream-python","commit_stats":{"total_commits":452,"total_committers":26,"mean_commits":"17.384615384615383","dds":0.7035398230088495,"last_synced_commit":"9c8b9cc9c3f9a3134532e63c383dab1e0718fc6c"},"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GetStream%2Fstream-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GetStream%2Fstream-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GetStream%2Fstream-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GetStream%2Fstream-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GetStream","download_url":"https://codeload.github.com/GetStream/stream-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226693903,"owners_count":17667757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activity-feed","feed","getstream-io","news-feed","notification-feed","python","stream-python","timeline"],"created_at":"2024-08-07T23:03:29.942Z","updated_at":"2024-11-27T05:31:05.959Z","avatar_url":"https://github.com/GetStream.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Official Python SDK for [Stream Feeds](https://getstream.io/activity-feeds/)\n\n[![build](https://github.com/GetStream/stream-python/workflows/build/badge.svg)](https://github.com/GetStream/stream-python/actions) [![PyPI version](https://badge.fury.io/py/stream-python.svg)](http://badge.fury.io/py/stream-python) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/stream-python.svg)\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/GetStream/stream-python/8a0e88a6cf115a34c2d6d39a54527398f3fa5a90/assets/logo.svg\" width=\"50%\" height=\"50%\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    Official Python API client for Stream Feeds, a web service for building scalable newsfeeds and activity streams.\n    \u003cbr /\u003e\n    \u003ca href=\"https://getstream.io/activity-feeds/docs/?language=python\"\u003e\u003cstrong\u003eExplore the docs »\u003c/strong\u003e\u003c/a\u003e\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/GetStream/stream-django\"\u003eDjango Code Sample\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/GetStream/stream-python/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/GetStream/stream-python/issues\"\u003eRequest Feature\u003c/a\u003e\n\u003c/p\u003e\n\n## 📝 About Stream\n\n\u003e 💡 Note: this is a library for the **Feeds** product. The Chat SDKs can be found [here](https://getstream.io/chat/docs/).\n\nYou can sign up for a Stream account at our [Get Started](https://getstream.io/get_started/) page.\n\nYou can use this library to access feeds API endpoints server-side.\n\nFor the client-side integrations (web and mobile) have a look at the JavaScript, iOS and Android SDK libraries ([docs](https://getstream.io/activity-feeds/)).\n\n\u003e 💡 We have a Django integration available [here](https://github.com/GetStream/stream-django).\n\n## ⚙️ Installation\n\n\n```bash\n$ pip install stream-python\n```\n\n## 📚 Full documentation\n\nDocumentation for this Python client are available at the [Stream website](https://getstream.io/docs/?language=python).\n\n## ✨ Getting started\n\n```python\nimport datetime\n\n# Create a new client\nimport stream\nclient = stream.connect('YOUR_API_KEY', 'API_KEY_SECRET')\n\n# Create a new client specifying data center location\nclient = stream.connect('YOUR_API_KEY', 'API_KEY_SECRET', location='us-east')\n# Find your API keys here https://getstream.io/dashboard/\n\n# Create a feed object\nuser_feed_1 = client.feed('user', '1')\n\n# Get activities from 5 to 10 (slow pagination)\nresult = user_feed_1.get(limit=5, offset=5)\n# (Recommended \u0026 faster) Filter on an id less than the given UUID\nresult = user_feed_1.get(limit=5, id_lt=\"e561de8f-00f1-11e4-b400-0cc47a024be0\")\n\n# Create a new activity\nactivity_data = {'actor': 1, 'verb': 'tweet', 'object': 1, 'foreign_id': 'tweet:1'}\nactivity_response = user_feed_1.add_activity(activity_data)\n# Create a bit more complex activity\nactivity_data = {'actor': 1, 'verb': 'run', 'object': 1, 'foreign_id': 'run:1',\n\t'course': {'name': 'Golden Gate park', 'distance': 10},\n\t'participants': ['Thierry', 'Tommaso'],\n\t'started_at': datetime.datetime.now()\n}\nuser_feed_1.add_activity(activity_data)\n\n# Remove an activity by its id\nuser_feed_1.remove_activity(\"e561de8f-00f1-11e4-b400-0cc47a024be0\")\n# or by foreign id\nuser_feed_1.remove_activity(foreign_id='tweet:1')\n\n# Follow another feed\nuser_feed_1.follow('flat', '42')\n\n# Stop following another feed\nuser_feed_1.unfollow('flat', '42')\n\n# List followers/following\nfollowing = user_feed_1.following(offset=0, limit=2)\nfollowers = user_feed_1.followers(offset=0, limit=10)\n\n# Creates many follow relationships in one request\nfollows = [\n    {'source': 'flat:1', 'target': 'user:1'},\n    {'source': 'flat:1', 'target': 'user:2'},\n    {'source': 'flat:1', 'target': 'user:3'}\n]\nclient.follow_many(follows)\n\n# Batch adding activities\nactivities = [\n\t{'actor': 1, 'verb': 'tweet', 'object': 1},\n\t{'actor': 2, 'verb': 'watch', 'object': 3}\n]\nuser_feed_1.add_activities(activities)\n\n# Add an activity and push it to other feeds too using the `to` field\nactivity = {\n    \"actor\":\"1\",\n    \"verb\":\"like\",\n    \"object\":\"3\",\n    \"to\":[\"user:44\", \"user:45\"]\n}\nuser_feed_1.add_activity(activity)\n\n# Retrieve an activity by its ID\nclient.get_activities(ids=[activity_id])\n\n# Retrieve an activity by the combination of foreign_id and time\nclient.get_activities(foreign_id_times=[\n    (foreign_id, activity_time),\n])\n\n# Enrich while getting activities\nclient.get_activities(ids=[activity_id], enrich=True, reactions={\"counts\": True})\n\n# Update some parts of an activity with activity_partial_update\nset = {\n    'product.name': 'boots',\n    'colors': {\n        'red': '0xFF0000',\n        'green': '0x00FF00'\n    }\n}\nunset = [ 'popularity', 'details.info' ]\n# ...by ID\nclient.activity_partial_update(id=activity_id, set=set, unset=unset)\n# ...or by combination of foreign_id and time\nclient.activity_partial_update(foreign_id=foreign_id, time=activity_time, set=set, unset=unset)\n\n# Generating user token for client side usage (JS client)\nuser_token = client.create_user_token(\"user-42\")\n\n# Javascript client side feed initialization\n# client = stream.connect(apiKey, userToken, appId);\n\n# Generate a redirect url for the Stream Analytics platform to track\n# events/impressions on url clicks\nimpression = {\n    'content_list': ['tweet:1', 'tweet:2', 'tweet:3'],\n    'user_data': 'tommaso',\n    'location': 'email',\n    'feed_id': 'user:global'\n}\n\nengagement = {\n    'content': 'tweet:2',\n    'label': 'click',\n    'position': 1,\n    'user_data': 'tommaso',\n    'location': 'email',\n    'feed_id':\n    'user:global'\n}\n\nevents = [impression, engagement]\n\nredirect_url = client.create_redirect_url('http://google.com/', 'user_id', events)\n```\n\n### Async code usage\n```python\nimport datetime\nimport stream\nclient = stream.connect('YOUR_API_KEY', 'API_KEY_SECRET', use_async=True)\n\n\n# Create a new client specifying data center location\nclient = stream.connect('YOUR_API_KEY', 'API_KEY_SECRET', location='us-east', use_async=True)\n# Find your API keys here https://getstream.io/dashboard/\n\n# Create a feed object\nuser_feed_1 = client.feed('user', '1')\n\n# Get activities from 5 to 10 (slow pagination)\nresult = await user_feed_1.get(limit=5, offset=5)\n# (Recommended \u0026 faster) Filter on an id less than the given UUID\nresult = await user_feed_1.get(limit=5, id_lt=\"e561de8f-00f1-11e4-b400-0cc47a024be0\")\n\n# Create a new activity\nactivity_data = {'actor': 1, 'verb': 'tweet', 'object': 1, 'foreign_id': 'tweet:1'}\nactivity_response = await user_feed_1.add_activity(activity_data)\n# Create a bit more complex activity\nactivity_data = {'actor': 1, 'verb': 'run', 'object': 1, 'foreign_id': 'run:1',\n\t'course': {'name': 'Golden Gate park', 'distance': 10},\n\t'participants': ['Thierry', 'Tommaso'],\n\t'started_at': datetime.datetime.now()\n}\nawait user_feed_1.add_activity(activity_data)\n\n# Remove an activity by its id\nawait user_feed_1.remove_activity(\"e561de8f-00f1-11e4-b400-0cc47a024be0\")\n# or by foreign id\nawait user_feed_1.remove_activity(foreign_id='tweet:1')\n\n# Follow another feed\nawait user_feed_1.follow('flat', '42')\n\n# Stop following another feed\nawait user_feed_1.unfollow('flat', '42')\n\n# List followers/following\nfollowing = await user_feed_1.following(offset=0, limit=2)\nfollowers = await user_feed_1.followers(offset=0, limit=10)\n\n# Creates many follow relationships in one request\nfollows = [\n    {'source': 'flat:1', 'target': 'user:1'},\n    {'source': 'flat:1', 'target': 'user:2'},\n    {'source': 'flat:1', 'target': 'user:3'}\n]\nawait client.follow_many(follows)\n\n# Batch adding activities\nactivities = [\n\t{'actor': 1, 'verb': 'tweet', 'object': 1},\n\t{'actor': 2, 'verb': 'watch', 'object': 3}\n]\nawait user_feed_1.add_activities(activities)\n\n# Add an activity and push it to other feeds too using the `to` field\nactivity = {\n    \"actor\":\"1\",\n    \"verb\":\"like\",\n    \"object\":\"3\",\n    \"to\":[\"user:44\", \"user:45\"]\n}\nawait user_feed_1.add_activity(activity)\n\n# Retrieve an activity by its ID\nawait client.get_activities(ids=[activity_id])\n\n# Retrieve an activity by the combination of foreign_id and time\nawait client.get_activities(foreign_id_times=[\n    (foreign_id, activity_time),\n])\n\n# Enrich while getting activities\nawait client.get_activities(ids=[activity_id], enrich=True, reactions={\"counts\": True})\n\n# Update some parts of an activity with activity_partial_update\nset = {\n    'product.name': 'boots',\n    'colors': {\n        'red': '0xFF0000',\n        'green': '0x00FF00'\n    }\n}\nunset = [ 'popularity', 'details.info' ]\n# ...by ID\nawait client.activity_partial_update(id=activity_id, set=set, unset=unset)\n# ...or by combination of foreign_id and time\nawait client.activity_partial_update(foreign_id=foreign_id, time=activity_time, set=set, unset=unset)\n\n# Generating user token for client side usage (JS client)\nuser_token = client.create_user_token(\"user-42\")\n\n# Javascript client side feed initialization\n# client = stream.connect(apiKey, userToken, appId);\n\n# Generate a redirect url for the Stream Analytics platform to track\n# events/impressions on url clicks\nimpression = {\n    'content_list': ['tweet:1', 'tweet:2', 'tweet:3'],\n    'user_data': 'tommaso',\n    'location': 'email',\n    'feed_id': 'user:global'\n}\n\nengagement = {\n    'content': 'tweet:2',\n    'label': 'click',\n    'position': 1,\n    'user_data': 'tommaso',\n    'location': 'email',\n    'feed_id':\n    'user:global'\n}\n\nevents = [impression, engagement]\n\nredirect_url = client.create_redirect_url('http://google.com/', 'user_id', events)\n\n```\n\n[JS client](http://github.com/getstream/stream-js).\n\n## ✍️ Contributing\n=======\n\nWe 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)](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) first. See our [license file](./LICENSE) for more details.\n\n## 🧑‍💻 We are hiring!\n\nWe've recently closed a [$38 million Series B funding round](https://techcrunch.com/2021/03/04/stream-raises-38m-as-its-chat-and-activity-feed-apis-power-communications-for-1b-users/) and we keep actively growing.\nOur 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.\n\nCheck out our current openings and apply via [Stream's website](https://getstream.io/team/#jobs).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGetStream%2Fstream-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGetStream%2Fstream-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGetStream%2Fstream-python/lists"}