> For the complete documentation index, see [llms.txt](https://relationlabs.gitbook.io/relation-one-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://relationlabs.gitbook.io/relation-one-api/js-sdk/im-js-sdk/static-method.md).

# Static Method

**RelationIM.getRelationToken (acquire a unifiedAuthToken)**

```javascript
RelationIM.getRelationToken(addressAuthToken, APIKEY)
```

|     **Config options**     |                      **Description**                      | **Default** |
| :------------------------: | :-------------------------------------------------------: | :---------: |
| addressAuthToken: *string* | Required field. The token is acquired via authByMetamask. |             |
|      apiKey: *string*      |       Required field. It is acquired from the Admin.      |             |

Note: In the return message, `token` refers to the account's `unifiedAuthToken` in `relation`. If there is no such account, one will be registered by default.

**RelationIM.init(You need to initialize an API before calling it.)**

```javascript
RelationIM.init({configOptions})
```

| **Config options** |                             **Description**                            | **Default** |
| :----------------: | :--------------------------------------------------------------------: | :---------: |
|   token: *string*  |                Required. The unifiedAuthToken of a user                |             |
|  apiKey: *string*  |                   Required. Acquired from the Admin.                   |             |
| connect: *boolean* | Optional. Whether to establish a socket connection to receive message. |    false    |
| refresh: *boolean* |    Optional. Whether to initialize the interface again(refresh it).    |    false    |

Note: When using `init` to initialize the interface, you can use `connect` to specify whether to connect to `socket`. The parameter `refresh` means whether to refresh the `RelationIM` instance.

**RelationIM.getInstance(to acquire the `RelationIM` instance already initialized.)**

```javascript
RelationIM.getInstance()
```

Note: Normally you only need one `RelationIM` instance. However, you may frequently call common APIs. To avoid redunant initiations of `RelationIM` and `socket , we suggest you manually specify a static method` RelationIM.getInstance`where needed so that you can acquire the`RelationIM\` instance already initialized.
