Back to Blog

How to Detect Spam or Bots on Twitter (And What to Do With That Data)

Thomas ShultzThomas Shultz
11 min read
113 views
How to Detect Spam or Bots on Twitter

Most engagement metrics on Twitter are lying to you at least a little. Somewhere between 5% and 20% of active accounts on the platform are automated — and the actual number is genuinely contested, because Twitter's own official figure (5%) and independent researcher estimates (as high as 20%+) have never agreed. What's not contested: bots inflate follower counts, distort engagement rates, skew keyword monitoring results, and spread misinformation faster than human-generated content.

If you're collecting Twitter data — for brand monitoring, research, lead scoring, or analysis — understanding how to identify bot accounts in your dataset matters. This guide covers the practical signals, the tools, and the programmatic approaches that actually work, along with an honest assessment of where detection breaks down.

Why Bot Detection Is Hard (And Getting Harder)

The naive assumption is that bots are obvious. In practice, unsophisticated bots are obvious. The ones that matter — the coordinated accounts pushing specific narratives, the follower-inflation operations, the engagement-manipulation networks — are specifically engineered to look human.

Research from academic institutions studying Twitter bot behavior has consistently found a systemic accuracy problem: machine learning models trained on one dataset often perform only marginally better than random guessing when deployed on a different dataset. A model trained on COVID-19 hashtag data doesn't generalize well to crypto scam bots, which don't generalize to election-manipulation bots. The training data is almost always context-specific and hand-labeled, which creates hidden brittleness.

There's also a simple model paradox buried in this research: a rule as crude as "has the account ever liked a tweet?" achieved accuracy comparable to complex ML systems on the same datasets. That's not a point in favor of simple rules — it's a sign that the datasets themselves lack real-world complexity.

The practical implication: no single detection method is reliable in isolation. Bot detection works best as a layered approach — multiple weak signals combined into a judgment.

The Signals That Actually Matter

Profile-Level Red Flags

Start with what's immediately visible. These signals are weak individually but compound quickly:

  • Username patterns — Random strings of numbers appended to a name (@JohnSmith_48291) are common, but not definitive. Bots often use auto-generated handles.

  • Profile photo — Default avatars or clearly AI-generated faces. Reverse image search helps; if the profile photo appears in dozens of other contexts, it's likely stolen.

  • Bio quality — Empty bios, keyword-stuffed bios, or bios with URLs to unrelated sites.

  • Creation date vs. activity — An account created four years ago with eleven total tweets is suspicious. So is an account created last week with three thousand tweets.

  • Location data — Accounts claiming locations that don't match their language or posting time zones.

Behavioral Red Flags

Profile data is static. Behavior tells you more:

  • Posting velocity — More than 50 tweets per day is suspicious. More than 144 tweets per day is highly questionable for a human operator. That's a tweet every ten minutes, continuously.

  • Content uniformity — Accounts that only retweet, only share links, or consistently post word-for-word copies of article headlines without original commentary.

  • Engagement mismatch — An account with 76 followers getting 23,000 interactions on a single post. The inverse — accounts that post constantly but receive near-zero engagement — is equally telling.

  • Like/retweet symmetry — When a post has nearly identical like and retweet counts (e.g., liked 100 times, retweeted 105 times), it suggests coordinated automated behavior rather than organic spread.

  • Temporal clustering — Bots often post in machine-regular intervals. Human posting patterns are irregular.

  • Follow/follower ratio — Following 5,000 accounts while having 80 followers is the classic signal. Legitimate accounts accumulate followers over time through actual engagement.

Network-Level Red Flags

Individual account signals miss coordinated behavior. Network analysis is where modern detection has improved most:

  • Accounts that exclusively retweet each other in tight clusters

  • Groups of accounts that all posted the same content within minutes of each other

  • Accounts that followed each other simultaneously around the same date

  • Shared hashtag usage patterns that suggest coordinated amplification rather than organic discovery

Research has specifically incorporated retweet networks, co-retweet patterns, and co-hashtag graphs into detection methods, because these higher-order relations reveal coordination that individual account analysis misses entirely.

Manual vs. Programmatic Detection

Manual Inspection (Good for Spot Checks)

If you're auditing a specific account's followers or investigating whether a particular account seems legitimate, manual inspection works fine at small scale. The practical heuristic: sample 20–50 random followers from an account. If more than 20% show multiple bot signals, the follower base is likely significantly contaminated.

