The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Archive tweets by keyword

To archive tweets by keyword, follow these steps using one of the common methods available:


Method 1: Using Tweepy (Python + Twitter API v2)

  1. Set up your Twitter Developer Account

  2. Install Tweepy

    bash
    pip install tweepy
  3. Python Script to Archive Tweets by Keyword

    python
    import tweepy import csv # Replace with your own credentials bearer_token = 'YOUR_TWITTER_BEARER_TOKEN' client = tweepy.Client(bearer_token=bearer_token) keyword = 'AI technology' max_results = 100 # up to 100 per request tweet_limit = 500 # total tweets to archive tweets_data = [] next_token = None while len(tweets_data) < tweet_limit: response = client.search_recent_tweets( query=keyword, tweet_fields=['created_at', 'text', 'author_id'], max_results=max_results, next_token=next_token ) if not response.data: break tweets_data.extend(response.data) next_token = response.meta.get('next_token') if not next_token: break # Save to CSV with open('archived_tweets.csv', 'w', newline='', encoding='utf-8') as file: writer = csv.writer(file) writer.writerow(['Tweet ID', 'Author ID', 'Created At', 'Text']) for tweet in tweets_data: writer.writerow([tweet.id, tweet.author_id, tweet.created_at, tweet.text])

Method 2: Using Tools like Zapier + Google Sheets

  1. Set up a Zapier account

  2. Create a new Zap:

    • Trigger: Twitter → “Search Mention” (by keyword)

    • Action: Google Sheets → “Create Spreadsheet Row”

  3. Result:

    • Tweets matching your keyword are automatically archived in a Google Sheet.


Method 3: Use Advanced Twitter Search + Manual Export

  1. Go to Twitter Advanced Search

  2. Enter your keyword and filter by date.

  3. Use browser extensions (like “Twitter Archiver” on Google Sheets or “TAGS”) to export the data.


Notes:

  • Twitter API v2 allows access to 7 days of historical tweets in the free tier.

  • For older tweets, you need Twitter Academic Access or a premium plan.

  • Always respect Twitter’s API usage limits and data policies when archiving tweets.

If you’d like, I can tailor a script or automation setup based on your needs or environment (e.g., local, cloud, automation frequency).

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About