You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+55-30Lines changed: 55 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ By the `Python-Twitter Developers <python-twitter@googlegroups.com>`_
24
24
Introduction
25
25
============
26
26
27
-
This library provides a pure Python interface for the `Twitter API <https://dev.twitter.com/>`_. It works with Python versions from 2.6+. Python 3 support is under development.
27
+
This library provides a pure Python interface for the `Twitter API <https://dev.twitter.com/>`_. It works with Python versions from 2.7+ and Python 3.
28
28
29
29
`Twitter <http://twitter.com>`_ provides a service that allows people to connect via the web, IM, and SMS. Twitter exposes a `web services API <https://dev.twitter.com/overview/documentation>`_ and this library is intended to make it even easier for Python programmers to use.
30
30
@@ -47,64 +47,83 @@ Check out the latest development version anonymously with::
Setup a virtual environment and install dependencies:
50
+
To install dependencies, run either::
51
51
52
-
$ make env
52
+
$ make dev
53
53
54
-
Activate the virtual environment created:
54
+
or::
55
55
56
-
$ source env/bin/activate
56
+
$ pip install -r requirements.testing.txt
57
+
58
+
To install the minimal dependencies for production use (i.e., what is installed
59
+
with ``pip install python-twitter``) run::
60
+
61
+
$ make env
62
+
63
+
or::
64
+
65
+
$ pip install -r requirements.txt
57
66
58
67
=============
59
68
Running Tests
60
69
=============
61
-
Note that tests require ```pip install nose``` and optionally ```pip install coverage```:
70
+
Note that tests require ```pip install pytest``` and optionally ```pip install pytest-cov``` (these are included if you have installed dependencies from ```requirements.testing.txt```)
62
71
63
-
To run the unit tests:
72
+
To run the unit tests::
64
73
65
-
$ make test
74
+
$ make test
66
75
67
-
to also run code coverage:
76
+
to also run code coverage::
68
77
69
78
$ make coverage
70
79
80
+
71
81
=============
72
82
Documentation
73
83
=============
74
84
75
-
View the last release API documentation at: https://dev.twitter.com/overview/documentation
85
+
View the latest python-twitter documentation at
86
+
https://python-twitter.readthedocs.org. You can view Twitter's API documentation at: https://dev.twitter.com/overview/documentation
76
87
77
88
=====
78
89
Using
79
90
=====
80
91
81
-
The library provides a Python wrapper around the Twitter API and the Twitter data model.
92
+
The library provides a Python wrapper around the Twitter API and the Twitter data model. To get started, check out the examples in the examples/ folder or read the documentation at https://python-twitter.readthedocs.org which contains information about getting your authentication keys from Twitter and using the library.
82
93
83
94
----
84
95
Using with Django
85
96
----
86
97
87
98
Additional template tags that expand tweet urls and urlize tweet text. See the django template tags available for use with python-twitter: https://github.com/radzhome/python-twitter-django-tags
88
99
89
-
-----
90
-
Model
91
-
-----
100
+
------
101
+
Models
102
+
------
92
103
93
-
The three model classes are ``twitter.Status``, ``twitter.User``, and ``twitter.DirectMessage``. The API methods return instances of these classes.
104
+
The library utilizes models to represent various data structures returned by Twitter. Those models are:
105
+
* twitter.Category
106
+
* twitter.DirectMessage
107
+
* twitter.Hashtag
108
+
* twitter.List
109
+
* twitter.Media
110
+
* twitter.Status
111
+
* twitter.Trend
112
+
* twitter.Url
113
+
* twitter.User
114
+
* twitter.UserStatus
94
115
95
-
To read the full API for ``twitter.Status``, ``twitter.User``, or ``twitter.DirectMessage``, run::
116
+
To read the documentation for any of these models, run::
96
117
97
-
$ pydoc twitter.Status
98
-
$ pydoc twitter.User
99
-
$ pydoc twitter.DirectMessage
118
+
$ pydoc twitter.[model]
100
119
101
120
---
102
121
API
103
122
---
104
123
105
124
The API is exposed via the ``twitter.Api`` class.
106
125
107
-
The python-twitter library now only supports OAuth authentication as the Twitter devs have indicated that OAuth is the only method that will be supported moving forward.
126
+
The python-twitter requires the use of OAuth keys for nearly all operations. As of Twitter's API v1.1, authentication is required for most, if not all, endpoints. Therefore, you will need to register an app with Twitter in order to use this library. Please see the "Getting Started" guide on https://python-twitter.readthedocs.org for a more information.
108
127
109
128
To generate an Access Token you have to pick what type of access your application requires and then do one of the following:
110
129
@@ -129,40 +148,46 @@ To see if your credentials are successful::
129
148
130
149
**NOTE**: much more than the small sample given here will print
131
150
132
-
To fetch a single user's public status messages, where ``user`` is a Twitter *short name*::
151
+
To fetch a single user's public status messages, where ``user`` is a Twitter user's screen name::
To fetch a list a user's friends (requires authentication)::
156
+
To fetch a list a user's friends::
138
157
139
158
>>> users = api.GetFriends()
140
159
>>> print([u.name for u in users])
141
160
142
-
To post a Twitter status message (requires authentication)::
161
+
To post a Twitter status message::
143
162
144
163
>>> status = api.PostUpdate('I love python-twitter!')
145
164
>>> print(status.text)
146
165
I love python-twitter!
147
166
148
-
There are many more API methods, to read the full API documentation::
167
+
There are many more API methods, to read the full API documentation either
168
+
check out the documentation on `readthedocs
169
+
<https://python-twitter.readthedocs.org>`_, build the documentation locally
170
+
with::
149
171
150
-
$ pydoc twitter.Api
172
+
$ make docs
151
173
174
+
or check out the inline documentation with::
152
175
176
+
$ pydoc twitter.Api
153
177
154
178
----
155
179
Todo
156
180
----
157
181
158
-
Patches and bug reports are `welcome <https://github.com/bear/python-twitter/issues/new>`_, just please keep the style consistent with the original source.
182
+
Patches, pull requests, and bug reports are `welcome <https://github.com/bear/python-twitter/issues/new>`_, just please keep the style consistent with the original source.
159
183
160
-
Add more example scripts.
184
+
In particular, having more example scripts would be a huge help. If you have
185
+
a program that uses python-twitter and would like a link in the documentation,
186
+
submit a pull request against ``twitter/doc/getting_started.rst`` and add your
187
+
program at the bottom.
161
188
162
189
The twitter.Status and ``twitter.User`` classes are going to be hard to keep in sync with the API if the API changes. More of the code could probably be written with introspection.
163
190
164
-
Statement coverage of ``twitter_test`` is only about 80% of twitter.py.
165
-
166
191
The ``twitter.Status`` and ``twitter.User`` classes could perform more validation on the property setters.
167
192
168
193
----------------
@@ -183,7 +208,7 @@ Now it's a full-on open source project with many contributors over time. See AUT
183
208
License
184
209
-------
185
210
186
-
|Copyright 2007-2014 The Python-Twitter Developers
211
+
|Copyright 2007-2016 The Python-Twitter Developers
187
212
|
188
213
|Licensed under the Apache License, Version 2.0 (the 'License');
189
214
|you may not use this file except in compliance with the License.
0 commit comments