Twitter's native tools are limited here. You can block, mute, and report — but the platform doesn't surface bot scores or give you audit tooling.

Third-Party Detection Tools

Several established tools exist for account-level analysis:

Tool

What It Does

Cost

Botometer

ML-based bot score (0–1 scale) for any account

Free

Bot Sentinel

Browser extension + dashboard, labels suspicious accounts

Free

Circleboom

Bulk detection across followers/following

Free + paid plans from $44.99/month

TwitterAudit

Follower quality score, fake follower estimate

Free tier available

Hoaxy

Bot detection + misinformation tracking

Free

The limitation applies equally to all of these: they work well on known bot patterns and less well on novel or sophisticated operations. Treat the outputs as probabilistic signals, not verdicts.

Programmatic Detection in Your Pipeline

If you're running a keyword monitoring pipeline, a follower analysis job, or building a dataset for ML, you want to flag likely bots during data collection rather than after. This is where programmatic approaches pay off.

The pattern: collect tweet or follower data, then score each account against a set of heuristics. Flag accounts above a threshold for exclusion or review.

A basic heuristic scoring approach in Python:

def bot_score(user: dict) -> int:
    """
    Returns a simple heuristic bot score (0–100).
    Higher = more likely to be a bot. Not a substitute for ML-based detection.
    """
    score = 0

    followers = user.get("followers_count") or 0
    following = user.get("friends_count") or 0
    tweet_count = user.get("statuses_count") or 0
    has_photo = not user.get("default_profile_image", True)
    has_bio = bool(user.get("description", "").strip())
    username = user.get("screen_name", "")

    # Follow/follower ratio signal
    if following > 0 and followers / following < 0.05:
        score += 30  # Following many, followed by few

    # Posting velocity (total tweets relative to account age in days)
    created_at = user.get("created_at")
    if created_at:
        from datetime import datetime, timezone
        try:
            created = datetime.strptime(created_at, "%a %b %d %H:%M:%S +0000 %Y")
            created = created.replace(tzinfo=timezone.utc)
            age_days = max((datetime.now(timezone.utc) - created).days, 1)
            tweets_per_day = tweet_count / age_days
            if tweets_per_day > 50:
                score += 20
            if tweets_per_day > 144:
                score += 20
        except (ValueError, TypeError):
            pass

    # Profile completeness signals
    if not has_photo:
        score += 15
    if not has_bio:
        score += 10

    # Username pattern (trailing digits)
    import re
    if re.search(r'\d{4,}$', username):
        score += 5

    return min(score, 100)

This is a starting point, not a production bot detector. The scoring weights should be tuned to your specific use case. A political research dataset has different noise characteristics than a brand monitoring pipeline.

In practice, most teams use a threshold approach: accounts scoring above a defined cutoff get flagged for exclusion. The right threshold depends on your tolerance for false positives vs. false negatives. A research dataset might use a conservative threshold and manually review borderline cases. A keyword monitoring pipeline might simply drop high-scoring accounts to keep signal quality high.

Integrating Bot Detection Into a Data Collection Pipeline

If you're collecting Twitter data at scale using an API like ScrapeBadger, you can run bot scoring inline as part of normalization, before records hit your database.

The pattern fits naturally into the kind of pipeline described in how to build a Twitter monitoring bot with Python:

async def process_tweet(tweet: dict, bot_threshold: int = 60) -> dict | None:
    """
    Normalize a tweet and flag or drop likely bot accounts.
    Returns None if the tweet author exceeds the bot score threshold.
    """
    user = tweet.get("user") or {}
    score = bot_score(user)

    if score >= bot_threshold:
        return None  # Drop the tweet from the pipeline

    metrics = tweet.get("public_metrics") or {}
    return {
        "tweet_id": str(tweet.get("id") or ""),
        "username": str(user.get("screen_name") or ""),
        "text": str(tweet.get("text") or ""),
        "created_at": str(tweet.get("created_at") or ""),
        "like_count": int(metrics.get("like_count") or 0),
        "retweet_count": int(metrics.get("retweet_count") or 0),
        "bot_score": score,  # Store for later auditing
    }

One useful practice: don't discard high-scoring accounts immediately. Store them in a separate flagged table with their bot scores. Periodically audit what you're filtering — both to catch false positives and to understand what types of bots are showing up in your specific data context.

