Skip to content

Cookbook

Real-world recipes for X/Twitter success. These aren't tutorialsβ€”they're battle-tested workflows.

  • Growth Hacking


    Proven strategies to grow your following fast

    Growth Recipes

  • Automation Workflows


    Set-and-forget automation scripts

    Automation

  • Data Science


    Advanced analytics and ML applications

    Data Science

  • Business Intelligence


    Competitive intelligence and lead gen

    Business

  • Research


    Academic and journalism applications

    Research

Quick Wins

Copy-paste scripts for immediate results:

🧹 Clean Your Following (5 minutes)

import asyncio
from xeepy import Xeepy

async def quick_cleanup():
    async with Xeepy() as x:
        result = await x.unfollow.non_followers(
            max_unfollows=50,
            min_following_days=7,
            exclude_verified=True,
            dry_run=False
        )
        print(f"βœ… Unfollowed {result.success_count} non-followers")

asyncio.run(quick_cleanup())

πŸ“ˆ Daily Growth Script

import asyncio
from xeepy import Xeepy

async def daily_growth():
    async with Xeepy() as x:
        # Follow 50 users in your niche
        await x.follow.by_keyword(
            ["your", "niche", "keywords"],
            max_follows=50
        )

        # Like 30 tweets
        await x.engage.auto_like(
            keywords=["your niche"],
            max_likes=30
        )

        # Check stats
        me = await x.scrape.profile("me")
        print(f"Followers: {me.followers_count} | Following: {me.following_count}")

asyncio.run(daily_growth())

πŸ” Competitor Analysis

import asyncio
from xeepy import Xeepy

async def analyze_competitor(username: str):
    async with Xeepy() as x:
        profile = await x.scrape.profile(username)
        tweets = await x.scrape.tweets(username, limit=100)

        # Calculate engagement rate
        total_engagement = sum(t.likes + t.retweets for t in tweets)
        avg_engagement = total_engagement / len(tweets)
        engagement_rate = (avg_engagement / profile.followers_count) * 100

        print(f"@{username} Analysis:")
        print(f"  Followers: {profile.followers_count:,}")
        print(f"  Avg Engagement: {avg_engagement:.0f}")
        print(f"  Engagement Rate: {engagement_rate:.2f}%")

        # Top performing content
        top_tweets = sorted(tweets, key=lambda t: t.likes, reverse=True)[:5]
        print(f"\nTop Tweets:")
        for t in top_tweets:
            print(f"  - {t.text[:60]}... ({t.likes} likes)")

asyncio.run(analyze_competitor("competitor_username"))

🎯 The Ghost Follower Detector

Find and remove followers who never engage:

import asyncio
from xeepy import Xeepy
from collections import defaultdict

async def detect_ghost_followers():
    """Find followers who never engage with your content"""

    async with Xeepy() as x:
        # Get your recent tweets
        my_tweets = await x.scrape.tweets("me", limit=50)

        # Get all engagers
        engager_counts = defaultdict(int)

        for tweet in my_tweets:
            likers = await x.scrape.likers(tweet.url, limit=100)
            for user in likers:
                engager_counts[user.username] += 1

        # Get your followers
        followers = await x.scrape.followers("me", limit=1000)
        follower_usernames = {f.username for f in followers}

        # Find ghosts (followers who never engage)
        engagers = set(engager_counts.keys())
        ghosts = follower_usernames - engagers

        print(f"πŸ“Š Ghost Follower Analysis")
        print(f"   Total followers: {len(follower_usernames)}")
        print(f"   Active engagers: {len(engagers & follower_usernames)}")
        print(f"   Ghost followers: {len(ghosts)} ({len(ghosts)/len(follower_usernames)*100:.1f}%)")

        return list(ghosts)

asyncio.run(detect_ghost_followers())

πŸŒ™ The Sleep Schedule Optimizer

Post when your audience is most active:

import asyncio
from xeepy import Xeepy
from collections import Counter
from datetime import datetime

async def find_optimal_post_times():
    """Analyze when your audience engages most"""

    async with Xeepy() as x:
        # Get your followers' recent activity
        followers = await x.scrape.followers("me", limit=200)

        activity_hours = Counter()

        for follower in followers[:50]:  # Sample 50 followers
            tweets = await x.scrape.tweets(follower.username, limit=20)

            for tweet in tweets:
                hour = tweet.created_at.hour
                activity_hours[hour] += 1

        # Find peak hours
        total = sum(activity_hours.values())
        print("πŸ“Š Audience Activity by Hour (your timezone)")
        print("="*50)

        for hour in range(24):
            count = activity_hours.get(hour, 0)
            pct = (count / total * 100) if total > 0 else 0
            bar = "β–ˆ" * int(pct / 2)
            time_str = f"{hour:02d}:00"
            print(f"{time_str} | {bar} {pct:.1f}%")

        # Top 3 hours
        top_hours = activity_hours.most_common(3)
        print(f"\n🎯 Best times to post: {', '.join(f'{h}:00' for h, _ in top_hours)}")

asyncio.run(find_optimal_post_times())

Advanced Patterns

These recipes combine multiple Xeepy features: