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
ct0stringNoOptional current CSRF token cookie. When provided with twid, skips server-side credential resolution.
twidstringNoOptional current user ID cookie, for example u=1234567890. Must be provided with ct0.
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

  • If you already have current ct0 and twid, send both to skip the extra server-side credential bootstrap from auth_token. If either one is omitted, the server resolves them from auth_token as before. Stale or invalid supplied values are not validated upfront and may fail on the actual Twitter action instead of returning an early 401.
  • 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