What Detection Can and Can't Tell You

Honest assessment of where this breaks down:

Detection works well for: - Obvious low-effort bots (no photo, no bio, extreme posting velocity, bad follow ratios) - Follower audit cleanup — removing clearly fake accounts from your own follower set - Pre-filtering keyword monitoring results before analysis - Flagging accounts for manual review

Detection breaks down for: - Sophisticated coordinated operations that maintain human-like posting patterns - Accounts that are legitimate humans behaving in bot-like ways (very active posters, heavy retweeters) - Novel bot types that don't match patterns in any training dataset - Any context where false positive rate matters (don't auto-block based on heuristic scores)

The rule that applies to most data pipelines: bot detection is a filter, not a classifier. Use it to improve signal quality, not to make authoritative judgments about specific accounts.

Reducing Noise in Practice

A few decisions that make more practical difference than the scoring algorithm:

Exclude retweets by default. Add -is:retweet to your search queries or filter them in normalization. Retweets are the primary amplification mechanism for bot networks, and they rarely contain original signal.

Set engagement floors. For most brand monitoring or trend analysis work, tweets with zero likes and zero retweets from accounts with no followers aren't worth processing. An engagement floor of 2–3 likes cuts a lot of noise without meaningful data loss.

Language filtering. If your use case is English-language, lang:en can cut volume by 40–60% depending on the keyword — and almost all of that cut comes from low-quality accounts with international or multilingual posting patterns.

Run periodic baseline audits. Sample 50–100 records from your collected dataset monthly and manually inspect them. Bot tactics evolve. Your heuristics should too.

FAQ

What percentage of Twitter accounts are bots? Estimates vary widely. Twitter's official figure is around 5% of monetizable daily active users. Independent researchers have put the number between 9% and 20%+, depending on methodology. The honest answer is: nobody knows precisely, because Twitter hasn't shared the data needed to verify any estimate independently.

Is Botometer still reliable? Botometer is a useful starting point, but it has known accuracy limitations — particularly when applied outside the contexts on which its models were trained. It's best used as one signal among several rather than a definitive verdict. Check whether it's still actively maintained before building a pipeline dependency on it.

Can you detect bots programmatically without a dedicated ML model? Yes, heuristic scoring on account features (follow ratio, posting velocity, profile completeness, username patterns) catches a meaningful portion of low-effort bots with no ML required. The tradeoff is that sophisticated bots specifically engineer around these signals. Heuristics work well for data quality improvement; they're not adequate for adversarial research contexts.

Should I automatically block accounts that score high on bot detection? No. Use detection to flag accounts for review or to filter them from analysis, not to make automatic blocking decisions. False positive rates on heuristic detection are high enough that auto-blocking will catch legitimate accounts. If you're cleaning your own follower list, manual review of flagged accounts is worth the time.

How does bot detection affect keyword monitoring pipelines? Primarily through data quality. A keyword monitoring pipeline that doesn't filter bots will over-count mentions, inflate engagement metrics, and surface noise that looks like signal. The practical fix is filtering obvious bots during normalization and excluding retweets. If you need accurate reach or sentiment data, bot filtering is not optional — it's the difference between a number that reflects reality and one that doesn't. For more on building reliable keyword pipelines, see how to monitor Twitter keywords automatically.

What's the difference between a spam account and a bot account? In practice, most spam accounts are automated (i.e., bots), but not all bots are spam. Some bots serve legitimate purposes — automated news feeds, earthquake alert accounts, space photo bots — and are transparent about being automated. The distinction matters when building detection systems: you want to filter malicious automation and coordinated inauthenticity, not legitimate automated accounts.

Do bot detection scores change over time? They should. Bot operators adapt to detection methods, and new bot types emerge regularly. A bot scoring approach that works well today may be systematically bypassed in twelve months. Periodic audits of your detection results and occasional recalibration of scoring weights are both worth building into your maintenance process.

Thomas Shultz

Written by

Thomas Shultz

Thomas Shultz is the Head of Data at ScrapeBadger, working on public web data, scraping infrastructure, and data reliability. He writes about real-world scraping, data pipelines, and turning unstructured web data into usable signals.

Ready to get started?

Join thousands of developers using ScrapeBadger for their data needs.

Detecting Twitter Bots: Signals, Tools & Methods | ScrapeBadger