{"id":4786,"library":"stream-python","title":"Stream Python Client","description":"Client for getstream.io, enabling developers to build scalable newsfeeds and activity streams. The library provides functionality to interact with Stream's API for feed management, activity posting, and user token generation. Currently at version 5.4.0, it maintains an active development pace with several releases per year, including minor updates and occasional major feature additions.","status":"active","version":"5.4.0","language":"en","source_language":"en","source_url":"http://github.com/GetStream/stream-python","tags":["api-client","feeds","activity-streams","social","realtime"],"install":[{"cmd":"pip install stream-python","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"stream.connect","correct":"import stream\nclient = stream.connect(...)"}],"quickstart":{"code":"import stream\nimport os\n\n# Get your API key and secret from getstream.io/dashboard\nSTREAM_API_KEY = os.environ.get('STREAM_API_KEY', 'YOUR_STREAM_API_KEY')\nSTREAM_API_SECRET = os.environ.get('STREAM_API_SECRET', 'YOUR_STREAM_API_SECRET')\n\n# Connect to the Stream API\nclient = stream.connect(STREAM_API_KEY, STREAM_API_SECRET)\n\n# Get a user feed\nuser_feed = client.feed('user', 'john-doe')\n\n# Add an activity to the feed\nactivity_data = {\n    'actor': 'john-doe',\n    'verb': 'post',\n    'object': '1',\n    'foreign_id': 'post:1',\n    'message': 'Hello world from Stream!'\n}\nresponse = user_feed.add_activity(activity_data)\nprint(f\"Activity added: {response['id']}\")\n\n# Read activities from the feed (optional, for demonstration)\nactivities = user_feed.get(limit=1)['results']\nif activities:\n    print(f\"Retrieved activity: {activities[0]['message']}\")\n","lang":"python","description":"Connects to the Stream API using environment variables for credentials, initializes a user feed, adds a simple activity, and then retrieves it to confirm."},"warnings":[{"fix":"Upgrade your Python interpreter to 3.7 or higher.","message":"Version 5.0.0 dropped support for Python 3.5. Ensure your environment uses Python 3.6 or newer (3.7+ recommended).","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Upgrade `pyjwt` to 2.x (`pip install 'pyjwt>=2,<3'`) or ensure your dependency tree allows for `pyjwt` 2.x.","message":"Version 5.0.1 introduced a breaking change by bumping the `pyjwt` dependency to version 2.x. If you have other dependencies requiring `pyjwt==1.x`, this might cause conflicts.","severity":"breaking","affected_versions":">=5.0.1"},{"fix":"Replace all calls to `client.create_user_session_token(...)` with `client.create_user_token(...)`.","message":"In version 4.0.0, the `create_user_session_token` method was removed and replaced with `create_user_token`. Calls to the old method will fail.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Refer to the `pyjwt` 2.x documentation for any custom token handling or ensure you use the library's provided `create_user_token` method for compatibility.","message":"When handling JWT tokens, especially if generating them manually or interacting with older systems, be aware that `stream-python`'s token generation methods (e.g., `create_user_token`) now use `pyjwt` 2.x internally. This affects the default algorithms and parameters.","severity":"gotcha","affected_versions":">=5.0.1"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}