Registry / communication / python-twitter

python-twitter

JSON →
library3.5pypypi✓ verified 87d ago

A Python wrapper around the Twitter API. Version 3.5 fixes DM endpoint handling. Release cadence is sporadic.

pip install python-twitter
INSTALL
IMPORT
SIG · PYTHON-TWITTER
P
python-twitter
communicationpythonv3.5
Install
2.6s avg
Import
747ms
Disk
26MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.790s · 27.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.6s · import 0.704s · 28MB
26MB installed
● package 26MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Api
from twitter import Api
from twitter.api import Api
Wrong: Api is exposed at the top-level package, not submodule.

Authenticate and post a tweet.

from twitter import Api consumer_key = os.environ.get('TWITTER_CONSUMER_KEY', '') consumer_secret = os.environ.get('TWITTER_CONSUMER_SECRET', '') access_token_key = os.environ.get('TWITTER_ACCESS_TOKEN_KEY', '') access_token_secret = os.environ.get('TWITTER_ACCESS_TOKEN_SECRET', '') api = Api(consumer_key, consumer_secret, access_token_key, access_token_secret) status = api.PostUpdate('Hello world!') print(status.text)
Debug
Known issues
breakingIn v3.0+, Python 2 support was dropped. Ensure you are using Python 3.
fix
Use Python 3.6+.
affects: >=3.0
deprecatedApi.PostMedia() is deprecated and will be removed in a future version. Use Api.PostUpdate() with media parameter instead.
fix
Replace PostMedia() with PostUpdate() and pass media as an argument.
affects: >=3.2
gotchaThe library previously used a different OAuth flow. Make sure you are using the correct set of keys (API key, API secret key, Access token, Access token secret).
fix
Use consumer_key, consumer_secret, access_token_key, access_token_secret as shown in quickstart.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'Api' from 'twitter'
Incorrect import path - trying to import from the top-level 'twitter' package instead of direct import.
fix
Use 'from twitter import Api' (not 'import twitter' then 'twitter.Api').
twitter.error.TwitterError: [{u'message': u'Could not authenticate you', u'code': 32}]
Invalid or missing OAuth credentials.
fix
Double-check your consumer key/secret and access token/secret. Ensure they are for the same Twitter App and user.
Upgrade
Version history
3.5latest on PyPI · released Nov 3, 2018
Audit
Dependencies
requestsrequiredHTTP library for API calls
requests-oauthlibrequiredOAuth authentication
Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
1
Resources
python-twitter — pip install python-twitter · libregistry