Getting Started with SociaVault API
You want to extract social media data. Profiles, posts, comments, followers—from TikTok, Instagram, YouTube, Twitter, LinkedIn, and more.
SociaVault makes this simple with a unified REST API. One API key, consistent endpoints, clean JSON responses.
Let's get you set up.
Quick Start (5 Minutes)
Step 1: Create an Account
Go to sociavault.com/auth/sign-up and create your free account.
You get 50 free credits to test the API.
Step 2: Get Your API Key
- Log in to your dashboard
- Find your API key in the settings section
- Copy it somewhere safe
Step 3: Make Your First Request
const API_KEY = 'your_api_key_here';
const response = await fetch(
'https://api.sociavault.com/v1/scrape/tiktok/profile?username=charlidamelio',
{
headers: {
'Authorization': `Bearer ${API_KEY}`
}
}
);
const data = await response.json();
console.log(data);
That's it. You're scraping social media data.
Authentication
All requests require an API key in the Authorization header:
Authorization: Bearer your_api_key_here
cURL Example
curl -X GET "https://api.sociavault.com/v1/scrape/tiktok/profile?username=charlidamelio" \
-H "Authorization: Bearer your_api_key_here"
Python Example
import requests
API_KEY = "your_api_key_here"
headers = {"Authorization": f"Bearer {API_KEY}"}
response = requests.get(
"https://api.sociavault.com/v1/scrape/tiktok/profile",
params={"username": "charlidamelio"},
headers=headers
)
print(response.json())
API Structure
Base URL
https://api.sociavault.com/v1/scrape
Endpoint Pattern
/{platform}/{resource}?{parameters}
Platforms: tiktok, instagram, youtube, twitter, linkedin, reddit, facebook, threads
Resources: Vary by platform (profile, posts, comments, search, etc.)
Common Endpoints
TikTok
| Endpoint | Description |
|---|---|
/tiktok/profile | Get user profile |
/tiktok/videos | Get user's videos |
/tiktok/video | Get single video info |
/tiktok/comments | Get video comments |
/tiktok/search | Search videos |
/tiktok/hashtag | Get hashtag videos |
// Get TikTok profile
const profile = await fetch(
'https://api.sociavault.com/v1/scrape/tiktok/profile?username=charlidamelio',
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
).then(r => r.json());
// Get user's videos
const videos = await fetch(
'https://api.sociavault.com/v1/scrape/tiktok/videos?username=charlidamelio&count=20',
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
).then(r => r.json());
| Endpoint | Description |
|---|---|
/instagram/profile | Get user profile |
/instagram/posts | Get user's posts |
/instagram/post | Get single post info |
/instagram/reels | Get user's reels |
/instagram/comments | Get post comments |
/instagram/hashtag | Get hashtag posts |
// Get Instagram profile
const profile = await fetch(
'https://api.sociavault.com/v1/scrape/instagram/profile?username=natgeo',
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
).then(r => r.json());
YouTube
| Endpoint | Description |
|---|---|
/youtube/channel | Get channel info |
/youtube/videos | Get channel videos |
/youtube/video | Get video details |
/youtube/comments | Get video comments |
/youtube/search | Search videos |
/youtube/transcript | Get video transcript |
// Get YouTube transcript (great for AI/RAG)
const transcript = await fetch(
'https://api.sociavault.com/v1/scrape/youtube/transcript?videoId=dQw4w9WgXcQ',
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
).then(r => r.json());
| Endpoint | Description |
|---|---|
/twitter/user | Get user profile |
/twitter/tweets | Get user's tweets |
/twitter/tweet | Get single tweet |
/twitter/search | Search tweets |
| Endpoint | Description |
|---|---|
/linkedin/profile | Get person profile |
/linkedin/company | Get company info |
| Endpoint | Description |
|---|---|
/reddit/user | Get user profile |
/reddit/subreddit | Get subreddit info |
/reddit/posts | Get subreddit posts |
/reddit/comments | Get post comments |
/reddit/search | Search posts |
Response Format
All responses follow this structure:
{
"success": true,
"data": {
// Platform-specific data
},
"credits_used": 1,
"credits_remaining": 49
}
Error Response
{
"success": false,
"error": {
"code": "INVALID_USERNAME",
"message": "The username provided does not exist"
}
}
Code Examples
JavaScript/Node.js
require('dotenv').config();
const API_KEY = process.env.SOCIAVAULT_API_KEY;
const API_BASE = 'https://api.sociavault.com/v1/scrape';
async function getTikTokProfile(username) {
const response = await fetch(
`${API_BASE}/tiktok/profile?username=${username}`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
if (!response.ok) {
throw new Error(`API error: ${response.status}`);
}
return response.json();
}
// Usage
const profile = await getTikTokProfile('charlidamelio');
console.log(`${profile.data.nickname}: ${profile.data.follower_count} followers`);
Python
import os
import requests
from dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv('SOCIAVAULT_API_KEY')
API_BASE = 'https://api.sociavault.com/v1/scrape'
def get_tiktok_profile(username):
response = requests.get(
f'{API_BASE}/tiktok/profile',
params={'username': username},
headers={'Authorization': f'Bearer {API_KEY}'}
)
response.raise_for_status()
return response.json()
# Usage
profile = get_tiktok_profile('charlidamelio')
print(f"{profile['data']['nickname']}: {profile['data']['follower_count']} followers")
TypeScript
interface SociaVaultResponse<T> {
success: boolean;
data: T;
credits_used: number;
credits_remaining: number;
}
interface TikTokProfile {
username: string;
nickname: string;
follower_count: number;
following_count: number;
like_count: number;
bio: string;
avatar_url: string;
}
async function getTikTokProfile(username: string): Promise<SociaVaultResponse<TikTokProfile>> {
const response = await fetch(
`https://api.sociavault.com/v1/scrape/tiktok/profile?username=${username}`,
{ headers: { 'Authorization': `Bearer ${process.env.SOCIAVAULT_API_KEY}` } }
);
return response.json();
}
Best Practices
1. Use Environment Variables
Never hardcode your API key:
// Good
const API_KEY = process.env.SOCIAVAULT_API_KEY;
// Bad
const API_KEY = 'sk_live_abc123...'; // Don't do this!
2. Handle Errors Gracefully
async function safeApiCall(endpoint, params) {
try {
const url = new URL(`https://api.sociavault.com/v1/scrape${endpoint}`);
Object.entries(params).forEach(([k, v]) => url.searchParams.set(k, v));
const response = await fetch(url, {
headers: { 'Authorization': `Bearer ${API_KEY}` }
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error?.message || `HTTP ${response.status}`);
}
return await response.json();
} catch (error) {
console.error('API call failed:', error.message);
return null;
}
}
3. Implement Caching
const cache = new Map();
async function cachedApiCall(key, fetchFn, ttlMs = 3600000) {
const cached = cache.get(key);
if (cached && Date.now() - cached.time < ttlMs) {
return cached.data;
}
const data = await fetchFn();
cache.set(key, { data, time: Date.now() });
return data;
}
// Usage
const profile = await cachedApiCall(
`tiktok:${username}`,
() => getTikTokProfile(username),
3600000 // 1 hour cache
);
4. Rate Limiting
async function batchRequests(items, requestFn, delayMs = 500) {
const results = [];
for (const item of items) {
const result = await requestFn(item);
results.push(result);
await new Promise(r => setTimeout(r, delayMs));
}
return results;
}
// Usage
const usernames = ['user1', 'user2', 'user3'];
const profiles = await batchRequests(usernames, getTikTokProfile, 500);
5. Monitor Credit Usage
let totalCreditsUsed = 0;
async function trackCredits(apiCall) {
const result = await apiCall();
if (result.credits_used) {
totalCreditsUsed += result.credits_used;
console.log(`Credits used: ${result.credits_used}, Total: ${totalCreditsUsed}`);
}
if (result.credits_remaining < 10) {
console.warn('Low credits! Consider upgrading.');
}
return result;
}
Common Use Cases
Building an Influencer Database
async function buildInfluencerDatabase(usernames) {
const influencers = [];
for (const username of usernames) {
const profile = await getTikTokProfile(username);
influencers.push({
username: profile.data.username,
name: profile.data.nickname,
followers: profile.data.follower_count,
engagement: calculateEngagement(profile.data),
niche: detectNiche(profile.data.bio)
});
await sleep(500);
}
return influencers;
}
Content Monitoring
async function monitorHashtag(hashtag, interval = 3600000) {
setInterval(async () => {
const data = await fetch(
`${API_BASE}/tiktok/hashtag?name=${hashtag}&count=50`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
).then(r => r.json());
const newPosts = filterNewPosts(data.data.videos);
if (newPosts.length > 0) {
await notifyTeam(newPosts);
}
}, interval);
}
Next Steps
- Explore the Playground: Test endpoints at sociavault.com/dashboard/playground
- Check API Docs: Full documentation at docs.sociavault.com
- Join Discord: Get help from the community
Questions? Email us at support@sociavault.com
Related:
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.