{"id":21833,"library":"python-twitter","title":"python-twitter","description":"A Python wrapper around the Twitter API. Version 3.5 fixes DM endpoint handling. Release cadence is sporadic.","status":"active","version":"3.5","language":"python","source_language":"en","source_url":"https://github.com/bear/python-twitter","tags":["twitter","api","social-media"],"install":[{"cmd":"pip install python-twitter","lang":"bash","label":"Standard install"}],"dependencies":[{"reason":"HTTP library for API calls","package":"requests","optional":false},{"reason":"OAuth authentication","package":"requests-oauthlib","optional":false}],"imports":[{"note":"Wrong: Api is exposed at the top-level package, not submodule.","wrong":"from twitter.api import Api","symbol":"Api","correct":"from twitter import Api"}],"quickstart":{"code":"from twitter import Api\n\nconsumer_key = os.environ.get('TWITTER_CONSUMER_KEY', '')\nconsumer_secret = os.environ.get('TWITTER_CONSUMER_SECRET', '')\naccess_token_key = os.environ.get('TWITTER_ACCESS_TOKEN_KEY', '')\naccess_token_secret = os.environ.get('TWITTER_ACCESS_TOKEN_SECRET', '')\n\napi = Api(consumer_key, consumer_secret, access_token_key, access_token_secret)\nstatus = api.PostUpdate('Hello world!')\nprint(status.text)","lang":"python","description":"Authenticate and post a tweet."},"warnings":[{"fix":"Use Python 3.6+.","message":"In v3.0+, Python 2 support was dropped. Ensure you are using Python 3.","severity":"breaking","affected_versions":">=3.0"},{"fix":"Replace PostMedia() with PostUpdate() and pass media as an argument.","message":"Api.PostMedia() is deprecated and will be removed in a future version. Use Api.PostUpdate() with media parameter instead.","severity":"deprecated","affected_versions":">=3.2"},{"fix":"Use consumer_key, consumer_secret, access_token_key, access_token_secret as shown in quickstart.","message":"The 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).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use 'from twitter import Api' (not 'import twitter' then 'twitter.Api').","cause":"Incorrect import path - trying to import from the top-level 'twitter' package instead of direct import.","error":"ImportError: cannot import name 'Api' from 'twitter'"},{"fix":"Double-check your consumer key/secret and access token/secret. Ensure they are for the same Twitter App and user.","cause":"Invalid or missing OAuth credentials.","error":"twitter.error.TwitterError: [{u'message': u'Could not authenticate you', u'code': 32}]"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}