Twitter (X) Fake News Detection: Datasets, Features and Code

By TwitterAPI.io Team•15 min read
Diagram of a Twitter (X) fake news detection pipeline. Four boxes feed a classifier score: 1 Content (claim text, TF-IDF or transformer, claim matching against fact-checks, LIAR with 12.8K PolitiFact statements), 2 Source (link domains bucketed as own site, news, social or video, shortener; author age, followers, blue check), 3 Propagation (reply per retweet and quote per retweet ratios, /twitter/tweet/quotes and /twitter/tweet/retweeters), 4 Crowd labels (Community Notes public TSVs joined by tweetId and classification). The score from 0 to 1 sends posts above a threshold to a human review queue. Footer: 87.9% of news-organization posts carry a link vs 4.3% in a fake news keyword search, where 78.0% are replies, collected in 2026.
The four signal families behind Twitter (X) fake news detection, and where the decision stays: with a human reviewer. Diagram; footer numbers from the study below.
TL;DR
  • Four signal families: claim text, source (link domains, author age), propagation (reply, quote and retweet ratios) and crowd labels (Community Notes). Text-only models are the weakest of the four on their own.
  • Datasets, verified: LIAR has 12.8K PolitiFact statements (10,269 train / 1,284 validation / 1,283 test, six labels); FakeNewsNet ships PolitiFact and GossipCop articles with tweet_ids only, so you hydrate the posts yourself; Community Notes publishes notes, ratings and status history as daily TSVs.
  • Text alone is weak: the LIAR paper's best text-only CNN scores 27.0% six-class test accuracy against a 20.8% majority baseline; adding speaker metadata reaches 27.4%.
  • Our study, 1,232 posts collected in 2026: 87.9% of posts from 6 news organizations and 92.1% from 4 fact-check accounts carry a link; a 'fake news' / 'misinformation' keyword search: 4.3% links, 78.0% replies.
  • Propagation baseline: on news-organization posts with 10+ retweets the median is 0.776 replies and 0.157 quotes per retweet. A post far above that is a candidate for review, not proof of anything.
  • Cost: the API returns no Community Notes field, so join notes by post ID. Reads are $0.15 per 1,000 posts on twitterapi.io vs $0.005 per post read on the official X API, about 33x less; see /pricing.

This guide is about detecting misinformation in X (Twitter) content: the datasets researchers train on, the features that carry signal, and code that collects public posts and turns them into a feature table. It is not about automated accounts; scoring whether an account is a bot is a different problem, covered in our guide to Twitter bots. And it is not a guide to writing or rating Community Notes, which our Community Notes explainer covers; here the notes are one input among four.

A word on framing before any code. No model can tell you whether a claim is true. What a model can do is rank posts by how closely they resemble content that human fact-checkers have previously rated false or misleading, so that limited human attention goes to the riskiest posts first. Everything on this page, including our study, reports scores and aggregate signals. We do not label any post or account as fake.

The unique part is the study: we pulled 1,232 public posts in 2026 with 64 API requests, from 6 news organizations, 4 fact-check accounts, two keyword searches ('fake news' and 'misinformation') and the quotes of 3 widely quoted news posts, and measured the features detection papers use. The point is the baselines: a feature only means something relative to what normal looks like, and normal differs sharply by source.

Posts with an external link: news organizations vs a 'fake news' keyword search

87.9% vs 4.3% (1,232 public posts, collected in 2026). In the keyword sample 78.0% of posts were replies, so detection has to score the parent post, not the reply.

01 — Section

How Twitter (X) fake news detection works: four signal families

Research on fake news detection on social media, from the FakeNewsNet papers by Shu and colleagues onward, splits the evidence into news content and social context. In practice that becomes four families of features, and a production pipeline uses all four because each fails in its own way.

1. Content. The text of the claim, encoded with TF-IDF or a transformer, fed to a classifier trained on statements that fact-checkers have rated. A stronger variant is claim matching: embed the post, find the nearest already fact-checked claim, and surface that fact-check. Claim matching never decides truth itself; it retrieves a human verdict that already exists.

