Skip to main content
POST
/
api
/
v1
/
videos
/
track
Track Video
curl --request POST \
  --url https://api.example.com/api/v1/videos/track \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <x-api-key>' \
  --data '
{
  "video_link": "<string>",
  "duration_days": 123
}
'
{
  "id": "<string>",
  "job_id": "<string>",
  "video_link": "<string>",
  "platform": "<string>",
  "status": "<string>",
  "monitoring_duration_days": 123,
  "days_remaining": 123,
  "estimated_cost": 123,
  "created_at": "<string>"
}

Endpoint

POST https://contentstats.io/api/v1/videos/track
Start tracking a video from TikTok, YouTube, Instagram, or Twitter/X. We’ll collect hourly snapshots for the duration you specify.

Authentication

X-API-Key
string
required
Your API key from the dashboard

Request Body

Full URL of the video to track. Must be a public video.Supported formats:
  • TikTok: https://www.tiktok.com/@user/video/123
  • YouTube: https://www.youtube.com/watch?v=VIDEO_ID
  • Instagram: https://www.instagram.com/p/POST_ID/
  • Twitter: https://twitter.com/user/status/123
duration_days
integer
required
Number of days to track the video (1-30)Cost calculation:
Duration (days) × 24 hours × $0.015 per snapshot
Example: 7 days = 168 snapshots = $2.52

Response

id
string
Unique identifier for this tracked video
job_id
string
External job ID for tracking
The video URL being tracked
platform
string
Detected platform: tiktok, youtube, instagram, or twitter
status
string
Current status: monitoring, completed, paused, error, cancelled
monitoring_duration_days
integer
Total days video will be tracked
days_remaining
number
Days remaining in tracking period
estimated_cost
number
Estimated total cost in USD
created_at
string
ISO 8601 timestamp when tracking started

Code Examples

curl -X POST https://contentstats.io/api/v1/videos/track \
  -H "Content-Type: application/json" \
  -H "X-API-Key: cs_live_YOUR_KEY" \
  -d '{
    "video_link": "https://www.tiktok.com/@user/video/7234567890",
    "duration_days": 7
  }'

Response Example

{
  "id": "cm5abc123def",
  "job_id": "job_xyz789",
  "video_link": "https://www.tiktok.com/@user/video/7234567890",
  "platform": "tiktok",
  "status": "monitoring",
  "monitoring_duration_days": 7,
  "days_remaining": 7,
  "estimated_cost": 2.52,
  "created_at": "2024-01-29T10:00:00.000Z"
}

Error Responses

400 Bad Request

Invalid request parameters:
{
  "error": "Invalid request",
  "details": [
    {
      "field": "video_link",
      "message": "Invalid URL format"
    }
  ]
}
Common causes:
  • Invalid video URL format
  • Duration outside 1-30 days range
  • Missing required fields

401 Unauthorized

{
  "error": "API key required"
}
Missing or invalid X-API-Key header.

402 Payment Required

{
  "error": "Insufficient balance",
  "balance": 0.50,
  "estimated_cost": 2.52,
  "required": 2.02
}
Not enough credit to start tracking. Add credits.

404 Not Found

{
  "error": "Video not found or is private"
}
Video is private, deleted, or URL is invalid.

500 Internal Server Error

{
  "error": "Failed to start monitoring - invalid response from tracking API"
}
Platform error or temporary issue. Retry in a few minutes.

What Happens Next

After starting tracking:
  1. First snapshot collected within 60 minutes
  2. Hourly snapshots continue for the specified duration
  3. Balance charged $0.015 per snapshot
  4. Email notification when tracking completes

Supported Platforms

URL formats:
https://www.tiktok.com/@username/video/1234567890
https://vm.tiktok.com/abc123/
https://www.tiktok.com/t/abc123/
Metrics tracked:
  • Views
  • Likes
  • Comments
  • Shares
  • Saves

Best Practices

Verify sufficient balance before tracking:
const usage = await fetch('https://contentstats.io/api/v1/usage', {
  headers: { 'X-API-Key': apiKey }
}).then(r => r.json());

const estimatedCost = duration_days * 24 * 0.015;

if (usage.balance_usd < estimatedCost) {
  throw new Error('Insufficient balance');
}
Validate video URLs before sending:
function isValidVideoUrl(url) {
  const patterns = [
    /^https:\/\/(www\.)?tiktok\.com\/@[\w.-]+\/video\/\d+/,
    /^https:\/\/(www\.)?youtube\.com\/watch\?v=[\w-]+/,
    /^https:\/\/(www\.)?instagram\.com\/(p|reel)\/[\w-]+/,
    /^https:\/\/(twitter|x)\.com\/\w+\/status\/\d+/
  ];
  
  return patterns.some(pattern => pattern.test(url));
}
Save the returned id to retrieve data later:
const result = await trackVideo(url, 7);

// Store in database
await db.trackedVideos.create({
  contentStatsId: result.id,
  videoUrl: url,
  platform: result.platform,
  startedAt: result.created_at
});
Check if already tracking before creating new job:
// List existing videos
const existing = await fetch(
  'https://contentstats.io/api/v1/videos?platform=tiktok',
  { headers: { 'X-API-Key': apiKey } }
).then(r => r.json());

// Check if URL already tracked
const alreadyTracking = existing.videos.find(
  v => v.video_link === newUrl && v.status === 'monitoring'
);

if (alreadyTracking) {
  return alreadyTracking; // Reuse existing
}

Next Steps