Token Statistics API Reference
This document provides detailed information about the Token Statistics API endpoints, which are designed for synchronizing token-related social media statistics.
Authentication​
All endpoints in the Token Statistics API require:
- Valid API key in the request header
- CLOUD_SCHEDULES role for all operations
Base URL​
/token-stat-jobs
Endpoints​
Sync Social Subscriber Count​
Synchronizes follower/subscriber counts for all configured social media platforms associated with the BLOCK token.
POST /token-stat-jobs/sync-social-subscriber-count
Authentication Requirements​
- API Key
- CLOUD_SCHEDULES role
Response​
Success Response​
{
"status": "success"
}
Failure Response​
{
"status": "failed"
}
Error Responses​
401 Unauthorized
: When the API key is invalid or missing403 Forbidden
: When the request doesn't have the required CLOUD_SCHEDULES role
Usage Examples​
cURL Example​
curl -X POST \
'http://api.example.com/token-stat-jobs/sync-social-subscriber-count' \
-H 'X-API-KEY: your-api-key'
Supported Social Media Platforms​
The API currently supports syncing statistics from the following platforms:
- Twitter: Follower count via the Twitter API
- YouTube: Subscriber count via the YouTube API
- Instagram: Follower count via RapidAPI
- TikTok: Follower count via RapidAPI
Data Structure​
The API maintains the following structure for each social media platform:
{
"type": "TWITTER", // Social media platform type
"username": "BlockBet", // Username on the platform
"currentNumberOfSubscribers": 10000, // Current follower/subscriber count
"prevNumberOfSubscribers": 9500 // Previous follower/subscriber count
}
This structure allows for tracking both current counts and growth over time.
Operational Considerations​
Rate Limiting​
Be aware of rate limits on the underlying social media APIs:
- Twitter API has strict rate limits that vary by API tier
- YouTube API has a daily quota
- RapidAPI endpoints for Instagram and TikTok have their own rate limits
Scheduling Recommendations​
This endpoint is designed to be called on a regular schedule. Recommended frequencies:
- Daily: For standard tracking of social media growth
- Weekly: For less frequently updated accounts
- Never more than hourly: To avoid hitting rate limits on underlying APIs
Error Handling​
The endpoint continues processing even if one or more social media platforms fail to return data. This ensures partial updates can still occur even if one API is temporarily unavailable.
Security Considerations​
- API Key Protection: Keep your API key secure and don't expose it in client-side code
- Role Assignment: Ensure that only appropriate services have the CLOUD_SCHEDULES role
- Access Control: This endpoint should only be accessed by authorized internal systems