Questions tagged [tweepy]

Tweepy is an easy-to-use Python library for accessing the Twitter API. It can be used with Python (3.7+).

Tweepy is an open source Python library for accessing the Twitter API.

The source code and documentation are available on GitHub. The library also has a community Discord server.

3361 questions
23
votes
3 answers

Twitter error code 429 with Tweepy

I am trying to create a project that accesses a twitter account using the tweepy api but I am faced with status code 429. Now, I've looked around and I see that it means that I have too many requests. However, I am only ever for 10 tweets at a time…
DSchana
  • 968
  • 3
  • 13
  • 28
23
votes
4 answers

How to add a location filter to tweepy module

I have found the following piece of code that works pretty well for letting me view in Python Shell the standard 1% of the twitter firehose: import sys import tweepy consumer_key="" consumer_secret="" access_key = "" access_secret = "" auth =…
gdogg371
  • 3,879
  • 14
  • 63
  • 107
20
votes
2 answers

Tweepy - Exclude Retweets

Ultimate goal is to use the tweepy api search to focus on topics (i.e docker) and to EXCLUDE retweets. I have looked at other threads that mention excluding retweets but they were completely applicable. I have tried to incorporate what I've learned…
hansolo
  • 903
  • 4
  • 12
  • 28
20
votes
3 answers

User ID to Username tweepy

Can someone please tell me how to get one username from one id on tweepy? I have looked everywhere and can't find anything.
Amr El Aswar
  • 3,395
  • 3
  • 23
  • 36
20
votes
2 answers

How can I consume tweets from Twitter's streaming api and store them in mongodb

I need to develop an app that lets me track tweets and save them in a mongodb for a research project (as you might gather, I am a noob, so please bear with me). I have found this piece of code that sends tweets streaming through my terminal…
user2161725
  • 667
  • 2
  • 7
  • 12
19
votes
6 answers

How to acess tweets with bearer token using tweepy, in python?

When I signed up for the Twitter API for research , they gave me 3 keys: API Key, API Secret Key, and Bearer Token. However the Hello Tweepy example, 4 keys are used: consumer_key, consumer_secret, access_token, access_token_secret. Obviously, the…
19
votes
1 answer

Getting whole user timeline of a Twitter user

I want to get the all of a user tweets from one Twitter user and so far this is what I came up with: import twitter import json import sys import tweepy from tweepy.auth import OAuthHandler CONSUMER_KEY = '' CONSUMER_SECRET=…
Vin23
  • 257
  • 1
  • 4
  • 9
19
votes
6 answers

Get the error code from tweepy exception instance

I'm new to python and I'm trying to use a library. It raises an exception, and I am trying to identify which one. This is what I am trying: except tweepy.TweepError as e: print e print type(e) print e.__dict__ print e.reason …
José D.
  • 4,175
  • 7
  • 28
  • 47
18
votes
3 answers

Heroku - No web process running

I made a twitter bot using tweepy in Python and tried deploying it using Heroku. The Bot just tweets after certain intervals. After deploying it, the Python program just doesn't run and Heroku log shows the following error : at=error code=H14…
arjun gulyani
  • 669
  • 2
  • 8
  • 23
18
votes
7 answers

401 Error when retrieving Twitter data using Tweepy

I am trying to retrieve Twitter data using Tweepy, using that below code, but I'm returning 401 error, and I regenerate the access and secret tokens, and the same error appeared. #imports from tweepy import Stream from tweepy import…
user3643380
  • 195
  • 1
  • 1
  • 11
18
votes
3 answers

Using Tweepy to listen to stream and search for tweets. How to stop previous search and only listen for new stream?

I'm using Flask and Tweepy to search for live tweets. On the front-end I have a user text input, and button called "Search". Ideally, when a user gives a search-term into the input and clicks the "Search" button, the Tweepy should listen for the new…
stthomas
  • 183
  • 1
  • 4
18
votes
3 answers

Tweepy: ImportError: cannot import name Random

I'm using Tweepy to send some messages to Twitter. I'm getting a long traceback from the API. The traceback settles at: ImportError: cannot import name Random I used Pip to install the latest version of Tweepy: Name: tweepy Version: 2.3.0 Location:…
Damian Romard
  • 663
  • 1
  • 5
  • 10
17
votes
3 answers

tweepy get tweets between two dates

I have the following code in Python: import tweepy consumer_key = "..." consumer_secret = "..." access_token = "..." access_token_secret = "..." auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token,…
Alessandro Russo
  • 173
  • 1
  • 1
  • 4
17
votes
5 answers

Getting tweet replies to a particular tweet from a particular user

I am trying to go through tweets of a particular user and get all replies on that tweet. I found that the APIv1.1 of twitter does not directly support it. Is there a hack or a workaround on getting the replies for a particular tweet. I am using…
Huga
  • 571
  • 1
  • 8
  • 21
17
votes
4 answers

how to properly close a tweepy stream

I'm trying to figure out how to properly close an asynchronous tweepy stream. The tweepy streaming module can be found here. I start the stream like this: stream = Stream(auth, listener) stream.filter(track=['keyword'], async=True) When closing the…
Wilco
  • 928
  • 3
  • 9
  • 20