Questions tagged [twython]

An actively maintained, pure Python wrapper for the Twitter API. Supports both the normal and streaming Twitter APIs.

Twython is a library providing an easy (and up-to-date) way to access Twitter data in Python. Actively maintained and featuring support for both Python 2.6+ and Python 3, it's been battle tested by companies, educational institutions and individuals alike.

Full repository on GitHub
Full documentation

Support for:

  • User information
  • Twitter lists
  • Timelines
  • Direct Messages
  • Image Uploading!
    • Updating user status with an image
    • Changing user avatar
    • Changing user background image
    • Changing user banner image
  • Support for Twitter's Streaming API
  • Seamless Python 3 support
317 questions
2
votes
3 answers

Twython: Error running the examples

Hi i have just started to evaluate different options for python>Twitter api:s. I have written some code looking at the examples in the Twython package but i always end up getting the same error. AttributeError: 'Twython' object has no attribute…
Thom
  • 540
  • 5
  • 12
1
vote
1 answer

Stop Twitter streaming by timer with twython

I have a code that receives tweets and writes them to csv files. I want to stop this process after a certain amount of time. How can I add a timer to the program. Probably for this you need to use datetime somewhere. Test code, don't swear too…
kostya ivanov
  • 613
  • 5
  • 15
1
vote
1 answer

How to get more than 100 tweets using twython python

I am scraping the data from tweeter using a hashtag. My code below works perfectly. However, I would like to get 10 000 tweets and save them in the same JSON folder (Or save them in separate folder and then combine into one). When I run the code and…
Alex
  • 21
  • 5
1
vote
0 answers

How to get Twitter banner image using API?

I want to check the existence of the Twitter banner image by using Twython. The banner image can be retrieved by profile_banner_url but if the user doesn't have a banner image this parameter does not exist in the API call and the output will be as…
1
vote
1 answer

Twython API - How to see which of my 'friends' are following a specific user?

as you can see in this picture taken on the Desktop Twitter App (although a similar thing appears in the Mobile App too) example.jpg example2.jpg , when you visit the profile of a user that is followed by users that you are also following, a handy…
1
vote
1 answer

How to send a direct message with Twython?

I know this is a beginner question, but can someone please provide some sample code of sending a Twitter direct message (just text) with Twython? I can't seems to find a lot of specific documentation over this (I know it's briefly covered in the…
james
  • 343
  • 1
  • 2
  • 10
1
vote
1 answer

Is there any direct way/method to verify whether a Tweet exists or not?

I need a method that returns only True if a Tweet exists, and otherwise, returns False without using statuses_look() or try-except, as I don't want it to fetch all the data first just to see if it exists. E.g.: what I want to achieve: id =…
Wasit Shafi
  • 854
  • 1
  • 9
  • 15
1
vote
1 answer

'List index is out of range' error for accessing an attribute in the following layout

I am using the twitter streaming API but I am not able to access the screen_name attribute as the various layers of nesting is confusing me a little bit Here is what I tried results = t.search(q='tuberculosis', count=50) all_tweets =…
Ravish Jha
  • 481
  • 3
  • 25
1
vote
2 answers

Twython Twitter Post is Truncated

I'm trying to get some tweets using Twython, but even with tweet_mode:extended the results are still truncated. Any ideas how I can get the full text. def requestTweets(topic, resultType = "new", amount = 10, language = "en"): '''Get the n tweets…
Melodix
  • 59
  • 1
  • 5
1
vote
1 answer

Twitter API is not respecting my callback_url parameter

I've read all the threads about simiular issues on SO and elsewhere, and none of them have solved my problem. I'm using Twython as a wrapper around the API. I've tried setting oauth_callback EVERYWHERE. Using the internal mechanism in Tython…
D-Nice
  • 4,772
  • 14
  • 52
  • 86
1
vote
2 answers

Coordinates field in Tweet objects

In every tweet object there are two fields related to location, (i) place and (ii) coordinates. Whenever I tweet something and switch on the location, only the place filed gets value. I'm wondering in what conditions the coordinates field is…
amiref
  • 3,181
  • 7
  • 38
  • 62
1
vote
1 answer

Int and Integer in Twitter API

In Twitter API (https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/tweet-object), some of the fields are Int and some others Integer which are Nullable. For instance retweet_count is Int, but favourite_count is Integer (which is…
amiref
  • 3,181
  • 7
  • 38
  • 62
1
vote
1 answer

A tweet example with symbols field in entities object

According to Twitter (https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/entities-object), "symbols" filed in entities object represents symbols, i.e. $cashtags, included in the text of the Tweet. However, whatever I tried to find…
amiref
  • 3,181
  • 7
  • 38
  • 62
1
vote
1 answer

script stuck in try-except block

I am currently working on a Python script that essentially scrapes a given Twitter account for Spotify tracks and creates a playlist of the tracks found. The script is functioning properly for the most part but I am trying to incorporate some error…
1
vote
0 answers

Twython using Enterprise Search API

I am trying to scrape tweets from twitter using twython and I want to use enterprise search api for this because I want to define fromDate and toDate parameters. I couldn't find any way to do it though, and when I try to cursor tweets from this…
Tolga Oguz
  • 142
  • 1
  • 14