Skip to content

ajitg25/twitter-analytics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

56 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐦 Twitter Archive Analytics

A powerful analytics tool to extract insights from your Twitter/X data archive. This tool helps you understand your follower relationships, tweet patterns, engagement metrics, and much more!

✨ Features

πŸ“Š Key Insights

  • Follower Management:
    • Identify accounts you follow that don't follow you back
    • Find "fans" (followers you don't follow back)
    • New: Fetch real-time usernames and display names via Twitter API
    • New: Export lists to CSV or copy profile URLs
  • Content Analysis:
    • Breakdown of Posts vs Replies
    • Engagement trends over time
    • Top performing hashtags
  • Engagement Metrics: Calculate your engagement rate and social reach

πŸ“ˆ Visualizations

  • Account Overview: Track Likes, Retweets, and Engagement over time (filterable by date: 7D, 2W, 3M, 1Y, All)
  • Posts vs Replies: Compare your original content vs interactions (filterable by date)
  • Follower Relationships: Interactive charts for mutual vs one-sided connections
  • Activity Heatmap: Visualize your posting habits by day and hour
  • Top Hashtags: Bar chart of your most used tags

πŸ’‘ Smart Recommendations

  • Content strategy suggestions based on your data
  • Follower growth opportunities
  • Engagement optimization tips
  • Connection management insights

πŸš€ Getting Started

Prerequisites

  • Python 3.8 or higher
  • Your Twitter/X data archive (Download from Twitter Settings > Your Account > Download an archive)

Installation

  1. Clone or download this repository

  2. Install dependencies:

pip install -r requirements.txt

Usage

Option 1: Command Line Analyzer

Simple text-based analysis tool:

python analyzer.py

Enter the path to your Twitter archive folder when prompted.

Option 2: Interactive Dashboard (Recommended)

Beautiful web-based dashboard with charts and visualizations:

streamlit run main.py

This will open a browser window with your interactive analytics dashboard.

πŸ“‚ What Data is Analyzed?

Your Twitter archive contains:

  • βœ… Followers: List of accounts following you
  • βœ… Following: List of accounts you follow
  • βœ… Tweets: All your tweets with metadata
  • βœ… Likes: Tweets you've liked
  • βœ… Direct Messages: Your DM history
  • βœ… Account Info: Profile and account details
  • βœ… Engagement Data: Retweets, replies, mentions

πŸ“Š Sample Insights

The tool provides insights like:

  • "You follow 52 accounts but only 5 follow you back" - Helps identify one-sided relationships
  • "Your most active hour is 3:00 PM" - Optimal posting times
  • "90% of your tweets are replies" - Content mix analysis
  • "#AI is your most used hashtag" - Topic analysis

🎯 Use Cases

  1. Personal Brand Optimization: Understand your Twitter presence and optimize your content strategy
  2. Audience Analysis: Learn who engages with your content
  3. Connection Management: Identify valuable connections vs one-sided follows
  4. Content Planning: Discover best times to post and trending topics
  5. Archive Exploration: Dive deep into your Twitter history

πŸ”’ Privacy & Security

  • All analysis is done locally on your machine
  • No data is sent to external servers
  • Your Twitter archive remains private
  • No API keys or authentication required (except optional public profile fetching)

πŸ› οΈ Technical Details

Built With

  • Python: Core analytics engine
  • Streamlit: Interactive web dashboard
  • Plotly: Beautiful interactive charts
  • Pandas: Data manipulation and analysis

Architecture

twitter-analytics/
β”œβ”€β”€ analyzer.py          # CLI-based analyzer
β”œβ”€β”€ main.py              # Web-based dashboard
β”œβ”€β”€ twitter_utils.py     # Core processing logic
β”œβ”€β”€ requirements.txt     # Python dependencies
β”œβ”€β”€ README.md           # Documentation
└── twitter-YYYY-MM-DD-*/  # Your Twitter archive
    └── data/
        β”œβ”€β”€ follower.js
        β”œβ”€β”€ following.js
        β”œβ”€β”€ tweets.js
        β”œβ”€β”€ likes.js
        └── ...

πŸ“– How to Download Your Twitter Archive

  1. Log in to Twitter/X
  2. Go to Settings and Privacy > Your Account > Download an archive of your data
  3. Confirm your password
  4. Wait for Twitter to prepare your archive (can take 24-48 hours)
  5. Download the ZIP file and extract it
  6. Use the extracted folder path with this tool

Note: The dashboard includes a built-in step-by-step guide with images and a video tutorial!

🎨 Dashboard Features

Interactive Elements

  • Quick Actions: Buttons to instantly view non-followers or fans
  • Smart Filters: Filter charts by time range (7 days to All time)
  • Metric Toggles: Switch between Likes, Retweets, and Engagement views
  • CSV Exports: Download lists of users for external management

Visualizations

  1. Account Overview: Comprehensive line chart of your growth and engagement
  2. Posts vs Replies: Donut chart showing your content distribution
  3. Activity Heatmap: Best posting times visualization
  4. Hashtag Bar Chart: Your most used topics
  5. Follower Stats: Detailed breakdown of your network

🀝 Contributing

Ideas for improvements:

  • Network graph visualization of connections
  • Sentiment analysis of tweets
  • Tweet engagement prediction
  • Export reports to PDF
  • Compare multiple archives over time
  • Integration with Twitter API for live data

πŸ“ Example Output

============================================================
πŸ‘€ ACCOUNT OVERVIEW
============================================================

πŸ“ Account Details:
   Username: @YourUsername
   Display Name: Your Name
   Account ID: 949939849796243456
   Created: 2018-01-07

============================================================
πŸ‘₯ FOLLOWER & FOLLOWING INSIGHTS
============================================================

πŸ“Š Basic Stats:
   Followers: 5
   Following: 52
   Follower/Following Ratio: 0.10

🀝 Mutual Connections:
   Mutual follows (friends): 2
   Followers you don't follow back: 3
   Following who don't follow back: 50
   
   Engagement rate: 3.8% of people you follow also follow you back

πŸ› Troubleshooting

"Path does not exist" error

  • Make sure you've extracted the Twitter archive ZIP file
  • Use the full path to the extracted folder
  • Check that the folder contains a data subfolder

"No data found" error

  • Verify your archive is complete
  • Check that .js files exist in the data folder
  • Try downloading a fresh archive from Twitter

Charts not displaying

  • Ensure all dependencies are installed: pip install -r requirements.txt
  • Try updating Streamlit: pip install --upgrade streamlit

πŸ“„ License

This project is open source and available for personal use.

πŸ™ Acknowledgments

  • Twitter/X for providing data export functionality
  • Streamlit for the amazing dashboard framework
  • The open-source community for inspiration

Made with ❀️ for Twitter data enthusiasts

Note: This tool is not affiliated with Twitter/X. It's an independent project for personal data analysis.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

  •  

Packages

No packages published