2. Source. Where the post points and who posted it: the domains of linked URLs (the publisher's own site, another outlet, a video platform, a link shortener), the author's account age, follower count and verification. Source features are cheap and strong, and they are also the easiest to misuse: a new account or an unfamiliar domain is a reason to look, never a finding.

3. Propagation. How a post spreads: the ratio of replies and quotes to retweets, the speed of early retweets, and the shape of the retweet and quote graph. Studies of rumor cascades use this family because it does not depend on language. On twitterapi.io the raw material is /twitter/tweet/quotes (quote posts of one post), /twitter/tweet/retweeters (accounts that reposted it) and /twitter/tweet/replies; conversation trees can be rebuilt with an advanced_search query of conversation_id:<id>. Our Twitter network analysis guide shows how to turn those edges into a graph.

4. Crowd labels. On X, Community Notes is a public, continuously updated set of human annotations. Each note carries the tweetId it is about and a classification of MISINFORMED_OR_POTENTIALLY_MISLEADING or NOT_MISLEADING, and the status history says whether raters found it CURRENTLY_RATED_HELPFUL. That makes it both a feature and a source of weak labels for training.

Signal familyExample featuresWhere the data comes fromTypical failure
ContentTF-IDF or embedding of the claim; similarity to fact-checked claimsthe post text; LIAR, FakeNewsNetsatire, sarcasm, new claims no fact-check has seen
Sourcelink domain bucket, author age, followers, isBlueVerifiedentities.urls, author objectpenalizes new but honest accounts and small outlets
Propagationreply/retweet, quote/retweet, early retweet speedreplyCount, quoteCount, retweetCount, quotes and retweeters endpointscontroversy and misinformation look alike
Crowd labelshelpful note present, note classificationCommunity Notes TSVs joined on tweetIdcoverage is small and arrives after a post spreads
02 — Section

Fake news detection Twitter datasets: what each one actually contains

Nearly every tutorial and paper on this topic starts from one of a handful of public datasets. Here is what each one contains, checked on its primary source this session, and what you have to do before you can use it.

LIAR (Wang, ACL 2017). 12.8K short statements labeled by PolitiFact editors, primarily from 2007 to 2016, with six fine-grained labels: pants-fire, false, barely-true, half-true, mostly-true and true. Splits are 10,269 train, 1,284 validation and 1,283 test. Each statement carries metadata: subject, speaker, job, state, party, context, and a credit history of the speaker's past ratings. The statements are not tweets, so a model trained on LIAR is a claim-text model that you then apply to post text. Download: cs.ucsb.edu/~william/data/liar_dataset.zip (paper: aclanthology.org/P17-2067).

FakeNewsNet (Shu et al., 2018). News articles from PolitiFact and GossipCop, split into fake and real files (politifact_fake.csv, politifact_real.csv, gossipcop_fake.csv, gossipcop_real.csv), each row with id, url, title and tweet_ids. The repository states it cannot distribute the full data because of Twitter policies and publisher copyright, so you get post IDs, not posts, and the bundled crawler expects official Twitter API keys. Many of the IDs are years old; expect a share of deleted or protected posts when you hydrate them. Repository: github.com/KaiDMML/FakeNewsNet.

Community Notes data (X). Notes, ratings, note status history, user enrollment and note requests, as TSV files with a header row. Per the project's documentation, a new snapshot is published daily on a best-effort basis and includes notes and ratings created at least 48 hours before release. Notes link to posts by tweetId; status history joins on noteId. The scoring algorithm is open source under Apache-2.0 in the communitynotes repository of the twitter organization on GitHub; the download page is x.com/i/communitynotes/download-data.

Others you will meet. PHEME (rumor threads around breaking news events), Twitter15 and Twitter16 (propagation trees for rumor classification), and newer crowdsourced sets built on PolitiFact claims. We could not open their primary download pages this session, so we name them without figures; check each license before use.

DatasetUnitSize and labelsPost text included?Good for
LIARshort political statement12.8K, six labelsno (statements, not posts)content classifiers, speaker metadata
FakeNewsNetnews article + sharing postsPolitiFact and GossipCop, fake/realIDs only, hydrate yourselfcontent + social context
Community Notesnote on a postdaily TSVs, note classification + rating statusIDs only (tweetId)weak labels, evaluation, features
Your own collectionpublic postswhatever you labelyesdomain-specific baselines

Hydrating IDs is a plain lookup: send up to a page of comma-separated IDs to /twitter/tweets with tweet_ids, and you get back the full post objects with counts and author. Posts that were deleted simply do not come back, which is itself a signal worth recording. For a wider view of research collection, see our academic research API guide.

03 — Section

Step 1: collect posts and build a feature table

The full script is at the end of this page. It runs a keyword search (/twitter/tweet/advanced_search, queryType=Latest, following next_cursor while has_next_page is true), computes the features below for each post, and writes features.csv. It keeps tweet_id so you can join Community Notes later; if you publish results, drop the ID and the author fields.

Links. Read entities.urls[].expanded_url, not the t.co wrapper, and bucket the host: the publisher's own site, another news outlet, a fact-check site, social or video, a link shortener, other. Shorteners hide the destination; resolve them with a HEAD request if the bucket matters to your model.

Structure. isReply, whether quoted_tweet is present, and media from extendedEntities.media[].type (photo, video, animated_gif). Reposts arrive with a retweeted_tweet object and carry the original post's counts, so exclude them from ratio features or you will double count.

Ratios. replyCount / retweetCount and quoteCount / retweetCount, only on posts with at least 10 retweets, because ratios on tiny counts are noise. A high quote share is the classic 'ratio' pattern: people amplify a post to argue with it.

Author. Account age at posting time (createdAt of the post minus author.createdAt; both use the format Sat Dec 05 22:36:19 +0000 2026, not ISO 8601), author.followers, author.isBlueVerified. The author.isAutomated flag marks self-declared automated accounts; it was false for every author in our sample, so it is not a usable feature for this task.

One thing the response does not contain: any Community Notes field. Neither the timeline nor the search tweet objects in our collection carried a note, so crowd labels always come from the public TSVs, joined by post ID, as in the next step.

04 — Section

Step 2: join Community Notes labels by post ID

Download the notes file and the note status history from the Community Notes data page, then join. Two columns do the work: classification is the note writer's view of the post, and currentStatus from the status history says whether the community rated the note helpful. Only CURRENTLY_RATED_HELPFUL notes are shown on X, so those are the ones to use as labels; a note that NEEDS_MORE_RATINGS is an opinion, not a consensus.

Be careful with what a join tells you. A post with a helpful MISINFORMED_OR_POTENTIALLY_MISLEADING note means raters with different viewpoints agreed the note adds useful context. It does not mean every claim in the post is false, and a post without a note has usually just not been reviewed. Coverage is small relative to the volume of posts, so expect a heavily imbalanced label and evaluate with precision and recall at a threshold, not accuracy.

If the post you care about is a reply deep in a thread, rebuild the conversation first with an advanced_search query of conversation_id:<id>; notes attach to the specific post, not the thread.

python
# join_notes.py - attach public Community Notes labels to posts you collected.
# Download notes-00000.tsv from the Community Notes data page (x.com/i/communitynotes/download-data)
# pip install pandas
import pandas as pd

notes = pd.read_csv("notes-00000.tsv", sep="\t", dtype={"tweetId": str, "noteId": str})
status = pd.read_csv("noteStatusHistory-00000.tsv", sep="\t", dtype={"noteId": str})
feats = pd.read_csv("features.csv", dtype={"tweet_id": str})

# classification: MISINFORMED_OR_POTENTIALLY_MISLEADING or NOT_MISLEADING (the note writer's view)
# currentStatus: NEEDS_MORE_RATINGS, CURRENTLY_RATED_HELPFUL, CURRENTLY_RATED_NOT_HELPFUL (the rating outcome)
labeled = notes.merge(status[["noteId", "currentStatus"]], on="noteId", how="left")
helpful = labeled[labeled["currentStatus"] == "CURRENTLY_RATED_HELPFUL"]
per_post = helpful.groupby("tweetId")["classification"].agg(lambda s: s.mode().iat[0]).rename("note_label")

out = feats.merge(per_post, left_on="tweet_id", right_index=True, how="left")
out["has_helpful_note"] = out["note_label"].notna().astype(int)
print(out["has_helpful_note"].mean(), "share of your posts with a helpful note")
out.to_csv("features_with_notes.csv", index=False)
05 — Section

Step 3: train a baseline that outputs a score, not a verdict

Start with the simplest model that can be explained to a reviewer: TF-IDF features and logistic regression on LIAR. It will not be accurate, and that is the lesson. The LIAR paper reports these six-class test accuracies: majority baseline 20.8%, logistic regression 24.7%, SVM 25.5%, Bi-LSTM 23.3%, CNN 27.0%, and a hybrid CNN using text plus all metadata 27.4%. Six fine-grained labels are hard even for people, and short statements stripped of context carry little signal.

Turn the classifier into a score. Rather than taking the top label, sum the probability of the two lowest labels (pants-fire and false) and use that as a 0 to 1 review score. Combine it with the source and propagation features from Step 1 in a second model, or simply sort the review queue by it. Every threshold you set is a trade between reviewer time and missed posts; pick it on a held-out set, and report precision and recall at that threshold.

If you use a pre-trained transformer from Hugging Face instead, read its model card first: the training data (often one of the datasets above), the license, and the evaluation numbers the authors report. Do not claim more accuracy than the card does, and re-evaluate on posts from your own domain, because a model trained on 2016 political statements will drift on today's topics. Our Twitter sentiment analysis guide walks through running a Hugging Face classifier on post text, and the same pattern applies here.

What not to do. Do not publish per-account 'fake news' rankings from a model score; do not auto-remove or auto-report on a score alone; do not treat a new account, a blue check, or a link to an unfamiliar site as evidence. Each of those features shifts a probability. None of them is a finding about a person.

python
# score.py - a transparent baseline: TF-IDF + logistic regression on LIAR, output a score.
# LIAR train/valid/test TSVs: cs.ucsb.edu/~william/data/liar_dataset.zip (column 2 = label, column 3 = statement)
# pip install scikit-learn pandas
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import make_pipeline

cols = ["id", "label", "statement", "subject", "speaker", "job", "state", "party",
        "barely_true", "false", "half_true", "mostly_true", "pants_fire", "context"]
train = pd.read_csv("train.tsv", sep="\t", names=cols)
test = pd.read_csv("test.tsv", sep="\t", names=cols)

# Six labels: pants-fire, false, barely-true, half-true, mostly-true, true
model = make_pipeline(TfidfVectorizer(ngram_range=(1, 2), min_df=2), LogisticRegression(max_iter=2000))
model.fit(train["statement"], train["label"])
print("6-class test accuracy:", round(model.score(test["statement"], test["label"]), 3))

# A score per post, for ranking a review queue: probability mass on the two lowest labels.
low = [list(model.classes_).index(c) for c in ("pants-fire", "false")]
def review_score(texts):
    return model.predict_proba(texts)[:, low].sum(axis=1)   # 0..1, a score, not a verdict
06 — Section

What the features look like on real data: 1,232 posts

A feature is only useful against a baseline, so we measured the same features on three kinds of sources, collected in 2026: the latest posts of 6 news organizations (@Reuters, @AP, @BBCBreaking, @CNN, @nytimes, @FoxNews; 553 original posts after removing 30 reposts), 4 fact-check accounts (@PolitiFact, @snopes, @factcheckdotorg, @CommunityNotes; 229 posts), and a keyword sample of the latest posts matching "fake news" and misinformation in English (300 posts).

Links separate publishers from conversation. 87.9% of news-organization posts and 92.1% of fact-check posts carry an external link, against 4.3% in the keyword sample. Among linked news-organization posts, 97.1% point to the outlet's own site. A model that treats 'no link' as suspicious would flag the large majority of ordinary conversation.

Talking about fake news is mostly replying. 78.0% of keyword-sample posts were replies and 14.3% quoted another post. Organization timelines show 0% replies because the timeline call excludes replies by default, so that row is not comparable; the point is that keyword samples are dominated by people arguing under someone else's post, which is why claim-level detection must look at the parent post, not the reply that mentions 'fake news'.

Shorteners are not a red flag on their own. 94.9% of @PolitiFact's linked posts used a link shortener. Resolve shortened URLs before bucketing, or a fact-checker will score like a spammer.

Feature6 news organizations4 fact-check accountsKeyword search sample
Posts analyzed (reposts excluded)553229300
With an external link87.9%92.1%4.3%
With photo or video40.9%43.2%12.7%
Replies0.0% (excluded by the call)0.0% (excluded by the call)78.0%
Quotes of another post0.0%6.1%14.3%
Median replies per retweet (10+ retweets)0.7760.8520.167
Median quotes per retweet (10+ retweets)0.1570.20.007
Grouped bar chart of four features across three samples collected in 2026. External link: news organizations 87.9%, fact-check accounts 92.1%, keyword search 4.3%. Photo or video: 40.9%, 43.2%, 12.7%. Replies: 0.0%, 0.0%, 78.0%. Quotes of another post: 0.0%, 6.1%, 14.3%. 1,232 public posts, 64 requests, no post labeled true or false.
The same four features on three kinds of sources, collected in 2026. Organization timelines exclude replies by default, so the reply bars compare only within the keyword sample.
07 — Section

Propagation and author signals: what normal looks like

Reply and quote ratios. On the 478 news-organization posts with at least 10 retweets, the median post drew 0.776 replies and 0.157 quotes per retweet; the 90th percentile was 2.255 replies and 0.411 quotes per retweet. Accounts differ: @CNN's median was 1.171 replies per retweet, @Reuters' 0.5. Normalize per account or per outlet type before you call a ratio unusual, and remember that a heated but accurate story produces the same pattern as a misleading one.

Who quotes a widely quoted news post. We fetched the first 120 quotes of the 3 news-organization posts with the highest quote counts in the sample (one each from @AP, @CNN and @nytimes). 76.7% of the quoting accounts were more than five years old, 6.7% under one year, 20.8% had a blue check, and only 1.7% of quotes added a link of their own. Quotes are commentary, not sourcing.

Who posts about fake news. In the keyword sample, the median author account was 1,724 days old (about 4.7 years), 7.0% of authors were under a year old and 0.7% under 30 days, 30.7% had a blue check, 25.3% had fewer than 100 followers and 10.0% more than 10,000. None carried the self-declared automated label. A detector that leans on young accounts would see few of them in this conversation at all.

Author featureKeyword search sampleQuotes of 3 news posts
Posts300120
Author account under 1 year old7.0%6.7%
Author account over 5 years old48.3%76.7%
Blue check30.7%20.8%
Under 100 followers25.3%9.2%
Post includes a link4.3%1.7%

These are aggregates over private individuals, reported only as shares. We did not read, quote or label any of their posts.

08 — Section

What it costs to collect detection data

Tweet endpoints on twitterapi.io (search, timelines, quotes, tweets by ID) cost 15 credits per post returned, $0.15 per 1,000 posts, with a 15-credit ($0.00015) minimum per request; $1 is 100,000 credits. Our whole study, 1,232 posts in 64 requests, cost about $0.19. The official X API's pay-per-usage rate card (docs.x.com) charges $0.005 per post read and $0.010 per user read, capped at 3 million post reads a month on pay-per-usage, which is about 33x more per 1,000 posts.

JobVolumetwitterapi.ioOfficial X API (pay-per-usage)
Hydrate a FakeNewsNet-sized ID list100,000 posts$15$500
Keyword sample for a feature baseline10,000 posts$1.50$50
Quotes of 100 posts, 40 each4,000 posts$0.60$20
Daily monitoring of a claim, 2,000 posts a day for 30 days60,000 posts$9$300

Reads need only an API key in the X-API-Key header; there is no X developer account to apply for. New accounts that pass the automatic check get free starter credits (no card, one per person or network, expiring after 31 days); the current amount and the subscription plans are on the pricing page. Accounts that have not paid yet are limited to 0.2 requests a second, 20 once paid.

09 — Section

How we collected this

Question: which aggregate signals that misinformation-detection pipelines use as features (links and their domains, media, reply, quote and retweet ratios, author account age and verification) show up in public X data, and how do they differ between news organizations, fact-check organizations and an open keyword conversation about fake news.

Accounts and queries: /twitter/user/last_tweets for @Reuters, @AP, @BBCBreaking, @CNN, @nytimes and @FoxNews (5 pages each) and @PolitiFact, @snopes, @factcheckdotorg and @CommunityNotes (3 pages each); /twitter/tweet/advanced_search with "fake news" lang:en -filter:retweets (10 pages) and misinformation lang:en -filter:retweets (5 pages), queryType=Latest; /twitter/tweet/quotes for the 3 news-organization posts with the highest quote counts (2 pages each).

Sample and window: 1,232 posts from 64 read-only requests, collected in 2026. Organization windows run from under a day (@Reuters) to several weeks; the @CommunityNotes account posts rarely, so its 57 posts span about two years. The keyword samples cover the latest hour or so of activity.

What the sample cannot show: whether any post is true or false (we labeled nothing), how features behave on posts that later received a Community Note (the API returns no note field, and we did not join the TSVs for this sample), replies on organization timelines (the default call excludes them), or anything about languages other than English. A one-hour keyword window is a snapshot, not a trend.

Privacy: aggregates only. Organization accounts are named; authors in the keyword and quote samples are private individuals and are never named, quoted or labeled. Raw search and quote pages were not kept with the study; the committed sample is de-identified feature rows (no IDs, URLs, text or handles).

python
"""fake_news_features.py - collect public X (Twitter) posts and turn them into the
aggregate features misinformation classifiers use: links and their domains, media,
reply / quote / retweet ratios, author age. It outputs a feature table, not verdicts.

    pip install requests
    export TWITTERAPI_IO_API_KEY=...
    python fake_news_features.py "\"fake news\" lang:en -filter:retweets" 5
"""
import csv
import os
import sys
import time
from datetime import datetime
from urllib.parse import urlparse

import requests

API = "https://api.twitterapi.io"
HEADERS = {"X-API-Key": os.environ["TWITTERAPI_IO_API_KEY"]}
SHORTENERS = {"bit.ly", "buff.ly", "ow.ly", "tinyurl.com", "dlvr.it", "trib.al"}
SOCIAL = {"youtube.com", "youtu.be", "x.com", "twitter.com", "instagram.com", "tiktok.com", "facebook.com", "t.me"}
FACT_CHECK = {"politifact.com", "snopes.com", "factcheck.org", "fullfact.org"}


def parse_time(s):
    # createdAt looks like "Sat Dec 05 22:36:19 +0000 2026", not ISO 8601
    return datetime.strptime(s, "%a %b %d %H:%M:%S %z %Y")


def search(query, pages=5):
    """Latest posts for a query; 20 per page, $0.15 per 1,000 posts returned."""
    tweets, cursor = [], None
    for _ in range(pages):
        params = {"query": query, "queryType": "Latest"}
        if cursor:
            params["cursor"] = cursor
        r = requests.get(f"{API}/twitter/tweet/advanced_search", headers=HEADERS, params=params, timeout=30)
        if r.status_code == 503:          # transient upstream throttle: wait and retry once
            time.sleep(60)
            continue
        r.raise_for_status()
        body = r.json()
        tweets.extend(body.get("tweets") or [])
        if not body.get("has_next_page") or not body.get("next_cursor"):
            break
        cursor = body["next_cursor"]
        time.sleep(1)                     # fixed pacing
    return tweets


def quotes_of(tweet_id, pages=2):
    """Quote posts of one post: who amplifies it with their own comment."""
    out, cursor = [], None
    for _ in range(pages):
        params = {"tweetId": tweet_id}
        if cursor:
            params["cursor"] = cursor
        r = requests.get(f"{API}/twitter/tweet/quotes", headers=HEADERS, params=params, timeout=30)
        r.raise_for_status()
        body = r.json()
        out.extend(body.get("tweets") or [])
        if not body.get("has_next_page") or not body.get("next_cursor"):
            break
        cursor = body["next_cursor"]
        time.sleep(1)
    return out


def domain_bucket(url):
    host = (urlparse(url).hostname or "").lower().removeprefix("www.")
    if host in FACT_CHECK:
        return "fact-check"
    if host in SOCIAL:
        return "social/video"
    if host in SHORTENERS:
        return "shortener"
    return "other"


def features(t):
    urls = [u.get("expanded_url") or "" for u in (t.get("entities") or {}).get("urls") or []]
    media = (t.get("extendedEntities") or {}).get("media") or []
    author = t.get("author") or {}
    rts = t.get("retweetCount") or 0
    age = (parse_time(t["createdAt"]) - parse_time(author["createdAt"])).days if author.get("createdAt") else None
    return {
        "has_link": int(bool(urls)),
        "link_buckets": "|".join(sorted({domain_bucket(u) for u in urls if u})),
        "has_media": int(bool(media)),
        "is_reply": int(bool(t.get("isReply"))),
        "is_quote": int(bool(t.get("quoted_tweet"))),
        "reply_per_retweet": round((t.get("replyCount") or 0) / rts, 3) if rts >= 10 else "",
        "quote_per_retweet": round((t.get("quoteCount") or 0) / rts, 3) if rts >= 10 else "",
        "author_age_days": age,
        "author_blue": int(bool(author.get("isBlueVerified"))),
        "author_followers": author.get("followers"),
        "tweet_id": t["id"],              # keep the ID so you can join Community Notes TSVs (tweetId)
    }


if __name__ == "__main__":
    query = sys.argv[1] if len(sys.argv) > 1 else '"fake news" lang:en -filter:retweets'
    pages = int(sys.argv[2]) if len(sys.argv) > 2 else 5
    rows = [features(t) for t in search(query, pages)]
    with open("features.csv", "w", newline="") as f:
        w = csv.DictWriter(f, fieldnames=list(rows[0].keys()) if rows else ["tweet_id"])
        w.writeheader()
        w.writerows(rows)
    n = len(rows) or 1
    print(f"{len(rows)} posts | with link {sum(r['has_link'] for r in rows) / n:.1%} | replies {sum(r['is_reply'] for r in rows) / n:.1%}")

Researching this?Free starter credits cover end-to-end testing — Google sign-in, no card. Get a key.

10 — Questions

Questions readers ask

Can a model reliably detect fake news on Twitter?

Not on its own. The LIAR paper's best text-only model reached 27.0% six-class test accuracy against a 20.8% majority baseline. Models are useful for ranking posts so human fact-checkers see the riskiest first; treat every output as a score, combine text with source, propagation and Community Notes signals, and keep a human in the decision.

What is the best dataset for Twitter fake news detection?

It depends on the model. LIAR (12.8K PolitiFact statements, six labels) suits claim-text classifiers. FakeNewsNet (PolitiFact and GossipCop articles with the IDs of posts that shared them) adds social context but ships IDs only, so you hydrate the posts. Community Notes publishes daily TSVs of notes keyed by tweetId, useful as weak labels and for evaluation.

How do I hydrate tweet IDs from FakeNewsNet?

Send the IDs in batches to /twitter/tweets with the tweet_ids parameter (comma-separated) and read the tweets array. Deleted or protected posts do not come back; record that, since disappearance is itself informative. At $0.15 per 1,000 posts returned, 100,000 IDs cost about $15, against $500 at the official X API's $0.005 per post read.

Does the API tell me whether a post has a Community Note?

No note field appeared in any tweet object in our collection. Download the Community Notes notes and noteStatusHistory TSVs, keep notes with currentStatus CURRENTLY_RATED_HELPFUL, and join them to your posts on tweetId.

Which features help detect misinformation on X?

Four families: claim text, source (link domains, author account age and history), propagation (replies, quotes and retweets relative to each other, and how fast they grow) and crowd labels. Each needs a baseline: in our study 87.9% of news-organization posts carried a link against 4.3% of keyword-search posts, so the absence of a link means little by itself.

Is this the same as bot detection?

No. Bot detection scores accounts for signs of automation; misinformation detection scores content and how it spreads. Accurate news is often posted by automated publisher accounts, and false claims are often posted by people. Our guide to Twitter bots covers the account side.

Can I publish a list of accounts my model flagged as spreading fake news?

We advise against it. A model score is a probability that a post resembles previously fact-checked false content, not a finding about a person. Publish aggregate results, keep per-post scores internal for human review, and follow your institution's ethics rules for research on private individuals.

11 — Further reading

Continue

Sources & further reading
More from this series

Writing about something you built with TwitterAPI.io? Our community rewards program pays API credits for honest tutorials, build logs and videos.

Build it

Stop reading. Start building.

Starter credits cover real testing on real data. Google sign-in, no card, no application queue.

Get an API key

Already building with TwitterAPI.io? Publish an honest tutorial or build log about it and earn up to $200 a month in API credits.