Skip to content

Commit ce16688

Browse files
committed
Revert "Update README.md"
This reverts commit 67808ae.
1 parent 67808ae commit ce16688

1 file changed

Lines changed: 170 additions & 5 deletions

File tree

README.md

Lines changed: 170 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,184 @@
1-
Stream-JS
2-
===========
1+
stream-python
2+
=============
3+
4+
[![Build Status](https://travis-ci.org/GetStream/stream-python.svg?branch=master)](https://travis-ci.org/GetStream/stream-python) [![codecov](https://codecov.io/gh/GetStream/stream-python/branch/master/graph/badge.svg)](https://codecov.io/gh/GetStream/stream-python) [![PyPI version](https://badge.fury.io/py/stream-python.svg)](http://badge.fury.io/py/stream-python)
5+
6+
[stream-python](https://github.com/GetStream/stream-python) is the official Python client for [Stream](https://getstream.io/), a web service for building scalable newsfeeds and activity streams.
7+
8+
Note there is also a higher level [Django - Stream integration](https://github.com/getstream/stream-django) library which hooks into the Django ORM.
9+
10+
You can sign up for a Stream account at https://getstream.io/get_started.
311

412
### Installation
513

14+
stream-python supports:
15+
16+
- Python (2.6, 2.7, 3.4, 3.5, 3.6, 3.7)
17+
18+
#### Install from Pypi
19+
620
```bash
7-
npm i @stream-io/react-native
21+
pip install stream-python
822
```
923

24+
### Full documentation
25+
26+
Documentation for this Python client are available at the [Stream website](https://getstream.io/docs/?language=python) or on [Read the Docs](http://stream-python.readthedocs.org/en/latest/).
27+
1028
### Usage
1129

12-
```javascript
30+
```python
31+
# Instantiate a new client
32+
import stream
33+
client = stream.connect('YOUR_API_KEY', 'API_KEY_SECRET')
34+
35+
# INstantiate a new client specifying datacenter location
36+
client = stream.connect('YOUR_API_KEY', 'API_KEY_SECRET', location='us-east')
37+
# Find your API keys here https://getstream.io/dashboard/
38+
39+
# Instantiate a feed object
40+
user_feed_1 = client.feed('user', '1')
41+
42+
# Get activities from 5 to 10 (slow pagination)
43+
result = user_feed_1.get(limit=5, offset=5)
44+
# (Recommended & faster) Filter on an id less than the given UUID
45+
result = user_feed_1.get(limit=5, id_lt="e561de8f-00f1-11e4-b400-0cc47a024be0")
46+
47+
# Create a new activity
48+
activity_data = {'actor': 1, 'verb': 'tweet', 'object': 1, 'foreign_id': 'tweet:1'}
49+
activity_response = user_feed_1.add_activity(activity_data)
50+
# Create a bit more complex activity
51+
activity_data = {'actor': 1, 'verb': 'run', 'object': 1, 'foreign_id': 'run:1',
52+
'course': {'name': 'Golden Gate park', 'distance': 10},
53+
'participants': ['Thierry', 'Tommaso'],
54+
'started_at': datetime.datetime.now()
55+
}
56+
user_feed_1.add_activity(activity_data)
57+
58+
# Remove an activity by its id
59+
user_feed_1.remove_activity("e561de8f-00f1-11e4-b400-0cc47a024be0")
60+
# or by foreign id
61+
user_feed_1.remove_activity(foreign_id='tweet:1')
62+
63+
# Follow another feed
64+
user_feed_1.follow('flat', '42')
65+
66+
# Stop following another feed
67+
user_feed_1.unfollow('flat', '42')
68+
69+
# List followers/following
70+
following = user_feed_1.following(offset=0, limit=2)
71+
followers = user_feed_1.followers(offset=0, limit=10)
72+
73+
# Creates many follow relationships in one request
74+
follows = [
75+
{'source': 'flat:1', 'target': 'user:1'},
76+
{'source': 'flat:1', 'target': 'user:2'},
77+
{'source': 'flat:1', 'target': 'user:3'}
78+
]
79+
client.follow_many(follows)
80+
81+
# Batch adding activities
82+
activities = [
83+
{'actor': 1, 'verb': 'tweet', 'object': 1},
84+
{'actor': 2, 'verb': 'watch', 'object': 3}
85+
]
86+
user_feed_1.add_activities(activities)
87+
88+
# Add an activity and push it to other feeds too using the `to` field
89+
activity = {
90+
"actor":"1",
91+
"verb":"like",
92+
"object":"3",
93+
"to":["user:44", "user:45"]
94+
}
95+
user_feed_1.add_activity(activity)
96+
97+
# Retrieve an activity by its ID
98+
client.get_activities(ids=[activity_id])
99+
100+
# Retrieve an activity by the combination of foreign_id and time
101+
client.get_activities(foreign_id_times=[
102+
(foreign_id, activity_time),
103+
])
104+
105+
# Update some parts of an activity with activity_partial_update
106+
set = {
107+
'product.name': 'boots',
108+
'colors': {
109+
'red': '0xFF0000',
110+
'green': '0x00FF00'
111+
}
112+
}
113+
unset = [ 'popularity', 'details.info' ]
114+
# ...by ID
115+
client.activity_partial_update(id=activity_id, set=set, unset=unset)
116+
# ...or by combination of foreign_id and time
117+
client.activity_partial_update(foreign_id=foreign_id, time=activity_time, set=set, unset=unset)
118+
119+
# Generating tokens for client side usage (JS client)
120+
token = user_feed_1.token
121+
# Javascript client side feed initialization
122+
# user1 = client.feed('user', '1', '{{ token }}');
123+
124+
# Generate a read-only token for client side usage (JS client)
125+
readonly_token = user_feed_1.get_readonly_token()
126+
# Javascript client side feed initialization
127+
# user1 = client.feed('user', '1', '{{ readonly_token }}');
128+
129+
# Generate a redirect url for the Stream Analytics platform to track
130+
# events/impressions on url clicks
131+
impression = {
132+
'content_list': ['tweet:1', 'tweet:2', 'tweet:3'],
133+
'user_data': 'tommaso',
134+
'location': 'email',
135+
'feed_id': 'user:global'
136+
}
137+
138+
engagement = {
139+
'content': 'tweet:2',
140+
'label': 'click',
141+
'position': 1,
142+
'user_data': 'tommaso',
143+
'location': 'email',
144+
'feed_id':
145+
'user:global'
146+
}
147+
148+
events = [impression, engagement]
149+
150+
redirect_url = client.create_redirect_url('http://google.com/', 'user_id', events)
13151
```
14152

153+
[JS client](http://github.com/getstream/stream-js).
154+
155+
### Contributing
156+
157+
First, make sure you can run the test suite. Tests are run via py.test
158+
159+
```bash
160+
py.test
161+
# with coverage
162+
py.test --cov stream --cov-report html
163+
# against a local API backend
164+
LOCAL=true py.test
165+
```
166+
167+
### Releasing a new version
168+
169+
In order to release new version you need to be a maintainer on Pypi.
170+
171+
- Update CHANGELOG
172+
- Update the version on setup.py
173+
- Commit and push to Github
174+
- Create a new tag for the version (eg. `v2.9.0`)
175+
- Create a new dist with python `python setup.py sdist`
176+
- Upload the new distributable with wine `twine upload dist/stream-python-VERSION-NAME.tar.gz`
177+
178+
If unsure you can also test using the Pypi test servers `twine upload --repository-url https://test.pypi.org/legacy/ dist/stream-python-VERSION-NAME.tar.gz`
179+
15180
### Copyright and License Information
16181

17-
Copyright (c) 2015-2018 Stream.io Inc, and individual contributors. All rights reserved.
182+
Copyright (c) 2014-2017 Stream.io Inc, and individual contributors. All rights reserved.
18183

19184
See the file "LICENSE" for information on the history of this software, terms & conditions for usage, and a DISCLAIMER OF ALL WARRANTIES.

0 commit comments

Comments
 (0)