How to Scrape Truth Social Posts with TypeScript

Extract post data from Truth Social

📘 Using TypeScript

Overview

Learn how to scrape Truth Social posts using TypeScript. This comprehensive guide will walk you through the entire process, from setup to implementation.

What You'll Learn

  • • Setting up your development environment
  • • Installing the required HTTP client
  • • Authenticating with the ScrapeCreators API
  • • Making requests to Truth Social
  • • Handling responses and errors
  • • Best practices for production use

What You'll Get

  • • Access to posts data
  • • JSON formatted responses
  • • Real-time data access
  • • Scalable solution
  • • Error handling patterns
  • • Performance optimization tips

Prerequisites

1. API Key

First, you'll need a ScrapeCreators API key to authenticate your requests.

Sign up at app.scrapecreators.com to get your free API key with 100 requests.

2. Development Environment

Make sure you have the following installed:

  • TypeScript and its dependencies
  • • A code editor (VS Code, Sublime, etc.)
  • • Basic understanding of API requests
  • • Command line interface access

Step 1: Install HTTP Client

Axios is a promise-based HTTP client for TypeScript/JavaScript

npm
npm install axios

Step 2: API Implementation

Now let's make a request to the Truth Social API using TypeScript. Replace YOUR_API_KEY with your actual API key.

TypeScript
import axios from 'axios';

interface ScrapeParams {
url: string;
}

const API_KEY = 'YOUR_API_KEY';

async function scrape(params: ScrapeParams): Promise<any> {
try {
const response = await axios.get(`https://api.scrapecreators.com/v1/truthsocial/post?url=https://truthsocial.com/@realDonaldTrump/posts/114315219437063160`, {
headers: {
'x-api-key': API_KEY,
'Content-Type': 'application/json'
},
});

console.log('Response:', response.data);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
throw error;
}
}

// Usage
const params: ScrapeParams = {
url: 'https://truthsocial.com/@realDonaldTrump/posts/114315219437063160'
};

scrape(params);

Step 3: Testing Your Code

API Parameters

This endpoint accepts the following parameters:

urlRequired(string)

Truth Social post URL

Example: https://truthsocial.com/@realDonaldTrump/posts/114315219437063160

Run Your Code

Execute your script to test the API connection. You should see a JSON response with Truth Social posts data.

✅ Success: You should receive a structured JSON response containing the requested data.

Expected Response

Here's an example of the JSON response you'll receive:

