Scrape public Truth Social posts to JSON, with text, likes, reposts and timestamps. Built on the Scrapier API: one HTTPS request, no headless browser to run, no parser to maintain.
Quickstart · Fields · CLI · FAQ
-
Get an API key from the Scrapier dashboard. No credit card needed to start.
-
Install:
pip install git+https://github.com/get-scrapier/Truth-Social-Posts-Scraper
-
Run:
from scrapier_truth_social_posts import TruthSocialPosts
client = TruthSocialPosts(api_key="sk_live_...") # or set SCRAPIER_API_KEY
import re
for post in client.iter_posts("realDonaldTrump",
max_items=100):
if post["reblog"]:
continue # a repost; content is empty
text = re.sub(r"<[^>]+>", "", post["content"])
print(post["favourites_count"], post["upvotes_count"],
text[:60])The same code is in examples/quickstart.py.
- Social listening
- News monitoring
- Research
- Sentiment analysis
Walks an account's posts, twenty a page, with the body, the like, repost and reply counts, the upvote and downvote counts, the media and the polls.
Truth Social keeps both Mastodon's favourites and its own up/down voting, so there are two independent engagement signals on every row.
Wraps the truth-social-posts endpoint, 20 rows a page.
# 1. A list. For scripts and one-liners.
rows = client.posts(username, max_items=100)
# 2. A generator. Streams, so you can stop early and stop paying.
for row in client.iter_posts(username):
handle(row)
# 3. A page at a time. You hold the cursor, so you can resume later.
page = client.posts_page(username)
save(page.items)
while page.has_more:
page = client.posts_page(cursor=page.next_cursor)
save(page.items)A Page carries the rows plus the envelope:
page.items # the rows
page.next_cursor # opaque string, or None
page.has_more # bool
page.raw_responses # upstream payloads, when raw_data=True
page.data # the whole envelope
len(page) # number of rowsObserved on live responses, not copied from a schema.
| Field | Notes |
|---|---|
id, url, uri |
identity |
content |
the post body, as HTML -- see the quirks |
favourites_count, reblogs_count, replies_count |
likes, reposts and replies -- note the spelling |
upvotes_count, downvotes_count, votable, reaction |
Truth Social's own voting, separate from favourites |
account |
the author, nested |
reblog |
the original post, when this row is a repost |
quote, quote_id |
the quoted post |
in_reply_to, in_reply_to_id, in_reply_to_account_id |
what it replies to |
media_attachments, card |
the media and the link preview |
poll |
the poll, when there is one |
tags, mentions, emojis |
tagging and custom emoji |
sensitive, spoiler_text, visibility |
content warnings and audience |
pinned, sponsored, group |
placement |
language |
the post's language |
created_at, edited_at, editable |
when, and whether edited |
favourited, reblogged, bookmarked, muted |
viewer state -- always false here, see the quirks |
input_username |
echoes your input |
This is Mastodon's schema, in British spelling. Truth Social runs on
Mastodon, so a like is favourites_count, a repost is
reblog/reblogs_count, and the post body is content. Reaching
for likes or text gets you nothing.
content is HTML, not plain text. It arrives with <p> tags,
links and mention markup, exactly as Mastodon serves it. Strip it before
any text analysis, and do not render it untrusted.
There are two engagement systems and they do not agree.
favourites_count is Mastodon's like; upvotes_count and
downvotes_count are Truth Social's addition. A post can be heavily
favourited and lightly voted, so pick the one your analysis means and
say which.
A repost's own content is empty; the original is in reblog.
Reading content on a repost attributes an empty string to the
account rather than the post it shared.
The viewer-state fields are meaningless here. favourited,
reblogged, bookmarked and muted describe how you have
interacted with a post, and this is a logged-out read, so they are
always false. They are not a signal about the post.
downvotes_count is a genuinely public dislike count, which almost no
platform publishes -- worth having alongside scrapier-rumble-video's
dislikeCount.
Each page is a billable request, so bound a broad walk:
client.posts(username, max_items=200) # stop after 200 rows
client.posts(username, max_pages=5) # stop after 5 requestsmax_items truncates mid-page rather than buying another page to fill a
quota. Checking your balance is free:
print(client.credits())
print(client.account())AsyncTruthSocialPosts exposes every method TruthSocialPosts does,
with identical arguments.
import asyncio
from scrapier_truth_social_posts import AsyncTruthSocialPosts
async def main():
async with AsyncTruthSocialPosts() as client:
rows = await client.posts(username)
asyncio.run(main())For hundreds of inputs, submit one background job instead of paging:
job = client.bulk([...], max_items=1000) # up to 10,000 per input
print(job.job_id, job.status)
rows = job.wait(timeout=1800, poll_interval=5)Reattach from another process with client.job(job_id), then read
job.data.
Submits are deduplicated server-side on the request parameters, so an identical submit returns the job the first one created — including when that job failed. Vary a parameter to force a fresh attempt.
Everything derives from ScrapierError, so one except can catch the
lot while you still get to be specific when it matters.
from scrapier_truth_social_posts import InsufficientCreditsError, RateLimitError, ScrapierError
try:
rows = client.posts(username)
except InsufficientCreditsError as exc:
print(f"out of credits: {exc.balance} left, {exc.required} needed")
except RateLimitError as exc:
print(f"slow down for {exc.retry_after}s")
except ScrapierError as exc:
print(f"something else: {exc}")| Exception | When |
|---|---|
ConfigurationError |
no API key, or a reserved parameter was passed |
TransportError |
the request never got a response |
BadRequestError |
400 — bad input |
AuthenticationError |
401 — bad or missing key |
InsufficientCreditsError |
402 with a balance — carries .balance and .required |
NotFoundError |
404 |
RateLimitError |
429 — carries .retry_after |
ScrapeTimeoutError |
504 — the scrape itself ran out of time |
ServiceUnavailableError |
503 |
ServerError |
5xx |
JobFailedError |
a bulk job finished in failed — carries .errors |
APIError |
the base for anything with a status code |
429, 503, 5xx and transport failures are retried automatically with
jittered backoff that honours Retry-After. 400, 401, 404 and a 402
about your balance are not — retrying those only wastes time.
export SCRAPIER_API_KEY=sk_live_...
scrapier-truth-social-posts <username> --max-items 50 --jsonlJSON on stdout and nothing else, so it pipes. Global flags (--api-key,
--base-url, --timeout, --jsonl, --indent) work anywhere on the
line. Exit codes: 0 success, 2 usage or configuration, 3 API
error.
TruthSocialPosts(
api_key=None, # falls back to $SCRAPIER_API_KEY
base_url=None, # falls back to $SCRAPIER_BASE_URL, then the default
timeout=160.0,
max_retries=3, # for 429/503/5xx and transport failures
http_client=None, # bring your own httpx.Client
)The key is sent in the X-API-Key header only — never in a URL or a
request body, so it will not end up in a proxy log.
Every call also accepts method="GET" if you would rather the
parameters went in the query string, use_proxy=True to route the
scrape through Scrapier's proxy pool, and raw_data=True to get the
upstream payloads instead of parsed rows.
Python 3.9+. The only dependency is httpx. Ships py.typed.
The client code is MIT-licensed. It needs a Scrapier API key, and requests are billed in credits; failed requests are not billed. See pricing. You can start without a credit card.
No. The scrape runs on Scrapier's servers and returns JSON.
Use bulk jobs: submit many inputs as one background job, then job.wait().
Yes. See AGENTS.md, or connect the
Scrapier MCP server.
180+ endpoints across 35+ platforms: browse them all.
Open an issue or read the docs.
MIT. See LICENSE.