# Get chat info, leave chat

## Get chat info

To get chat info, use `.getChat` **answer/api method**

{% hint style="info" %}
.getChat answer/api method takes argument: chat id you want to get (optional in answer method, current chat id by default)

If you want to know what arguments an API method takes, see the IDE hint
{% endhint %}

{% hint style="success" %}
Returns [IChat](https://core.telegram.org/bots/api#chat) on success
{% endhint %}

## Get chat admins

To get chat administrators, use `.getChatAdmins` **answer/api method**

{% hint style="info" %}
.getChatAdmins answer/api method takes argument: chat id you want to get admins to (optional in answer method, current chat id by default)

If you want to know what arguments an API method takes, see the IDE hint
{% endhint %}

{% hint style="success" %}
Returns **array of** [ChatMember](https://core.telegram.org/bots/api#chatmember) on success
{% endhint %}

## Get chat member count

To get chat member count, use `.getChatMemberCount` **answer/api method**

{% hint style="info" %}
.getChatMemberCount answer/api method takes argument: chat id you want to get member count to (optional in answer method, current chat id by default)

If you want to know what arguments an API method takes, see the IDE hint
{% endhint %}

{% hint style="success" %}
Returns **number** on success
{% endhint %}

## Get chat member

To get chat member, use `.getChatMember` **answer/api method**

#### .getChatMember answer method take arguments:

<table><thead><tr><th width="164.33333333333331" data-type="number">Argument</th><th>Description</th><th>Required</th></tr></thead><tbody><tr><td>1</td><td>User id you want to get</td><td>Optional. Current user id by default</td></tr><tr><td>2</td><td>Chat id you want to get member to</td><td>Optional. Current chat id by default</td></tr></tbody></table>

{% hint style="info" %}
You can read more about subscription checking [here](/nestgram/api-reference/check-user-subscription.md)

If you want to know what arguments an API method takes, see the IDE hint
{% endhint %}

{% hint style="success" %}
Returns [ChatMember](https://core.telegram.org/bots/api#chatmember) on success
{% endhint %}

## Leave chat

You can leave chat using **Leave class-method** or `.leave` **answer/api method**

{% hint style="info" %}
Leave class-method or .leave answer/api method takes argument: chat id you want to leave to as argument (optional in answer method, current chat id by default)

If you want to know what arguments an API method takes, see the IDE hint
{% endhint %}

{% code title="app.controller.ts" %}

```typescript
import { Controller, Leave, OnCommand } from 'nestgram';
import { AppService } from './app.service';

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @OnCommand('leave')
  leaveChat() {
    return new Leave();
  }
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://degreetpro.gitbook.io/nestgram/api-reference/get-chat-info-leave-chat.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
