Users
Follow User
Follow a user on Twitter/X programmatically via API. $0.001 per call. GetXAPI follow user endpoint with username or user_id targeting.
POST
/twitter/user/followThis endpoint costs $0.001 per API call.
Follows a user on behalf of the auth_token owner. Identify the target by either user_id or username.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
auth_token | string | Yes | User's auth token |
user_id | string | Conditional | Numeric id of the account to follow. Provide either user_id or username |
username | string | Conditional | Handle (without @) of the account to follow. Provide either user_id or username |
proxy | string | No | Proxy URL (http://, https://, socks5://, or socks4://) |
Provide one of user_id or username.
Notes
- Idempotent — following an already-followed account succeeds without error.
- For protected accounts, the follow is queued: the response returns
followRequestSent: trueandfollowing: falseuntil the owner approves.
Response (200)
{
"status": "success",
"msg": "User followed successfully",
"data": {
"userId": "11348282",
"userName": "NASA",
"name": "NASA",
"following": true,
"followRequestSent": false,
"protected": false
}
}Error Responses
400 - Missing target
{
"error": "Provide user_id or username of the account to follow"
}404 - User not found
{
"error": "User not found"
}Examples
curl -X POST "https://api.getxapi.com/twitter/user/follow" \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-d '{
"auth_token": "your_auth_token",
"username": "nasa"
}'const response = await fetch("https://api.getxapi.com/twitter/user/follow", {
method: "POST",
headers: {
Authorization: "Bearer API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
auth_token: "your_auth_token",
username: "nasa",
}),
});
const data = await response.json();
console.log(data.data);import requests
response = requests.post(
"https://api.getxapi.com/twitter/user/follow",
headers={"Authorization": "Bearer API_KEY"},
json={
"auth_token": "your_auth_token",
"username": "nasa",
},
)
print(response.json()["data"])Follow by user_id
curl -X POST "https://api.getxapi.com/twitter/user/follow" \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-d '{
"auth_token": "your_auth_token",
"user_id": "11348282"
}'