Create Twitter User Following Monitor - API Reference
Creates a new monitor to receive alerts when the target Twitter user follows someone.
POST https://api.socialdata.tools/monitors/user-following
Headers
Authorization string required
Authorization Bearer header containing your SocialData API key
Example: Bearer YOUR_API_KEY
Body
user_id integer required
User ID of the target user. Required if user_screen_name
not provided
Example: 1493446837214187523
user_screen_name string required
Username of the target user without @. Required if user_id
not provided
Example: elonmusk
webhook_url string optional
Monitor-specific webhook URL that will override your global webhook URL. Not required
Example: https://my-website.com/webhook
Code Examples
curl -X POST "https://api.socialdata.tools/monitors/user-following" -H 'Authorization: Bearer YOUR_API_KEY' -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{"user_id": 1493446837214187523}'
const API_KEY = 'YOUR_API_KEY_HERE';const userId = 1493446837214187523;
fetch('https://api.socialdata.tools/monitors/user-following', { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: JSON.stringify({ user_id: userId })}).then(response => response.json()).then(response => console.log(response)).catch(err => console.error(err));
import requests
API_KEY = 'YOUR_API_KEY_HERE'user_id = 1493446837214187523
url = 'https://api.socialdata.tools/monitors/user-following'
headers = { 'Authorization': f'Bearer {API_KEY}', 'Content-Type': 'application/json', 'Accept': 'application/json'}
payload = {'user_id': user_id}
response = requests.post(url, json=payload, headers=headers)
if response.status_code == 200: data = response.json() print(data)else: print(f"Error: {response.status_code}") print(response.text)
$API_KEY = 'YOUR_API_KEY_HERE';$user_id = 1493446837214187523;
$url = "https://api.socialdata.tools/monitors/user-following";
$ch = curl_init();
curl_setopt_array($ch, [ CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode(['user_id' => $user_id]), CURLOPT_HTTPHEADER => [ "Authorization: Bearer $API_KEY", "Content-Type: application/json", "Accept: application/json" ]]);
$response = curl_exec($ch);$data = json_decode($response, true);print_r($data);
curl_close($ch);
Example Responses
{ "status": "success", "data": { "id": "01jm2569nf8jnn50zd8302vnpr", "created_at": "2025-02-14T11:58:33.000000Z", "monitor_type": "user_following", "webhook_url": null, "parameters": { "user_screen_name": "MarioNawfal", "user_name": "Mario Nawfal", "user_id_str": "1319287761048723458" } }}
{ "status": "error", "message": "Insufficient balance"}
{ "status": "error", "message": "Failed to fetch data from Twitter"}
Response Codes
- 200 OK - request succeeded
- 402 Payment Required - not enough credits to perform this request
- 422 Unprocessable Content - validation failed (e.g. one of the required parameters was not provided)
- 500 Internal Error - API internal error, typically means that SocialData API failed to obtain the requested information and you should try again later