Refresh Content
Guide for refreshing X (Twitter) and YouTube content via admin endpoints.
Instructions
- •
Check current cache status:
- •Read
src/lib/db.tsforgetLastFetchedAt*functions - •Query database for last fetch timestamps
- •Read
- •
Available refresh endpoints (POST requests):
X Posts:
bashcurl -X POST http://localhost:3000/api/admin/refresh/x-posts
X Mentions:
bashcurl -X POST http://localhost:3000/api/admin/refresh/x-mentions
YouTube Videos:
bashcurl -X POST http://localhost:3000/api/admin/refresh/youtube-videos
Video Summaries (requires OpenAI):
bashcurl -X POST http://localhost:3000/api/admin/refresh/video-summaries
- •
For production, use the deployed URL instead of localhost
- •
Check responses for success/count:
json{ "success": true, "message": "Refreshed 15 posts", "count": 15 }
Data Flow
- •Admin triggers POST to refresh endpoint
- •API calls external source (XAI for X, YouTube API)
- •Data parsed and validated
- •Upserted to database with
fetched_attimestamp - •Frontend fetches from
/api/x/postsor/api/youtube/videos
Troubleshooting
No data returned:
- •Check API keys in
.env.local:XAI_API_KEY,YOUTUBE_API_KEY - •Verify rate limits not exceeded
JSON parse errors (X posts):
- •XAI sometimes returns malformed JSON
- •Check
src/lib/xai.tsfor sanitization logic
YouTube filtering:
- •Shorts (<=180s) and livestreams are automatically excluded
- •See
src/lib/youtube.tsfor filter logic
Examples
- •"Refresh the X posts feed"
- •"Sync latest YouTube videos"
- •"Check when content was last updated"
Guardrails
- •Do NOT purge data without explicit confirmation
- •Run one refresh at a time to avoid rate limits
- •Check environment variables are set before calling endpoints
- •Never expose API keys in logs or responses