# API for Querying Client Status

{% hint style="info" %}
This feature is currently only available to NaaS partners, enabling efficient querying of the status of multiple clients in bulk.
{% endhint %}

### Prerequisite

Please make sure you obtain `x-ak` & `x-sk` issued by Aethir.&#x20;

### Query Client Online Status

#### **Description**

This interface is used to query whether the client is online.

#### **URL**

<https://app.aethir.com/console-api/v2/client/onLineState>

#### **Method**

POST

#### Rate Limit

Each `x-ak` can make a request every 5 seconds.&#x20;

#### **Request Headers**

<table><thead><tr><th width="136">Header</th><th width="101">Type</th><th width="119">Mandatory</th></tr></thead><tbody><tr><td>x-ak</td><td>string</td><td>Yes</td></tr><tr><td>x-op-token</td><td>string</td><td>Yes</td></tr></tbody></table>

{% hint style="info" %}
**x-ak** is a verification code issued to qualified partner Node Operators.
{% endhint %}

{% hint style="info" %}
**x-op-token** is consists of three parts

<pre><code><strong>x-op-token = header.payload.signature
</strong></code></pre>

* **Header**

  A compact JSON string encoded with base64, representing the header.

  ```json
  {
    "alg": "HS256",  // Encryption algorithm, fixed as HS256
    "typ": "CHK_OP"  // Token type, fixed as CHK_OP
  }
  ```
* **Payload**

  A compact JSON string encoded with base64, representing the payload.

  ```json
  {
    "ak": "",       // Issued to nodeOperator's AK
    "exp": 1,       // Token expiration timestamp in ms, configured by the user
    "ip": "",       // Client IP
    "nonce": 1      // Random number generated by the user
  }
  ```
* **Signature**

  <pre class="language-json"><code class="lang-json"><strong>signature = base64UrlEncode(HmacSHA256.sign(base64UrlEncode(header) + "." + base64UrlEncode(payload), sk))
  </strong></code></pre>

  where `sk`is a verification code issued to qualified partner Node Operators.
  {% endhint %}

#### **Request Body**

The request body is an array of `clientId`, supporting a maximum of 100 IDs.

```json
[
  "clientId1",
  "clientId2",
  ...
]
```

#### **Response**

Possible responses and their corresponding meanings are:

* `HttpStatus 200`: Query successful; the query result is parsed in the `HttpResponseBody`.
* `HttpStatus 400`: The `x-op-token` format is incorrect or [rate limit](#rate-limit) exceeded.
* `HttpStatus 401`: The client needs to regenerate the `x-op-token` and retry the query.

#### **Response Body**

```json
[
  {
    "clientId": "clientId1",
    "onLineState": 1
  }
]
```

| Field       | Type   | Description           |
| ----------- | ------ | --------------------- |
| clientId    | string | Client ID             |
| onLineState | int    | 1: Online, 0: Offline |


---

# 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://docs.aethir.com/checker-guide/how-to-run-checker-nodes/api-for-querying-client-status.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.
