Wednesday, October 8, 2025
HomeLanguagesPython – API.get_saved_search() in Tweepy

Python – API.get_saved_search() in Tweepy

Twitter is a popular social network where users share messages called tweets. Twitter allows us to mine the data of any user using Twitter API or Tweepy. The data will be tweets extracted from the user. The first thing to do is get the consumer key, consumer secret, access key and access secret from twitter developer available easily for each user. These keys will help the API for authentication.

API.get_saved_search()

The get_saved_search() method of the API class in Tweepy module is used to get a particular saved search.

Syntax : API.get_saved_search(id)

Parameter :

  • id : the ID of the saved search.

Returns : an object of class SavedSearch

Example 1 : Accessing a saved search and printing its query.




# import the module
import tweepy
  
# assign the values accordingly
consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""
  
# authorization of consumer key and consumer secret
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
  
# set access to user's access key and access secret 
auth.set_access_token(access_token, access_token_secret)
  
# calling the api 
api = tweepy.API(auth)
  
# ID of the saved search
id = 1269503225993900032
  
# fetching the saved search
saved_search = api.get_saved_search(id)
  
# printing the information
print("The ID of the saved search is : " + str(saved_search.id))
print("The query of this saved search is : " + saved_search.query)


Output :

The ID of this saved search is : 1269503225993900032
The query of this saved search is : computer

Example 2 : Print the time of the saved search.




# ID of the saved search
id = 1269503225993900032
  
# fetching the saved search
saved_search = api.get_saved_search(id)
  
# printing the information
print("The saved search " + str(saved_search.id) +
      " was created on : " + str(saved_search.created_at))


Output :

The saved search 1269503225993900032 was created on : 2020-06-07 05:35:29
Last Updated :
10 Jun, 2020
Like Article
Save Article

<!–

–>

Similar Reads
Related Tutorials
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32342 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6712 POSTS0 COMMENTS
Nicole Veronica
11875 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11937 POSTS0 COMMENTS
Shaida Kate Naidoo
6833 POSTS0 COMMENTS
Ted Musemwa
7092 POSTS0 COMMENTS
Thapelo Manthata
6786 POSTS0 COMMENTS
Umr Jansen
6789 POSTS0 COMMENTS