createChatInviteLink
Crea un enlace de invitación.
Devuelve: Si la llamada tiene éxito, devuelve ChatInviteLink.
Parámetros
| Parámetro | Tipo | Obligatorio | Descripción |
|---|---|---|---|
chat_id | Integer or String | Sí | ID del chat |
name | String | Opcional | Nombre del enlace |
expire_date | Integer | Opcional | Marca de tiempo Unix de expiración |
member_limit | Integer | Opcional | Máximo de usuarios (0 = ilimitado) |
creates_join_request | Boolean | Opcional | Requerir aprobación de las solicitudes para unirse |
Ejemplo de solicitud
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/createChatInviteLink" \
-H "Content-Type: application/json" \
-d '{"chat_id":123456789}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/createChatInviteLink",
json={
"chat_id": 123456789
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/createChatInviteLink`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"chat_id": 123456789
}),
});
console.log(await res.json());
Guía paso a paso: Cómo crear un bot en Telegram paso a paso: de BotFather a tu primer mensaje
Métodos relacionados
getChatObtiene información del chat.getChatMemberObtiene información de un miembro del chat.getChatMemberCountDevuelve la cantidad de miembros del chat.getChatAdministratorsDevuelve la lista de administradores del chat.setChatTitleEstablece el título del chat.setChatDescriptionEstablece la descripción del chat.setChatPhotoEstablece la foto del chat.deleteChatPhotoElimina la foto del chat.setChatPermissionsEstablece los permisos del chat.leaveChatSale de un chat.exportChatInviteLinkExporta el enlace de invitación principal del chat.editChatInviteLinkEdita un enlace de invitación.