Social Media Scraping API: One API for All Platforms
Building an app that needs social media data? You could write individual scrapers for each platform. Maintain proxies. Handle rate limits. Fix things when platforms change their HTML.
Or you could use a social media scraping API and skip all that.
This guide shows you how to extract data from TikTok, Instagram, Twitter, YouTube, LinkedIn, and more—using one unified API.
What is a Social Media Scraping API?
A social media scraping API handles the hard parts of data extraction:
| You Do | The API Does |
|---|---|
| Make HTTP requests | Proxy rotation |
| Receive JSON data | CAPTCHA solving |
| Build your app | Rate limit handling |
| Browser automation | |
| Anti-bot detection bypass | |
| Data parsing & normalization |
You call an endpoint, you get clean data. That's it.
Platforms You Can Scrape
| Platform | Data Types |
|---|---|
| TikTok | Profiles, videos, comments, followers, hashtags, sounds |
| Profiles, posts, reels, stories, comments, followers | |
| Twitter/X | Profiles, tweets, threads, followers, trends, search |
| YouTube | Channels, videos, comments, transcripts, playlists |
| Profiles, companies, jobs, posts | |
| Pages, posts, comments, ad library | |
| Subreddits, posts, comments, users | |
| Threads | Profiles, posts, replies |
Quick Start
1. Get Your API Key
Sign up at sociavault.com and grab your API key from the dashboard.
2. Make Your First Request
const API_KEY = 'your_api_key';
// Scrape a TikTok profile
const response = await fetch(
'https://api.sociavault.com/v1/scrape/tiktok/profile?username=khaby.lame',
{
headers: {
'Authorization': `Bearer ${API_KEY}`
}
}
);
const data = await response.json();
console.log(data);
3. Use the Data
// Response
{
"success": true,
"data": {
"username": "khaby.lame",
"nickname": "Khabane lame",
"followers": 162000000,
"following": 78,
"likes": 2500000000,
"videos": 1200,
"bio": "If u wanna laugh u are in the right place",
"verified": true
}
}
Platform Examples
TikTok Scraping
// Get TikTok profile
async function getTikTokProfile(username) {
const response = await fetch(
`https://api.sociavault.com/v1/scrape/tiktok/profile?username=${username}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
return response.json();
}
// Get TikTok videos
async function getTikTokVideos(username, limit = 20) {
const response = await fetch(
`https://api.sociavault.com/v1/scrape/tiktok/videos?username=${username}&limit=${limit}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
return response.json();
}
// Get hashtag posts
async function getTikTokHashtag(hashtag, limit = 50) {
const response = await fetch(
`https://api.sociavault.com/v1/scrape/tiktok/hashtag?tag=${hashtag}&limit=${limit}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
return response.json();
}
Related: Extract TikTok Data
Instagram Scraping
// Get Instagram profile
async function getInstagramProfile(username) {
const response = await fetch(
`https://api.sociavault.com/v1/scrape/instagram/profile?username=${username}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
return response.json();
}
// Get Instagram posts
async function getInstagramPosts(username, limit = 12) {
const response = await fetch(
`https://api.sociavault.com/v1/scrape/instagram/posts?username=${username}&limit=${limit}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
return response.json();
}
// Get Instagram reels
async function getInstagramReels(username, limit = 10) {
const response = await fetch(
`https://api.sociavault.com/v1/scrape/instagram/reels?username=${username}&limit=${limit}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
return response.json();
}
// Get post comments
async function getInstagramComments(postUrl, limit = 100) {
const response = await fetch(
`https://api.sociavault.com/v1/scrape/instagram/comments?url=${encodeURIComponent(postUrl)}&limit=${limit}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
return response.json();
}
Related: How to Scrape Instagram Data
Twitter/X Scraping
// Get Twitter profile
async function getTwitterProfile(username) {
const response = await fetch(
`https://api.sociavault.com/v1/scrape/twitter/profile?username=${username}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
return response.json();
}
// Get tweets
async function getTweets(username, limit = 20) {
const response = await fetch(
`https://api.sociavault.com/v1/scrape/twitter/tweets?username=${username}&limit=${limit}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
return response.json();
}
// Search tweets
async function searchTweets(query, limit = 50) {
const response = await fetch(
`https://api.sociavault.com/v1/scrape/twitter/search?q=${encodeURIComponent(query)}&limit=${limit}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
return response.json();
}
Related: Twitter Scraping API
YouTube Scraping
// Get channel info
async function getYouTubeChannel(channelUrl) {
const response = await fetch(
`https://api.sociavault.com/v1/scrape/youtube/channel?url=${encodeURIComponent(channelUrl)}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
return response.json();
}
// Get video info
async function getYouTubeVideo(videoUrl) {
const response = await fetch(
`https://api.sociavault.com/v1/scrape/youtube/video?url=${encodeURIComponent(videoUrl)}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
return response.json();
}
// Get video comments
async function getYouTubeComments(videoUrl, limit = 100) {
const response = await fetch(
`https://api.sociavault.com/v1/scrape/youtube/comments?url=${encodeURIComponent(videoUrl)}&limit=${limit}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
return response.json();
}
Related: YouTube API Alternative
LinkedIn Scraping
// Get LinkedIn profile
async function getLinkedInProfile(profileUrl) {
const response = await fetch(
`https://api.sociavault.com/v1/scrape/linkedin/profile?url=${encodeURIComponent(profileUrl)}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
return response.json();
}
// Get company info
async function getLinkedInCompany(companyUrl) {
const response = await fetch(
`https://api.sociavault.com/v1/scrape/linkedin/company?url=${encodeURIComponent(companyUrl)}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
return response.json();
}
Related: LinkedIn Scraping API
Python SDK
import requests
class SociaVaultClient:
def __init__(self, api_key):
self.api_key = api_key
self.base_url = 'https://api.sociavault.com/v1/scrape'
def _request(self, endpoint, params=None):
response = requests.get(
f'{self.base_url}/{endpoint}',
params=params,
headers={'Authorization': f'Bearer {self.api_key}'}
)
return response.json()
# TikTok
def tiktok_profile(self, username):
return self._request('tiktok/profile', {'username': username})
def tiktok_videos(self, username, limit=20):
return self._request('tiktok/videos', {'username': username, 'limit': limit})
# Instagram
def instagram_profile(self, username):
return self._request('instagram/profile', {'username': username})
def instagram_posts(self, username, limit=12):
return self._request('instagram/posts', {'username': username, 'limit': limit})
def instagram_followers(self, username, limit=100):
return self._request('instagram/followers', {'username': username, 'limit': limit})
# Twitter
def twitter_profile(self, username):
return self._request('twitter/profile', {'username': username})
def twitter_tweets(self, username, limit=20):
return self._request('twitter/tweets', {'username': username, 'limit': limit})
# YouTube
def youtube_channel(self, url):
return self._request('youtube/channel', {'url': url})
def youtube_video(self, url):
return self._request('youtube/video', {'url': url})
# LinkedIn
def linkedin_profile(self, url):
return self._request('linkedin/profile', {'url': url})
def linkedin_company(self, url):
return self._request('linkedin/company', {'url': url})
# Usage
client = SociaVaultClient('your_api_key')
# Get TikTok data
profile = client.tiktok_profile('charlidamelio')
print(f"Followers: {profile['data']['followers']:,}")
# Get Instagram data
posts = client.instagram_posts('nike', limit=10)
for post in posts['data']:
print(f"Likes: {post['like_count']:,}")
Use Cases
1. Cross-Platform Influencer Analysis
async function analyzeInfluencer(handles) {
const results = {};
// TikTok
if (handles.tiktok) {
const tt = await getTikTokProfile(handles.tiktok);
results.tiktok = {
followers: tt.data.followers,
engagement: await calculateTikTokEngagement(handles.tiktok)
};
}
// Instagram
if (handles.instagram) {
const ig = await getInstagramProfile(handles.instagram);
results.instagram = {
followers: ig.data.follower_count,
engagement: await calculateInstagramEngagement(handles.instagram)
};
}
// YouTube
if (handles.youtube) {
const yt = await getYouTubeChannel(handles.youtube);
results.youtube = {
subscribers: yt.data.subscriber_count,
totalViews: yt.data.total_views
};
}
// Calculate total reach
results.totalReach = Object.values(results)
.reduce((sum, p) => sum + (p.followers || p.subscribers || 0), 0);
return results;
}
Related: Build an Influencer Database
2. Competitor Monitoring
async function monitorCompetitors(competitors) {
const report = [];
for (const competitor of competitors) {
const data = {
name: competitor.name,
platforms: {}
};
// Check each platform
for (const [platform, handle] of Object.entries(competitor.handles)) {
const profile = await scrapeProfile(platform, handle);
data.platforms[platform] = {
followers: profile.data.followers || profile.data.follower_count,
posts: profile.data.media_count || profile.data.videos
};
}
report.push(data);
}
return report;
}
// Usage
const competitors = [
{ name: 'Nike', handles: { instagram: 'nike', tiktok: 'nike', twitter: 'nike' } },
{ name: 'Adidas', handles: { instagram: 'adidas', tiktok: 'adidas', twitter: 'adidas' } }
];
monitorCompetitors(competitors).then(console.table);
3. Content Aggregation
async function aggregateContent(hashtag, platforms = ['tiktok', 'instagram', 'twitter']) {
const content = [];
for (const platform of platforms) {
let posts;
switch (platform) {
case 'tiktok':
posts = await getTikTokHashtag(hashtag, 20);
break;
case 'instagram':
posts = await getInstagramHashtag(hashtag, 20);
break;
case 'twitter':
posts = await searchTweets(`#${hashtag}`, 20);
break;
}
posts.data.forEach(post => {
content.push({
platform,
id: post.id,
text: post.caption || post.text || post.description,
likes: post.likes || post.like_count,
author: post.author || post.username,
url: post.url || post.post_url
});
});
}
// Sort by engagement
content.sort((a, b) => b.likes - a.likes);
return content;
}
4. Sentiment Analysis
from textblob import TextBlob
def analyze_sentiment(comments):
sentiments = []
for comment in comments:
text = comment.get('text', '')
blob = TextBlob(text)
sentiments.append({
'text': text[:100],
'polarity': blob.sentiment.polarity, # -1 to 1
'subjectivity': blob.sentiment.subjectivity,
'sentiment': 'positive' if blob.sentiment.polarity > 0.1
else 'negative' if blob.sentiment.polarity < -0.1
else 'neutral'
})
# Aggregate
positive = sum(1 for s in sentiments if s['sentiment'] == 'positive')
negative = sum(1 for s in sentiments if s['sentiment'] == 'negative')
neutral = sum(1 for s in sentiments if s['sentiment'] == 'neutral')
return {
'total_comments': len(sentiments),
'positive': positive,
'negative': negative,
'neutral': neutral,
'positive_rate': f"{(positive/len(sentiments)*100):.1f}%",
'avg_polarity': sum(s['polarity'] for s in sentiments) / len(sentiments)
}
# Usage
client = SociaVaultClient('your_api_key')
comments = client.instagram_comments('https://instagram.com/p/ABC123', limit=200)
sentiment = analyze_sentiment(comments['data'])
print(sentiment)
Related: Social Media Sentiment Analysis
Error Handling
async function safeScrape(platform, endpoint, params) {
try {
const response = await fetch(
`https://api.sociavault.com/v1/scrape/${platform}/${endpoint}?${new URLSearchParams(params)}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
if (!response.ok) {
if (response.status === 429) {
// Rate limited - wait and retry
await new Promise(r => setTimeout(r, 5000));
return safeScrape(platform, endpoint, params);
}
throw new Error(`HTTP ${response.status}`);
}
const data = await response.json();
if (!data.success) {
throw new Error(data.error || 'Unknown error');
}
return data;
} catch (error) {
console.error(`Error scraping ${platform}/${endpoint}:`, error.message);
return { success: false, error: error.message };
}
}
Pricing Comparison
| Service | Pricing | Platforms |
|---|---|---|
| SociaVault | $0.001/request | 25+ |
| Bright Data | $500+/month | Limited |
| PhantomBuster | $69-439/month | 10+ |
| Apify | $49-499/month | Varies |
| Build yourself | $300-500/month | Whatever you build |
Getting Started
- Sign up at sociavault.com
- Get 50 free credits - no credit card required
- Copy your API key from the dashboard
- Start scraping with the examples above
Frequently Asked Questions
Is social media scraping legal?
Yes, scraping publicly available data is legal. The hiQ Labs v. LinkedIn case (2022) established that public data isn't protected by the CFAA. See our legal guide.
Which platforms can I scrape?
TikTok, Instagram, Twitter/X, YouTube, LinkedIn, Facebook, Reddit, Threads, and more. Check the documentation for the full list.
How fast is the API?
Most requests complete in 1-5 seconds. Larger requests (like follower lists) may take longer depending on volume.
Do I need to manage proxies?
No. The API handles all proxy rotation, CAPTCHA solving, and anti-bot detection automatically.
Related guides:
Found this helpful?
Share it with others who might benefit
Ready to Try SociaVault?
Start extracting social media data with our powerful API. No credit card required.