> ## Documentation Index
> Fetch the complete documentation index at: https://generaltranslation.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Inicio rápido

> Obtén las listas de seguidores y de cuentas seguidas, y gestiona las relaciones de seguimiento

export const Button = ({href, children}) => {
  return <div className="not-prose group">
    <a href={href}>
      <button className="flex items-center space-x-2.5 py-1 px-4 bg-primary-dark dark:bg-white text-white dark:text-gray-950 rounded-full group-hover:opacity-[0.9] font-medium">
        <span>
          {children}
        </span>
        <svg width="3" height="24" viewBox="0 -9 3 24" class="h-6 rotate-0 overflow-visible"><path d="M0 0L3 3L0 6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>
      </button>
    </a>
  </div>;
};

Esta guía te explica cómo recuperar las listas de seguidores y seguidos, y cómo gestionar los seguimientos.

<Note>
  **Requisitos previos**

  Antes de empezar, necesitarás:

  * Una [cuenta de desarrollador](https://developer.x.com/en/portal/petition/essential/basic-info) con una App aprobada
  * El Bearer Token de tu App (para consultas)
  * El User Access Token (para gestionar seguimientos)
</Note>

***

<div id="get-a-users-followers">
  ## Obtener los seguidores de un usuario
</div>

Obtén la lista de usuarios que siguen a un usuario específico:

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl "https://api.x.com/2/users/2244994945/followers?\
  user.fields=username,verified,public_metrics&\
  max_results=100" \
    -H "Authorization: Bearer $BEARER_TOKEN"
  ```

  ```python Python SDK theme={null}
  from xdk import Client

  client = Client(bearer_token="YOUR_BEARER_TOKEN")

  # Obtener los seguidores de un usuario con paginación
  for page in client.users.get_followers(
      "2244994945",
      user_fields=["username", "verified", "public_metrics"],
      max_results=100
  ):
      for user in page.data:
          print(f"{user.username} - Seguidores: {user.public_metrics.followers_count}")
  ```

  ```javascript JavaScript SDK theme={null}
  import { Client } from "@xdevplatform/xdk";

  const client = new Client({ bearerToken: "YOUR_BEARER_TOKEN" });

  // Obtener los seguidores de un usuario con paginación
  const paginator = client.users.getFollowers("2244994945", {
    userFields: ["username", "verified", "public_metrics"],
    maxResults: 100,
  });

  for await (const page of paginator) {
    page.data?.forEach((user) => {
      console.log(`${user.username} - Seguidores: ${user.public_metrics?.followers_count}`);
    });
  }
  ```
</CodeGroup>

<div id="response">
  ### Respuesta
</div>

```json theme={null}
{
  "data": [
    {
      "id": "1234567890",
      "name": "Developer",
      "username": "dev_user",
      "verified": false,
      "public_metrics": {
        "followers_count": 500,
        "following_count": 200,
        "tweet_count": 1500
      }
    }
  ],
  "meta": {
    "result_count": 1,
    "next_token": "abc123"
  }
}
```

***

<div id="get-who-a-user-follows">
  ## Obtener a quién sigue un usuario
</div>

Recupera la lista de usuarios que sigue un usuario específico:

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl "https://api.x.com/2/users/2244994945/following?\
  user.fields=username,verified&\
  max_results=100" \
    -H "Authorization: Bearer $BEARER_TOKEN"
  ```

  ```python Python SDK theme={null}
  from xdk import Client

  client = Client(bearer_token="YOUR_BEARER_TOKEN")

  # Obtener los usuarios que sigue un usuario
  for page in client.users.get_following(
      "2244994945",
      user_fields=["username", "verified"],
      max_results=100
  ):
      for user in page.data:
          print(f"{user.username} - Verified: {user.verified}")
  ```

  ```javascript JavaScript SDK theme={null}
  import { Client } from "@xdevplatform/xdk";

  const client = new Client({ bearerToken: "YOUR_BEARER_TOKEN" });

  // Obtener los usuarios que sigue un usuario
  const paginator = client.users.getFollowing("2244994945", {
    userFields: ["username", "verified"],
    maxResults: 100,
  });

  for await (const page of paginator) {
    page.data?.forEach((user) => {
      console.log(`${user.username} - Verified: ${user.verified}`);
    });
  }
  ```
</CodeGroup>

***

<div id="follow-a-user">
  ## Seguir a un usuario
</div>

Sigue a un usuario en nombre del usuario autenticado:

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl -X POST "https://api.x.com/2/users/123456789/following" \
    -H "Authorization: Bearer $USER_ACCESS_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"target_user_id": "2244994945"}'
  ```

  ```python Python SDK theme={null}
  from xdk import Client
  from xdk.oauth1_auth import OAuth1

  oauth1 = OAuth1(
      api_key="YOUR_API_KEY",
      api_secret="YOUR_API_SECRET",
      access_token="YOUR_ACCESS_TOKEN",
      access_token_secret="YOUR_ACCESS_TOKEN_SECRET"
  )

  client = Client(auth=oauth1)

  # Seguir a un usuario
  response = client.users.follow(
      source_user_id="123456789",
      target_user_id="2244994945"
  )
  print(f"Siguiendo: {response.data.following}")
  ```

  ```javascript JavaScript SDK theme={null}
  import { Client, OAuth1 } from "@xdevplatform/xdk";

  const oauth1 = new OAuth1({
    apiKey: "YOUR_API_KEY",
    apiSecret: "YOUR_API_SECRET",
    accessToken: "YOUR_ACCESS_TOKEN",
    accessTokenSecret: "YOUR_ACCESS_TOKEN_SECRET",
  });

  const client = new Client({ oauth1 });

  // Seguir a un usuario
  const response = await client.users.follow("123456789", {
    targetUserId: "2244994945",
  });
  console.log(`Siguiendo: ${response.data?.following}`);
  ```
</CodeGroup>

<div id="response">
  ### Respuesta
</div>

```json theme={null}
{
  "data": {
    "following": true,
    "pending_follow": false
  }
}
```

<Note>
  Si la cuenta de destino está protegida, `pending_follow` será `true` hasta que se apruebe la solicitud de seguimiento.
</Note>

***

<div id="unfollow-a-user">
  ## Dejar de seguir a un usuario
</div>

Deja de seguir a un usuario en nombre del usuario autenticado:

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl -X DELETE "https://api.x.com/2/users/123456789/following/2244994945" \
    -H "Authorization: Bearer $USER_ACCESS_TOKEN"
  ```

  ```python Python SDK theme={null}
  from xdk import Client
  from xdk.oauth1_auth import OAuth1

  oauth1 = OAuth1(
      api_key="YOUR_API_KEY",
      api_secret="YOUR_API_SECRET",
      access_token="YOUR_ACCESS_TOKEN",
      access_token_secret="YOUR_ACCESS_TOKEN_SECRET"
  )

  client = Client(auth=oauth1)

  # Dejar de seguir a un usuario
  response = client.users.unfollow(
      source_user_id="123456789",
      target_user_id="2244994945"
  )
  print(f"Following: {response.data.following}")
  ```

  ```javascript JavaScript SDK theme={null}
  import { Client, OAuth1 } from "@xdevplatform/xdk";

  const oauth1 = new OAuth1({
    apiKey: "YOUR_API_KEY",
    apiSecret: "YOUR_API_SECRET",
    accessToken: "YOUR_ACCESS_TOKEN",
    accessTokenSecret: "YOUR_ACCESS_TOKEN_SECRET",
  });

  const client = new Client({ oauth1 });

  // Dejar de seguir a un usuario
  const response = await client.users.unfollow("123456789", "2244994945");
  console.log(`Following: ${response.data?.following}`);
  ```
</CodeGroup>

<div id="response">
  ### Respuesta
</div>

```json theme={null}
{
  "data": {
    "following": false
  }
}
```

***

<div id="common-parameters">
  ## Parámetros comunes
</div>

| Parámetro          | Descripción                                               |
| :----------------- | :-------------------------------------------------------- |
| `max_results`      | Resultados por página (1-1000; valor predeterminado: 100) |
| `pagination_token` | Token de la siguiente página                              |
| `user.fields`      | Campos de usuario adicionales                             |
| `expansions`       | Objetos relacionados que se incluirán                     |

***

<div id="next-steps">
  ## Próximos pasos
</div>

<CardGroup cols={2}>
  <Card title="Búsqueda de usuarios" icon="user" href="/es/x-api/users/lookup/introduction">
    Consulta perfiles de usuario
  </Card>

  <Card title="Bloqueos" icon="ban" href="/es/x-api/users/blocks/introduction">
    Bloquea y desbloquea usuarios
  </Card>

  <Card title="Silenciar" icon="volume-xmark" href="/es/x-api/users/mutes/introduction">
    Silencia y deja de silenciar usuarios
  </Card>

  <Card title="Referencia de la API" icon="code" href="/es/x-api/users/followers-lookup">
    Documentación completa del endpoint
  </Card>
</CardGroup>
