python-twitter
Basics
  • Standard API, free, recent Tweets published in the past 7 days
  • Premium API, pay as you go, advanced filtering functionality and scalable access to the the Search Tweets API, free and paid, access to either the last 30 days of Tweets or access to Tweets from as early as 2006
  • Enterprise-level, paid subscription, access to Twitter data, including real-time Tweets and public account information, historical Tweets, and Tweet insights, access to either the last 30 days of Tweets or access to Tweets from as early as 2006
  • Authentication
  • Twitter Account
    1. Create App
    2. Setup one or more development environment
      • Search Tweets: 30-DaysSandbox
      • Search Tweets: Full ArchiveSandbox
      • Account Activity APISandbox
    3. Start using the endpoints
    Create API
    import twitter
    from t import ACCESS_TOKEN_KEY, ACCESS_TOKEN_SECRET, CONSUMER_KEY, CONSUMER_SECRET
    
    api = twitter.Api(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN_KEY, ACCESS_TOKEN_SECRET)
    		
    GetUser()
  • Returns a single user
  • user = api.GetUser(screen_name="@valdostastate")
    		
    GetSearch()
  • Return twitter search results for a given term
  • searches = api.GetSearch(term='valdosta state', count= 100)
    
    searches = api.GetSearch(raw_query="q=valdosta%20state&result_type=recent&since=2014-07-19&count=100")
    
    searches = api.GetSearch(term='valdosta', since_id = 1193364932055711745)
    
    searches = api.GetSearch(term='valdosta', max_id = 1193364932055711745)
    
    searches = api.GetSearch(term='valdosta state', until='2019-11-09') #YYYY-MM-DD
    
    searches = api.GetSearch(term='FSU', geocode = [30.4433237, -84.2777568, "1mi"], result_type="recent", count=100)
    		
    GetUserTimeline
  • Fetch the sequence of public Status messages for a single user
  • searches = api.GetUserTimeline(screen_name="@valdostastate", count = 100)
    		
    GetFriends()
    #user_id, twitter id
    #screen_name, twitter name
    users = api.GetFriends() #fetch the follower
    
    user = users[0]
    print(user)
    		
    Reference
  • Search Tweets
  • API Reference Index
  • Twitter Search
  • python-twitter API
  • Twitter Tutorials
  • python-twitter examples