Sample Response
{
"success": true,
"text": "It’s so hard to watch as Highly Qualified and Respected Ambassadors, who we desperately need representing our Country in Faraway Lands, are purposefully meant to wait as the Democrat Senators take maximum time for every single one of them, even though they were confirmed with Bipartisan Support, also at maximum time, and only done to hurt our Country. A process that should take a matter of minutes is forced into taking months, making it very hard on the new Ambassadors’ families, and not good, at all, for the Good Ole’ U.S.A. In a true sense, in numerous cases, what they do is actually a Threat to National Security. John Thune and the Republicans are doing a great job, but nothing much can be done when the Democrats make everyone sit, day after day, pushing the limits. The level of hostility is not to be believed!",
"id": "114315219437063160",
"created_at": "2025-04-10T19:03:40.023Z",
"in_reply_to_id": null,
"quote_id": null,
"in_reply_to_account_id": null,
"sensitive": false,
"spoiler_text": "",
"visibility": "public",
"language": "en",
"uri": "https://truthsocial.com/@realDonaldTrump/114315219437063160",
"url": "https://truthsocial.com/@realDonaldTrump/114315219437063160",
"content": "<p>It’s so hard to watch as Highly Qualified and Respected Ambassadors, who we desperately need representing our Country in Faraway Lands, are purposefully meant to wait as the Democrat Senators take maximum time for every single one of them, even though they were confirmed with Bipartisan Support, also at maximum time, and only done to hurt our Country. A process that should take a matter of minutes is forced into taking months, making it very hard on the new Ambassadors’ families, and not good, at all, for the Good Ole’ U.S.A. In a true sense, in numerous cases, what they do is actually a Threat to National Security. John Thune and the Republicans are doing a great job, but nothing much can be done when the Democrats make everyone sit, day after day, pushing the limits. The level of hostility is not to be believed!</p>",
"account": {
"id": "107780257626128497",
"username": "realDonaldTrump",
"acct": "realDonaldTrump",
"display_name": "Donald J. Trump",
"locked": false,
"bot": false,
"discoverable": false,
"group": false,
"created_at": "2022-02-11T16:16:57.705Z",
"note": "<p></p>",
"url": "https://truthsocial.com/@realDonaldTrump",
"avatar": "https://static-assets-1.truthsocial.com/tmtg:prime-ts-assets/accounts/avatars/107/780/257/626/128/497/original/454286ac07a6f6e6.jpeg",
"avatar_static": "https://static-assets-1.truthsocial.com/tmtg:prime-ts-assets/accounts/avatars/107/780/257/626/128/497/original/454286ac07a6f6e6.jpeg",
"header": "https://static-assets-1.truthsocial.com/tmtg:prime-ts-assets/accounts/headers/107/780/257/626/128/497/original/ba3b910ba387bf4e.jpeg",
"header_static": "https://static-assets-1.truthsocial.com/tmtg:prime-ts-assets/accounts/headers/107/780/257/626/128/497/original/ba3b910ba387bf4e.jpeg",
"followers_count": 9528704,
"following_count": 72,
"statuses_count": 26249,
"last_status_at": "2025-04-10",
"verified": true,

Verify Response Structure

Check that your response includes the expected fields:

  • success(boolean)
  • text(string)
  • id(string)
  • created_at(string)
  • in_reply_to_id(object)
  • ... and 29 more fields

Best Practices

1

Error Handling

Implement comprehensive error handling and retry logic for failed requests. Log errors properly for debugging.

2

Caching

Cache responses when possible to reduce API calls and improve performance. Consider data freshness requirements.

3

Security

Never expose your API key in client-side code. Use environment variables and secure key management practices.

Performance Tips

Batch Requests

When scraping multiple posts, consider batching requests to maximize throughput while staying within rate limits.

Async Processing

Use asynchronous processing in TypeScript to handle multiple requests concurrently and improve overall performance.

Common Use Cases

Market Research

Analyze Truth Social posts to understand market trends, competitor analysis, and audience insights.

Content Analytics

Track performance metrics, engagement rates, and content trends across Truth Social posts.

Lead Generation

Identify potential customers and business opportunities throughTruth Social data analysis.

Troubleshooting

Common Errors

401 Unauthorized

Check your API key is correct and properly formatted in the x-api-key header.

402 Payment Required

You ran out of credits and need to buy more.

404 Not Found

The resource might not exist or be private.

500 Server Error

Temporary server issue. Implement retry logic with exponential backoff.

Frequently Asked Questions

How much does it cost to scrape Truth Social posts?

ScrapeCreators offers 100 free API calls to get started. After that, pricing starts at $10 for 5k requests with volume discounts available.

Is it legal to scrape Truth Social data?

Scraping publicly available data is fair game, and we only collect public data. So anything that you can see in an incognito browser is what we collect.

How fast can I scrape Truth Social posts?

There is no rate limit! So you can scrape as fast as you want!

What data format does the API return?

All API responses are returned in JSON format, making it easy to integrate with any programming language or application.

Can I use this with other TypeScript frameworks?

Yes! This tutorial focuses on core TypeScript HTTP concepts that work with any framework. The API calls remain the same regardless of your specific TypeScript setup.

How do I handle large datasets?

For large datasets, implement pagination, use streaming responses where available, and consider storing data in a database for efficient querying.

Related Tutorials

Ready to Start Scraping?

Get started with 100 free API calls. No credit card required.