twittter


Nametwittter JSON
Version 1.19.6 PyPI version JSON
download
home_pagehttps://mike.verdone.ca/twitter/
SummaryAn API and command-line toolset for Twitter (twitter.com)
upload_time2024-04-04 22:01:20
maintainerNone
docs_urlNone
authorMike Verdone
requires_python!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7
licenseMIT License
keywords twitter irc command-line tools web 2.0
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Python Twitter Tools
====================

[![Tests](https://github.com/python-twitter-tools/twitter/workflows/Tests/badge.svg)](https://github.com/python-twitter-tools/twitter/actions)
[![Coverage Status](https://coveralls.io/repos/github/python-twitter-tools/twitter/badge.svg?branch=master)](https://coveralls.io/github/python-twitter-tools/twitter?branch=master)

The Minimalist Twitter API for Python is a Python API for Twitter,
everyone's favorite Web 2.0 Facebook-style status updater for people
on the go.

Also included is a Twitter command-line tool for getting your friends'
tweets and setting your own tweet from the safety and security of your
favorite shell and an IRC bot that can announce Twitter updates to an
IRC channel.

For more information:

 * install the [package](https://pypi.org/project/twitter/) `pip install twitter`
 * import the `twitter` package and run `help()` on it
 * run `twitter -h` for command-line tool help

twitter - The Command-Line Tool
-------------------------------

The command-line tool lets you do some awesome things:

 * view your tweets, recent replies, and tweets in lists
 * view the public timeline
 * follow and unfollow (leave) friends
 * various output formats for tweet information

The bottom line: type `twitter`, receive tweets.

twitterbot - The IRC Bot
------------------------

The IRC bot is associated with a Twitter account (either your own account or an
account you create for the bot). The bot announces all tweets from friends
it is following. It can be made to follow or leave friends through IRC /msg
commands.


`twitter-log`
-------------

`twitter-log` is a simple command-line tool that dumps all public
tweets from a given user in a simple text format. It is useful to get
a complete offsite backup of all your tweets. Run `twitter-log` and
read the instructions.

`twitter-archiver` and `twitter-follow`
---------------------------------------

twitter-archiver will log all the tweets posted by any user since they
started posting. twitter-follow will print a list of all of all the
followers of a user (or all the users that user follows).


Programming with the Twitter API classes
========================================

The `Twitter` and `TwitterStream` classes are the key to building your own
Twitter-enabled applications.


The `Twitter` class
-------------------

The minimalist yet fully featured Twitter API class.

Get RESTful data by accessing members of this class. The result
is decoded python objects (lists and dicts).

The Twitter API is documented at:

**[https://developer.twitter.com/en/docs](https://developer.twitter.com/en/docs)**

The list of most accessible functions is listed at:

**[https://developer.twitter.com/en/docs/api-reference-index](https://developer.twitter.com/en/docs/api-reference-index)**

Examples:

```python
from twitter import *

t = Twitter(
    auth=OAuth(token, token_secret, consumer_key, consumer_secret))

# Get your "home" timeline
t.statuses.home_timeline()

# Get a particular friend's timeline
t.statuses.user_timeline(screen_name="boogheta")

# to pass in GET/POST parameters, such as `count`
t.statuses.home_timeline(count=5)

# to pass in the GET/POST parameter `id` you need to use `_id`
t.statuses.show(_id=1234567890)

# Update your status
t.statuses.update(
    status="Using @boogheta's sweet Python Twitter Tools.")

# Send a direct message
t.direct_messages.events.new(
    _json={
        "event": {
            "type": "message_create",
            "message_create": {
                "target": {
                    "recipient_id": t.users.show(screen_name="boogheta")["id"]},
                "message_data": {
                    "text": "I think yer swell!"}}}})

# Get the members of maxmunnecke's list "network analysis tools" (grab the list_id within the url) https://twitter.com/i/lists/1130857490764091392
t.lists.members(owner_screen_name="maxmunnecke", list_id="1130857490764091392")

# Favorite/like a status
status = t.statuses.home_timeline()[0]
if not status['favorited']:
    t.favorites.create(_id=status['id'])

# An *optional* `_timeout` parameter can also be used for API
# calls which take much more time than normal or twitter stops
# responding for some reason:
t.users.lookup(
    screen_name=','.join(A_LIST_OF_100_SCREEN_NAMES), _timeout=1)

# Overriding Method: GET/POST
# you should not need to use this method as this library properly
# detects whether GET or POST should be used, Nevertheless
# to force a particular method, use `_method`
t.statuses.oembed(_id=1234567890, _method='GET')

# Send images along with your tweets:
# - first just read images from the web or from files the regular way:
with open("example.png", "rb") as imagefile:
    imagedata = imagefile.read()
# - then upload medias one by one on Twitter's dedicated server
#   and collect each one's id:
t_upload = Twitter(domain='upload.twitter.com',
    auth=OAuth(token, token_secret, consumer_key, consumer_secret))
id_img1 = t_upload.media.upload(media=imagedata)["media_id_string"]
id_img2 = t_upload.media.upload(media=imagedata)["media_id_string"]
# - finally send your tweet with the list of media ids:
t.statuses.update(status="PTT ★", media_ids=",".join([id_img1, id_img2]))

# Or send a tweet with an image (or set a logo/banner similarly)
# using the old deprecated method that will probably disappear some day
params = {"media[]": imagedata, "status": "PTT ★"}
# Or for an image encoded as base64:
params = {"media[]": base64_image, "status": "PTT ★", "_base64": True}
t.statuses.update_with_media(**params)

# Attach text metadata to medias sent, using the upload.twitter.com route
# using the _json workaround to send json arguments as POST body
# (warning: to be done before attaching the media to a tweet)
t_upload.media.metadata.create(_json={
  "media_id": id_img1,
  "alt_text": { "text": "metadata generated via PTT!" }
})
# or with the shortcut arguments ("alt_text" and "text" work):
t_upload.media.metadata.create(media_id=id_img1, text="metadata generated via PTT!")
```

Searching Twitter:
```python
# Search for the latest tweets about #pycon
t.search.tweets(q="#pycon")

# Search for the latest tweets about #pycon, using [extended mode](https://developer.twitter.com/en/docs/tweets/tweet-updates)
t.search.tweets(q="#pycon", tweet_mode='extended')
```


Retrying after reaching the API rate limit
------------------------------------------

Simply create the `Twitter` instance with the argument `retry=True`, then the
HTTP error codes `429`, `502`, `503`, and `504` will cause a retry of the last
request.

If `retry` is an integer, it defines the maximum number of retry attempts.


Using the data returned
-----------------------

Twitter API calls return decoded JSON. This is converted into
a bunch of Python lists, dicts, ints, and strings. For example:

```python
x = twitter.statuses.home_timeline()

# The first 'tweet' in the timeline
x[0]

# The screen name of the user who wrote the first 'tweet'
x[0]['user']['screen_name']
```

Getting raw XML data
--------------------

If you prefer to get your Twitter data in XML format, pass
`format="xml"` to the `Twitter` object when you instantiate it:

```python
twitter = Twitter(format="xml")
```

The output will not be parsed in any way. It will be a raw string
of XML.

The `TwitterStream` class
-------------------------

The `TwitterStream` object is an interface to the Twitter Stream
API. This can be used pretty much the same as the `Twitter` class,
except the result of calling a method will be an iterator that
yields objects decoded from the stream. For example::

```python
twitter_stream = TwitterStream(auth=OAuth(...))
iterator = twitter_stream.statuses.sample()

for tweet in iterator:
    ...do something with this tweet...
```

Per default the `TwitterStream` object uses
[public streams](https://dev.twitter.com/docs/streaming-apis/streams/public).
If you want to use one of the other
[streaming APIs](https://dev.twitter.com/docs/streaming-apis), specify the URL
manually.

The iterator will `yield` until the TCP connection breaks. When the
connection breaks, the iterator yields `{'hangup': True}` (and
raises `StopIteration` if iterated again).

Similarly, if the stream does not produce heartbeats for more than
90 seconds, the iterator yields `{'hangup': True,
'heartbeat_timeout': True}` (and raises `StopIteration` if
iterated again).

The `timeout` parameter controls the maximum time between
yields. If it is nonzero, then the iterator will yield either
stream data or `{'timeout': True}` within the timeout period. This
is useful if you want your program to do other stuff in between
waiting for tweets.

The `block` parameter sets the stream to be fully non-blocking.
In this mode, the iterator always yields immediately. It returns
stream data, or `None`.

Note that `timeout` supercedes this argument, so it should also be
set `None` to use this mode, and non-blocking can potentially lead
to 100% CPU usage.

Twitter `Response` Objects
--------------------------

Response from a Twitter request. Behaves like a list or a string
(depending on requested format), but it has a few other interesting
attributes.

`headers` gives you access to the response headers as an
`httplib.HTTPHeaders` instance. Use `response.headers.get('h')`
to retrieve a header.

Authentication
--------------

You can authenticate with Twitter in three ways: NoAuth, OAuth, or
OAuth2 (app-only). Get `help()` on these classes to learn how to use them.

OAuth and OAuth2 are probably the most useful.


Working with OAuth
------------------

Visit the Twitter developer page and create a new application:

**[https://dev.twitter.com/apps/new](https://dev.twitter.com/apps/new)**

This will get you a `CONSUMER_KEY` and `CONSUMER_SECRET`.

When users run your application they have to authenticate your app
with their Twitter account. A few HTTP calls to Twitter are required
to do this. Please see the `twitter.oauth_dance` module to see how this
is done. If you are making a command-line app, you can use the
`oauth_dance()` function directly.

Performing the "oauth dance" gets you an oauth token and oauth secret
that authenticate the user with Twitter. You should save these for
later, so that the user doesn't have to do the oauth dance again.

`read_token_file` and `write_token_file` are utility methods to read and
write OAuth `token` and `secret` key values. The values are stored as
strings in the file. Not terribly exciting.

Finally, you can use the `OAuth` authenticator to connect to Twitter. In
code it all goes like this:

```python
from twitter import *

MY_TWITTER_CREDS = os.path.expanduser('~/.my_app_credentials')
if not os.path.exists(MY_TWITTER_CREDS):
    oauth_dance("My App Name", CONSUMER_KEY, CONSUMER_SECRET,
                MY_TWITTER_CREDS)

oauth_token, oauth_secret = read_token_file(MY_TWITTER_CREDS)

twitter = Twitter(auth=OAuth(
    oauth_token, oauth_secret, CONSUMER_KEY, CONSUMER_SECRET))

# Now work with Twitter
twitter.statuses.update(status='Hello, world!')
```

Working with `OAuth2`
---------------------

Twitter only supports the application-only flow of OAuth2 for certain
API endpoints. This OAuth2 authenticator only supports the application-only
flow right now.

To authenticate with OAuth2, visit the Twitter developer page and create a new
application:

**[https://dev.twitter.com/apps/new](https://dev.twitter.com/apps/new)**

This will get you a `CONSUMER_KEY` and `CONSUMER_SECRET`.

Exchange your `CONSUMER_KEY` and `CONSUMER_SECRET` for a bearer token using the
`oauth2_dance` function.

Finally, you can use the `OAuth2` authenticator and your bearer token to connect
to Twitter. In code it goes like this::

```python
twitter = Twitter(auth=OAuth2(bearer_token=BEARER_TOKEN))

# Now work with Twitter
twitter.search.tweets(q='keyword')
```

License
=======

Python Twitter Tools are released under an MIT License.

            

Raw data

            {
    "_id": null,
    "home_page": "https://mike.verdone.ca/twitter/",
    "name": "twittter",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7",
    "maintainer_email": null,
    "keywords": "twitter, IRC, command-line tools, web 2.0",
    "author": "Mike Verdone",
    "author_email": "mike.verdone+twitterapi@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/71/83/8e92f4f945d9808720fd4173b1f7fb583cf684ff2785b5995338788c2537/twittter-1.19.6.tar.gz",
    "platform": null,
    "description": "Python Twitter Tools\r\n====================\r\n\r\n[![Tests](https://github.com/python-twitter-tools/twitter/workflows/Tests/badge.svg)](https://github.com/python-twitter-tools/twitter/actions)\r\n[![Coverage Status](https://coveralls.io/repos/github/python-twitter-tools/twitter/badge.svg?branch=master)](https://coveralls.io/github/python-twitter-tools/twitter?branch=master)\r\n\r\nThe Minimalist Twitter API for Python is a Python API for Twitter,\r\neveryone's favorite Web 2.0 Facebook-style status updater for people\r\non the go.\r\n\r\nAlso included is a Twitter command-line tool for getting your friends'\r\ntweets and setting your own tweet from the safety and security of your\r\nfavorite shell and an IRC bot that can announce Twitter updates to an\r\nIRC channel.\r\n\r\nFor more information:\r\n\r\n * install the [package](https://pypi.org/project/twitter/) `pip install twitter`\r\n * import the `twitter` package and run `help()` on it\r\n * run `twitter -h` for command-line tool help\r\n\r\ntwitter - The Command-Line Tool\r\n-------------------------------\r\n\r\nThe command-line tool lets you do some awesome things:\r\n\r\n * view your tweets, recent replies, and tweets in lists\r\n * view the public timeline\r\n * follow and unfollow (leave) friends\r\n * various output formats for tweet information\r\n\r\nThe bottom line: type `twitter`, receive tweets.\r\n\r\ntwitterbot - The IRC Bot\r\n------------------------\r\n\r\nThe IRC bot is associated with a Twitter account (either your own account or an\r\naccount you create for the bot). The bot announces all tweets from friends\r\nit is following. It can be made to follow or leave friends through IRC /msg\r\ncommands.\r\n\r\n\r\n`twitter-log`\r\n-------------\r\n\r\n`twitter-log` is a simple command-line tool that dumps all public\r\ntweets from a given user in a simple text format. It is useful to get\r\na complete offsite backup of all your tweets. Run `twitter-log` and\r\nread the instructions.\r\n\r\n`twitter-archiver` and `twitter-follow`\r\n---------------------------------------\r\n\r\ntwitter-archiver will log all the tweets posted by any user since they\r\nstarted posting. twitter-follow will print a list of all of all the\r\nfollowers of a user (or all the users that user follows).\r\n\r\n\r\nProgramming with the Twitter API classes\r\n========================================\r\n\r\nThe `Twitter` and `TwitterStream` classes are the key to building your own\r\nTwitter-enabled applications.\r\n\r\n\r\nThe `Twitter` class\r\n-------------------\r\n\r\nThe minimalist yet fully featured Twitter API class.\r\n\r\nGet RESTful data by accessing members of this class. The result\r\nis decoded python objects (lists and dicts).\r\n\r\nThe Twitter API is documented at:\r\n\r\n**[https://developer.twitter.com/en/docs](https://developer.twitter.com/en/docs)**\r\n\r\nThe list of most accessible functions is listed at:\r\n\r\n**[https://developer.twitter.com/en/docs/api-reference-index](https://developer.twitter.com/en/docs/api-reference-index)**\r\n\r\nExamples:\r\n\r\n```python\r\nfrom twitter import *\r\n\r\nt = Twitter(\r\n    auth=OAuth(token, token_secret, consumer_key, consumer_secret))\r\n\r\n# Get your \"home\" timeline\r\nt.statuses.home_timeline()\r\n\r\n# Get a particular friend's timeline\r\nt.statuses.user_timeline(screen_name=\"boogheta\")\r\n\r\n# to pass in GET/POST parameters, such as `count`\r\nt.statuses.home_timeline(count=5)\r\n\r\n# to pass in the GET/POST parameter `id` you need to use `_id`\r\nt.statuses.show(_id=1234567890)\r\n\r\n# Update your status\r\nt.statuses.update(\r\n    status=\"Using @boogheta's sweet Python Twitter Tools.\")\r\n\r\n# Send a direct message\r\nt.direct_messages.events.new(\r\n    _json={\r\n        \"event\": {\r\n            \"type\": \"message_create\",\r\n            \"message_create\": {\r\n                \"target\": {\r\n                    \"recipient_id\": t.users.show(screen_name=\"boogheta\")[\"id\"]},\r\n                \"message_data\": {\r\n                    \"text\": \"I think yer swell!\"}}}})\r\n\r\n# Get the members of maxmunnecke's list \"network analysis tools\" (grab the list_id within the url) https://twitter.com/i/lists/1130857490764091392\r\nt.lists.members(owner_screen_name=\"maxmunnecke\", list_id=\"1130857490764091392\")\r\n\r\n# Favorite/like a status\r\nstatus = t.statuses.home_timeline()[0]\r\nif not status['favorited']:\r\n    t.favorites.create(_id=status['id'])\r\n\r\n# An *optional* `_timeout` parameter can also be used for API\r\n# calls which take much more time than normal or twitter stops\r\n# responding for some reason:\r\nt.users.lookup(\r\n    screen_name=','.join(A_LIST_OF_100_SCREEN_NAMES), _timeout=1)\r\n\r\n# Overriding Method: GET/POST\r\n# you should not need to use this method as this library properly\r\n# detects whether GET or POST should be used, Nevertheless\r\n# to force a particular method, use `_method`\r\nt.statuses.oembed(_id=1234567890, _method='GET')\r\n\r\n# Send images along with your tweets:\r\n# - first just read images from the web or from files the regular way:\r\nwith open(\"example.png\", \"rb\") as imagefile:\r\n    imagedata = imagefile.read()\r\n# - then upload medias one by one on Twitter's dedicated server\r\n#   and collect each one's id:\r\nt_upload = Twitter(domain='upload.twitter.com',\r\n    auth=OAuth(token, token_secret, consumer_key, consumer_secret))\r\nid_img1 = t_upload.media.upload(media=imagedata)[\"media_id_string\"]\r\nid_img2 = t_upload.media.upload(media=imagedata)[\"media_id_string\"]\r\n# - finally send your tweet with the list of media ids:\r\nt.statuses.update(status=\"PTT \u00e2\u02dc\u2026\", media_ids=\",\".join([id_img1, id_img2]))\r\n\r\n# Or send a tweet with an image (or set a logo/banner similarly)\r\n# using the old deprecated method that will probably disappear some day\r\nparams = {\"media[]\": imagedata, \"status\": \"PTT \u00e2\u02dc\u2026\"}\r\n# Or for an image encoded as base64:\r\nparams = {\"media[]\": base64_image, \"status\": \"PTT \u00e2\u02dc\u2026\", \"_base64\": True}\r\nt.statuses.update_with_media(**params)\r\n\r\n# Attach text metadata to medias sent, using the upload.twitter.com route\r\n# using the _json workaround to send json arguments as POST body\r\n# (warning: to be done before attaching the media to a tweet)\r\nt_upload.media.metadata.create(_json={\r\n  \"media_id\": id_img1,\r\n  \"alt_text\": { \"text\": \"metadata generated via PTT!\" }\r\n})\r\n# or with the shortcut arguments (\"alt_text\" and \"text\" work):\r\nt_upload.media.metadata.create(media_id=id_img1, text=\"metadata generated via PTT!\")\r\n```\r\n\r\nSearching Twitter:\r\n```python\r\n# Search for the latest tweets about #pycon\r\nt.search.tweets(q=\"#pycon\")\r\n\r\n# Search for the latest tweets about #pycon, using [extended mode](https://developer.twitter.com/en/docs/tweets/tweet-updates)\r\nt.search.tweets(q=\"#pycon\", tweet_mode='extended')\r\n```\r\n\r\n\r\nRetrying after reaching the API rate limit\r\n------------------------------------------\r\n\r\nSimply create the `Twitter` instance with the argument `retry=True`, then the\r\nHTTP error codes `429`, `502`, `503`, and `504` will cause a retry of the last\r\nrequest.\r\n\r\nIf `retry` is an integer, it defines the maximum number of retry attempts.\r\n\r\n\r\nUsing the data returned\r\n-----------------------\r\n\r\nTwitter API calls return decoded JSON. This is converted into\r\na bunch of Python lists, dicts, ints, and strings. For example:\r\n\r\n```python\r\nx = twitter.statuses.home_timeline()\r\n\r\n# The first 'tweet' in the timeline\r\nx[0]\r\n\r\n# The screen name of the user who wrote the first 'tweet'\r\nx[0]['user']['screen_name']\r\n```\r\n\r\nGetting raw XML data\r\n--------------------\r\n\r\nIf you prefer to get your Twitter data in XML format, pass\r\n`format=\"xml\"` to the `Twitter` object when you instantiate it:\r\n\r\n```python\r\ntwitter = Twitter(format=\"xml\")\r\n```\r\n\r\nThe output will not be parsed in any way. It will be a raw string\r\nof XML.\r\n\r\nThe `TwitterStream` class\r\n-------------------------\r\n\r\nThe `TwitterStream` object is an interface to the Twitter Stream\r\nAPI. This can be used pretty much the same as the `Twitter` class,\r\nexcept the result of calling a method will be an iterator that\r\nyields objects decoded from the stream. For example::\r\n\r\n```python\r\ntwitter_stream = TwitterStream(auth=OAuth(...))\r\niterator = twitter_stream.statuses.sample()\r\n\r\nfor tweet in iterator:\r\n    ...do something with this tweet...\r\n```\r\n\r\nPer default the `TwitterStream` object uses\r\n[public streams](https://dev.twitter.com/docs/streaming-apis/streams/public).\r\nIf you want to use one of the other\r\n[streaming APIs](https://dev.twitter.com/docs/streaming-apis), specify the URL\r\nmanually.\r\n\r\nThe iterator will `yield` until the TCP connection breaks. When the\r\nconnection breaks, the iterator yields `{'hangup': True}` (and\r\nraises `StopIteration` if iterated again).\r\n\r\nSimilarly, if the stream does not produce heartbeats for more than\r\n90 seconds, the iterator yields `{'hangup': True,\r\n'heartbeat_timeout': True}` (and raises `StopIteration` if\r\niterated again).\r\n\r\nThe `timeout` parameter controls the maximum time between\r\nyields. If it is nonzero, then the iterator will yield either\r\nstream data or `{'timeout': True}` within the timeout period. This\r\nis useful if you want your program to do other stuff in between\r\nwaiting for tweets.\r\n\r\nThe `block` parameter sets the stream to be fully non-blocking.\r\nIn this mode, the iterator always yields immediately. It returns\r\nstream data, or `None`.\r\n\r\nNote that `timeout` supercedes this argument, so it should also be\r\nset `None` to use this mode, and non-blocking can potentially lead\r\nto 100% CPU usage.\r\n\r\nTwitter `Response` Objects\r\n--------------------------\r\n\r\nResponse from a Twitter request. Behaves like a list or a string\r\n(depending on requested format), but it has a few other interesting\r\nattributes.\r\n\r\n`headers` gives you access to the response headers as an\r\n`httplib.HTTPHeaders` instance. Use `response.headers.get('h')`\r\nto retrieve a header.\r\n\r\nAuthentication\r\n--------------\r\n\r\nYou can authenticate with Twitter in three ways: NoAuth, OAuth, or\r\nOAuth2 (app-only). Get `help()` on these classes to learn how to use them.\r\n\r\nOAuth and OAuth2 are probably the most useful.\r\n\r\n\r\nWorking with OAuth\r\n------------------\r\n\r\nVisit the Twitter developer page and create a new application:\r\n\r\n**[https://dev.twitter.com/apps/new](https://dev.twitter.com/apps/new)**\r\n\r\nThis will get you a `CONSUMER_KEY` and `CONSUMER_SECRET`.\r\n\r\nWhen users run your application they have to authenticate your app\r\nwith their Twitter account. A few HTTP calls to Twitter are required\r\nto do this. Please see the `twitter.oauth_dance` module to see how this\r\nis done. If you are making a command-line app, you can use the\r\n`oauth_dance()` function directly.\r\n\r\nPerforming the \"oauth dance\" gets you an oauth token and oauth secret\r\nthat authenticate the user with Twitter. You should save these for\r\nlater, so that the user doesn't have to do the oauth dance again.\r\n\r\n`read_token_file` and `write_token_file` are utility methods to read and\r\nwrite OAuth `token` and `secret` key values. The values are stored as\r\nstrings in the file. Not terribly exciting.\r\n\r\nFinally, you can use the `OAuth` authenticator to connect to Twitter. In\r\ncode it all goes like this:\r\n\r\n```python\r\nfrom twitter import *\r\n\r\nMY_TWITTER_CREDS = os.path.expanduser('~/.my_app_credentials')\r\nif not os.path.exists(MY_TWITTER_CREDS):\r\n    oauth_dance(\"My App Name\", CONSUMER_KEY, CONSUMER_SECRET,\r\n                MY_TWITTER_CREDS)\r\n\r\noauth_token, oauth_secret = read_token_file(MY_TWITTER_CREDS)\r\n\r\ntwitter = Twitter(auth=OAuth(\r\n    oauth_token, oauth_secret, CONSUMER_KEY, CONSUMER_SECRET))\r\n\r\n# Now work with Twitter\r\ntwitter.statuses.update(status='Hello, world!')\r\n```\r\n\r\nWorking with `OAuth2`\r\n---------------------\r\n\r\nTwitter only supports the application-only flow of OAuth2 for certain\r\nAPI endpoints. This OAuth2 authenticator only supports the application-only\r\nflow right now.\r\n\r\nTo authenticate with OAuth2, visit the Twitter developer page and create a new\r\napplication:\r\n\r\n**[https://dev.twitter.com/apps/new](https://dev.twitter.com/apps/new)**\r\n\r\nThis will get you a `CONSUMER_KEY` and `CONSUMER_SECRET`.\r\n\r\nExchange your `CONSUMER_KEY` and `CONSUMER_SECRET` for a bearer token using the\r\n`oauth2_dance` function.\r\n\r\nFinally, you can use the `OAuth2` authenticator and your bearer token to connect\r\nto Twitter. In code it goes like this::\r\n\r\n```python\r\ntwitter = Twitter(auth=OAuth2(bearer_token=BEARER_TOKEN))\r\n\r\n# Now work with Twitter\r\ntwitter.search.tweets(q='keyword')\r\n```\r\n\r\nLicense\r\n=======\r\n\r\nPython Twitter Tools are released under an MIT License.\r\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "An API and command-line toolset for Twitter (twitter.com)",
    "version": "1.19.6",
    "project_urls": {
        "Homepage": "https://mike.verdone.ca/twitter/"
    },
    "split_keywords": [
        "twitter",
        " irc",
        " command-line tools",
        " web 2.0"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "48ecd0595f764c223275a4af4bd9fee8beda25e8f5ac7f2869871e32d01689b9",
                "md5": "48cad4e4dea3925ef54147d70840c1d8",
                "sha256": "8e63d0d71ca74b787850b758002defbc23387f01da9f02d23ba37ea175b67e2a"
            },
            "downloads": -1,
            "filename": "twittter-1.19.6-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "48cad4e4dea3925ef54147d70840c1d8",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7",
            "size": 50482,
            "upload_time": "2024-04-04T22:01:17",
            "upload_time_iso_8601": "2024-04-04T22:01:17.114374Z",
            "url": "https://files.pythonhosted.org/packages/48/ec/d0595f764c223275a4af4bd9fee8beda25e8f5ac7f2869871e32d01689b9/twittter-1.19.6-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "71838e92f4f945d9808720fd4173b1f7fb583cf684ff2785b5995338788c2537",
                "md5": "21bfa040bbb6011ab730a4380e7b2736",
                "sha256": "72d6667a6452ac001d2e5b18da02ad773f42a5707cf5c41b8956467f458d12cc"
            },
            "downloads": -1,
            "filename": "twittter-1.19.6.tar.gz",
            "has_sig": false,
            "md5_digest": "21bfa040bbb6011ab730a4380e7b2736",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7",
            "size": 53554,
            "upload_time": "2024-04-04T22:01:20",
            "upload_time_iso_8601": "2024-04-04T22:01:20.597511Z",
            "url": "https://files.pythonhosted.org/packages/71/83/8e92f4f945d9808720fd4173b1f7fb583cf684ff2785b5995338788c2537/twittter-1.19.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-04 22:01:20",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "twittter"
}
        
Elapsed time: 2.14983s