GetXAPI
Users

Unfollow User

Unfollow a user on Twitter/X programmatically via API. $0.001 per call. GetXAPI unfollow user endpoint with username or user_id targeting.

POST/twitter/user/unfollow

This endpoint costs $0.001 per API call.

Unfollows a user on behalf of the auth_token owner. Identify the target by either user_id or username.

Request Body

FieldTypeRequiredDescription
auth_tokenstringYesUser's auth token
user_idstringConditionalNumeric id of the account to unfollow. Provide either user_id or username
usernamestringConditionalHandle (without @) of the account to unfollow. Provide either user_id or username
proxystringNoProxy URL (http://, https://, socks5://, or socks4://)

Provide one of user_id or username.

Notes

  • Idempotent — unfollowing an account you don't follow succeeds without error.

Response (200)

{
  "status": "success",
  "msg": "User unfollowed successfully",
  "data": {
    "userId": "11348282",
    "userName": "NASA",
    "name": "NASA",
    "following": false
  }
}

Error Responses

400 - Missing target

{
  "error": "Provide user_id or username of the account to unfollow"
}

404 - User not found

{
  "error": "User not found"
}

Examples

curl -X POST "https://api.getxapi.com/twitter/user/unfollow" \
  -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/unfollow", {
  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/unfollow",
    headers={"Authorization": "Bearer API_KEY"},
    json={
        "auth_token": "your_auth_token",
        "username": "nasa",
    },
)
print(response.json()["data"])

Unfollow by user_id

curl -X POST "https://api.getxapi.com/twitter/user/unfollow" \
  -H "Authorization: Bearer API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "auth_token": "your_auth_token",
    "user_id": "11348282"
  }'

On this page