• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

python_twitter.egg-info/H03-May-2022-969707

twitter/H07-Jun-2018-6,4275,417

AUTHORS.rstH A D01-Dec-2017718 3936

CHANGESH A D01-Dec-201721.7 KiB658484

COPYINGH A D26-Nov-2017605 1410

GAE.rstH A D07-Jun-20182.4 KiB5640

LICENSEH A D11-Mar-201611.1 KiB203169

MANIFEST.inH A D07-Jun-2018118 87

NOTICEH A D26-Nov-2017109 42

PKG-INFOH A D07-Jun-201839.1 KiB969707

README.rstH A D07-Jun-20188.3 KiB244162

setup.cfgH A D07-Jun-2018283 2417

setup.pyH A D03-May-20222.7 KiB7750

README.rst

1Python Twitter
2
3A Python wrapper around the Twitter API.
4
5By the `Python-Twitter Developers <python-twitter@googlegroups.com>`_
6
7.. image:: https://img.shields.io/pypi/v/python-twitter.svg
8    :target: https://pypi.python.org/pypi/python-twitter/
9    :alt: Downloads
10
11.. image:: https://readthedocs.org/projects/python-twitter/badge/?version=latest
12    :target: http://python-twitter.readthedocs.org/en/latest/?badge=latest
13    :alt: Documentation Status
14
15.. image:: https://circleci.com/gh/bear/python-twitter.svg?style=svg
16    :target: https://circleci.com/gh/bear/python-twitter
17    :alt: Circle CI
18
19.. image:: http://codecov.io/github/bear/python-twitter/coverage.svg?branch=master
20    :target: http://codecov.io/github/bear/python-twitter
21    :alt: Codecov
22
23.. image:: https://requires.io/github/bear/python-twitter/requirements.svg?branch=master
24     :target: https://requires.io/github/bear/python-twitter/requirements/?branch=master
25     :alt: Requirements Status
26
27.. image:: https://dependencyci.com/github/bear/python-twitter/badge
28     :target: https://dependencyci.com/github/bear/python-twitter
29     :alt: Dependency Status
30
31============
32Introduction
33============
34
35This 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.
36
37`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.
38
39==========
40Installing
41==========
42
43You can install python-twitter using::
44
45    $ pip install python-twitter
46
47
48If you are using python-twitter on Google App Engine, see `more information <GAE.rst>`_ about including 3rd party vendor library dependencies in your App Engine project.
49
50
51================
52Getting the code
53================
54
55The code is hosted at https://github.com/bear/python-twitter
56
57Check out the latest development version anonymously with::
58
59    $ git clone git://github.com/bear/python-twitter.git
60    $ cd python-twitter
61
62To install dependencies, run either::
63
64	$ make dev
65
66or::
67
68    $ pip install -Ur requirements.testing.txt
69    $ pip install -Ur requirements.txt
70
71Note that ```make dev``` will install into your local ```pyenv``` all of the versions needed for test runs using ```tox```.
72
73To install the minimal dependencies for production use (i.e., what is installed
74with ``pip install python-twitter``) run::
75
76    $ make env
77
78or::
79
80    $ pip install -Ur requirements.txt
81
82=============
83Running Tests
84=============
85The test suite can be run against a single Python version or against a range of them depending on which Makefile target you select.
86
87Note that tests require ```pip install pytest``` and optionally ```pip install pytest-cov``` (these are included if you have installed dependencies from ```requirements.testing.txt```)
88
89To run the unit tests with a single Python version::
90
91    $ make test
92
93to also run code coverage::
94
95    $ make coverage
96
97To run the unit tests against a set of Python versions::
98
99    $ make tox
100
101=============
102Documentation
103=============
104
105View the latest python-twitter documentation at
106https://python-twitter.readthedocs.io. You can view Twitter's API documentation at: https://dev.twitter.com/overview/documentation
107
108=====
109Using
110=====
111
112The 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.io which contains information about getting your authentication keys from Twitter and using the library.
113
114----
115Using with Django
116----
117
118Additional 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
119
120------
121Models
122------
123
124The library utilizes models to represent various data structures returned by Twitter. Those models are:
125    * twitter.Category
126    * twitter.DirectMessage
127    * twitter.Hashtag
128    * twitter.List
129    * twitter.Media
130    * twitter.Status
131    * twitter.Trend
132    * twitter.Url
133    * twitter.User
134    * twitter.UserStatus
135
136To read the documentation for any of these models, run::
137
138    $ pydoc twitter.[model]
139
140---
141API
142---
143
144The API is exposed via the ``twitter.Api`` class.
145
146The 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.io for a more information.
147
148To generate an Access Token you have to pick what type of access your application requires and then do one of the following:
149
150- `Generate a token to access your own account <https://dev.twitter.com/oauth/overview/application-owner-access-tokens>`_
151- `Generate a pin-based token <https://dev.twitter.com/oauth/pin-based>`_
152- use the helper script `get_access_token.py <https://github.com/bear/python-twitter/blob/master/get_access_token.py>`_
153
154For full details see the `Twitter OAuth Overview <https://dev.twitter.com/oauth/overview>`_
155
156To create an instance of the ``twitter.Api`` with login credentials (Twitter now requires an OAuth Access Token for all API calls)::
157
158    >>> import twitter
159    >>> api = twitter.Api(consumer_key='consumer_key',
160                          consumer_secret='consumer_secret',
161                          access_token_key='access_token',
162                          access_token_secret='access_token_secret')
163
164To see if your credentials are successful::
165
166    >>> print(api.VerifyCredentials())
167    {"id": 16133, "location": "Philadelphia", "name": "bear"}
168
169**NOTE**: much more than the small sample given here will print
170
171To fetch a single user's public status messages, where ``user`` is a Twitter user's screen name::
172
173    >>> statuses = api.GetUserTimeline(screen_name=user)
174    >>> print([s.text for s in statuses])
175
176To fetch a list a user's friends::
177
178    >>> users = api.GetFriends()
179    >>> print([u.name for u in users])
180
181To post a Twitter status message::
182
183    >>> status = api.PostUpdate('I love python-twitter!')
184    >>> print(status.text)
185    I love python-twitter!
186
187There are many more API methods, to read the full API documentation either
188check out the documentation on `readthedocs
189<https://python-twitter.readthedocs.io>`_, build the documentation locally
190with::
191
192    $ make docs
193
194or check out the inline documentation with::
195
196    $ pydoc twitter.Api
197
198----
199Todo
200----
201
202Patches, 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.
203
204In particular, having more example scripts would be a huge help. If you have
205a program that uses python-twitter and would like a link in the documentation,
206submit a pull request against ``twitter/doc/getting_started.rst`` and add your
207program at the bottom.
208
209The 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.
210
211The ``twitter.Status`` and ``twitter.User`` classes could perform more validation on the property setters.
212
213----------------
214More Information
215----------------
216
217Please visit `the google group <http://groups.google.com/group/python-twitter>`_ for more discussion.
218
219------------
220Contributors
221------------
222
223Originally two libraries by DeWitt Clinton and Mike Taylor which was then merged into python-twitter.
224
225Now it's a full-on open source project with many contributors over time. See AUTHORS.rst for the complete list.
226
227-------
228License
229-------
230
231| Copyright 2007-2016 The Python-Twitter Developers
232|
233| Licensed under the Apache License, Version 2.0 (the 'License');
234| you may not use this file except in compliance with the License.
235| You may obtain a copy of the License at
236|
237|     http://www.apache.org/licenses/LICENSE-2.0
238|
239| Unless required by applicable law or agreed to in writing, software
240| distributed under the License is distributed on an 'AS IS' BASIS,
241| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
242| See the License for the specific language governing permissions and
243| limitations under the License.
244