Back to Extractor

API Documentation

Extract Twitter content programmatically with our REST API

Overview

The Twitter Content Extractor API allows developers to extract text and images from Twitter posts programmatically. The API uses the same robust extraction methods as our web interface and includes intelligent caching for improved performance.

Fast

Intelligent caching reduces response times for repeated requests

Reliable

Multiple extraction methods ensure high success rates

JSON

Clean JSON responses with consistent structure

Base URL

GET https://your-domain.com/api/v1/extract

Parameters

  • url (required) - The Twitter URL to extract content from

Supported URL Formats

  • https://twitter.com/username/status/123456789
  • https://x.com/username/status/123456789
  • https://t.co/abc123

Example Request

GET /api/v1/extract?url=https://twitter.com/username/status/123456789

Success Response

{ "success": true, "data": { "text": "This is the tweet content...", "images": [ "https://pbs.twimg.com/media/example.jpg" ], "url": "https://twitter.com/username/status/123456789" }, "meta": { "cached": false, "extracted_at": "2024-01-15T10:30:00.000Z", "share_url": "https://your-domain.com/share/abc123" } }

Error Response

{ "error": "Invalid Twitter URL", "supported_formats": [ "https://twitter.com/username/status/123456789", "https://x.com/username/status/123456789", "https://t.co/abc123" ] }

Test the API

Try the API directly from this page:

Extracting content...

Success

            

Code Examples

JavaScript (Fetch)

const response = await fetch('/api/v1/extract?url=https://twitter.com/username/status/123456789'); const data = await response.json(); if (data.success) { console.log('Text:', data.data.text); console.log('Images:', data.data.images); } else { console.error('Error:', data.error); }

Python (Requests)

import requests response = requests.get('https://your-domain.com/api/v1/extract', params={'url': 'https://twitter.com/username/status/123456789'}) data = response.json() if data['success']: print('Text:', data['data']['text']) print('Images:', data['data']['images']) else: print('Error:', data['error'])

cURL

curl "https://your-domain.com/api/v1/extract?url=https://twitter.com/username/status/123456789"

Rate Limits & Caching

Content Extraction

Extract text and images from Twitter posts using our API.

POST /api/extract

Parameters

url - Twitter URL to extract content from

Example Request

curl -X POST http://localhost:3000/api/extract \
  -H "Content-Type: application/json" \
  -d '{"url": "https://twitter.com/username/status/123456789"}'

Example Response

{ "success": true, "text": "Extracted tweet text...", "images": ["image1.jpg", "image2.jpg"], "url": "https://twitter.com/username/status/123456789", "cached": false, "shareUrl": "/share/abc123" }

Public API

Public API endpoint for developers and third-party integrations.

GET /api/v1/extract

Parameters

url - Twitter URL to extract content from (query parameter)

Example Request

GET /api/v1/extract?url=https://twitter.com/username/status/123456789

Example Response

{ "success": true, "data": { "text": "Extracted tweet text...", "images": ["image1.jpg", "image2.jpg"], "url": "https://twitter.com/username/status/123456789" }, "meta": { "cached": false, "extracted_at": "2024-01-01T12:00:00.000Z", "share_url": "http://localhost:3000/share/abc123" } }

Tracking Statistics

Get tracking statistics for shared content and platform usage.

GET /api/tracking/:id

Parameters

id - Share ID to get tracking data for

Example Request

GET /api/tracking/abc123

Example Response

{ "success": true, "shareId": "abc123", "tracking": { "totalVisits": 42, "referrers": { "twitter": 15, "direct": 12, "google.com": 8, "facebook.com": 7 }, "firstVisit": "2024-01-01T12:00:00.000Z", "lastVisit": "2024-01-15T18:30:00.000Z", "referrerCount": 4 }, "content": { "originalUrl": "https://twitter.com/username/status/123456789", "extractedAt": "2024-01-01T12:00:00.000Z", "hasImages": true, "imageCount": 2 }, "shareUrl": "http://localhost:3000/share/abc123" }

Global Statistics

Get platform-wide statistics and analytics.

GET /api/tracking

Example Request

GET /api/tracking

Example Response

{ "success": true, "globalStats": { "totalShares": 150, "totalVisits": 2847, "topReferrers": { "twitter": 1200, "direct": 850, "google.com": 450, "facebook.com": 200, "reddit.com": 147 }, "recentActivity": [ { "shareId": "abc123", "lastVisit": "2024-01-15T18:30:00.000Z", "totalVisits": 42 } ] } }

Platform Stats

Get aggregated statistics for the main page dashboard.

GET /api/stats

Example Request

GET /api/stats

Example Response

{ "success": true, "stats": { "totalShares": 150, "totalViews": 2847, "avgViews": 18.98 } }

Image Caching

Cache and serve images from Twitter posts.

GET /api/cache-image

Parameters

url - Image URL to cache

Example Request

GET /api/cache-image?url=https://pbs.twimg.com/media/example.jpg

Example Response

{ "success": true, "cachedUrl": "/cache/abc123.jpg", "originalUrl": "https://pbs.twimg.com/media/example.jpg" }