# About Query Channel

**URL:** https://forum.social.plus/t/about-query-channel/1274
**Category:** General
**Created:** [April 19, 2024, 1:40am UTC](https://forum.social.plus/t/about-query-channel/1274 "2024-04-19T01:40:26Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![hossam](https://avatars.discourse-cdn.com/v4/letter/h/e8c25b/32.png) [@hossam](https://forum.social.plus/u/hossam)
#### Post date: [April 19, 2024, 1:40am UTC](https://forum.social.plus/t/about-query-channel/1274/1 "2024-04-19T01:40:26Z")

</div>

Hello I used your API services and want to get the channel with last active how can make it ?

I will give you my scenario that I have chat in my app and want if the some one send message to me the channel of this one to be the first channel I retrieve and the first one to be second and so on ?

---

<div class="post-metadata">

### Author: ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)
#### Post date: [April 19, 2024, 4:25am UTC](https://forum.social.plus/t/about-query-channel/1274/2 "2024-04-19T04:25:39Z")

</div>

@hossam For the use case you described, we recommend using our SDK. Typically, when you query channels with our API, they are sorted by ‘last active’ by default. Based on your use case, you will need to use real-time events, which our SDK supports as documented here: [Amity SDK - Realtime Events](https://docs.amity.co/amity-sdk/core-concepts/realtime-events).

---

<div class="post-metadata">

### Author: ![hossam](https://avatars.discourse-cdn.com/v4/letter/h/e8c25b/32.png) [@hossam](https://forum.social.plus/u/hossam)
#### Post date: [April 19, 2024, 11:15pm UTC](https://forum.social.plus/t/about-query-channel/1274/3 "2024-04-19T23:15:22Z")

</div>

Can I use the SDK for chat only ?

I have every thing as API with you so can I use the SDK for the chat only ?

---

<div class="post-metadata">

### Author: ![hossam](https://avatars.discourse-cdn.com/v4/letter/h/e8c25b/32.png) [@hossam](https://forum.social.plus/u/hossam)
#### Post date: [April 22, 2024, 8:30am UTC](https://forum.social.plus/t/about-query-channel/1274/4 "2024-04-22T08:30:21Z")

</div>

Hello I want to use Chat SDK and I used every thing using your API and the authentication using API , every thing using API and I want to use only the Chat SDK to get the ChatRealTime so how can make it please

---

<div class="post-metadata">

### Author: ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)
#### Post date: [April 22, 2024, 9:27am UTC](https://forum.social.plus/t/about-query-channel/1274/5 "2024-04-22T09:27:47Z")

</div>

Hello @hossam ,

To integrate ChatRealTime using our Chat SDK alongside your existing API for authentication, please follow these steps:

1. **Install the Chat SDK:** Refer to our [Installation and Authentication Guide](https://docs.amity.co/getting-started/installation-and-authentication) for detailed instructions on setting up the SDK.
2. **Set Up Authentication:** Ensure your authentication setup aligns with our API as detailed in the guide.
3. **Implement ChatRealTime:** For instructions on using real-time chat features, visit our [Chat SDK Documentation](https://docs.amity.co/amity-sdk/chat).

---

<div class="post-metadata">

### Author: ![hossam](https://avatars.discourse-cdn.com/v4/letter/h/e8c25b/32.png) [@hossam](https://forum.social.plus/u/hossam)
#### Post date: [April 22, 2024, 9:50am UTC](https://forum.social.plus/t/about-query-channel/1274/6 "2024-04-22T09:50:09Z")

</div>

So Thank you for help , please can you provide me the steps after this

```auto
import { API_REGIONS, Client, enableCache } from '@amityco/ts-sdk';

const apiKey = 'b0e9ec5d3eddf5641f328d4a555b168ed20c8bb0bf356b7a';

const client = Client.createClient(apiKey, API_REGIONS.EU);

enableCache();

```

And when log the response in the SDK It return

```auto
{"accessTokenExpiryWatcher": [Function accessTokenExpiryWatcher], "apiKey": "b0e9ec5d3eddf5641f328d4a555b168ed20c8bb0bf356b7a", "cache": {"data": {}}, "emitter": {"all": Map {}, "emit": [Function emit], "off": [Function off], "on": [Function on]}, "getFeedSettings": [Function getFeedSettings], "getMarkerSyncConsistentMode": [Function getMarkerSyncConsistentMode], "getMessagePreviewSetting": [Function getMessagePreviewSetting], "getSocialSettings": [Function getSocialSettings], "hasPermission": [Function hasPermission$1], "http": [Function wrap], "isUnreadCountEnabled": false, "log": [Function print], "mqtt": {"connect": [Function connect], "connected": false, "disconnect": [Function disconnect], "off": [Function off], "on": [Function on], "once": [Function once], "removeAllListeners": [Function removeAllListeners], "subscribe": [Function subscribe], "unsubscribe": [Function unsubscribe]}, "sessionHandler": undefined, "sessionState": "notLoggedIn", "use": [Function use], "validateTexts": [Function validateTexts], "validateUrls": [Function validateUrls], "version": "v6.22.0-cjs", "ws": {"_callbacks": {"$connect": [Array], "$connecting": [Array], "$disconnect": [Array]}, "acks": {}, "connected": false, "disconnected": true, "flags": {}, "ids": 0, "io": {"_randomizationFactor": 0.5, "_reconnection": true, "_reconnectionAttempts": Infinity, "_reconnectionDelay": 2000, "_reconnectionDelayMax": 5000, "_timeout": 20000, "autoConnect": false, "backoff": [Backoff], "connecting": [Array], "decoder": [Decoder], "encoder": [Encoder], "encoding": false, "lastPing": null, "nsps": [Object], "opts": [Object], "packetBuffer": [Array], "readyState": "closed", "subs": [Array], "uri": "https://api.sg.amity.co"}, "json": [Circular], "nsp": "/", "receiveBuffer": [], "sendBuffer": []}}

```

But I want to connect with EU and I put this already so why?  
and how can connect with API to make login ?

@amitysupport

---

<div class="post-metadata">

### Author: ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)
#### Post date: [April 22, 2024, 10:35am UTC](https://forum.social.plus/t/about-query-channel/1274/7 "2024-04-22T10:35:24Z")

</div>

@hossam Regarding the issue you encountered, please check this link for more information: [Create User - Amity SDK Core Concepts](https://docs.amity.co/amity-sdk/core-concepts/user/create-user).

---

<div class="post-metadata">

### Author: ![hossam](https://avatars.discourse-cdn.com/v4/letter/h/e8c25b/32.png) [@hossam](https://forum.social.plus/u/hossam)
#### Post date: [April 22, 2024, 11:26am UTC](https://forum.social.plus/t/about-query-channel/1274/8 "2024-04-22T11:26:41Z")

</div>

I think you don’t answer my question I told you when I trying to connect to the SDK I got that

```auto
{"accessTokenExpiryWatcher": [Function accessTokenExpiryWatcher], "apiKey": "b0e9ec5d3eddf5641f328d4a555b168ed20c8bb0bf356b7a", "cache": {"data": {}}, "emitter": {"all": Map {}, "emit": [Function emit], "off": [Function off], "on": [Function on]}, "getFeedSettings": [Function getFeedSettings], "getMarkerSyncConsistentMode": [Function getMarkerSyncConsistentMode], "getMessagePreviewSetting": [Function getMessagePreviewSetting], "getSocialSettings": [Function getSocialSettings], "hasPermission": [Function hasPermission$1], "http": [Function wrap], "isUnreadCountEnabled": false, "log": [Function print], "mqtt": {"connect": [Function connect], "connected": false, "disconnect": [Function disconnect], "off": [Function off], "on": [Function on], "once": [Function once], "removeAllListeners": [Function removeAllListeners], "subscribe": [Function subscribe], "unsubscribe": [Function unsubscribe]}, "sessionHandler": undefined, "sessionState": "notLoggedIn", "use": [Function use], "validateTexts": [Function validateTexts], "validateUrls": [Function validateUrls], "version": "v6.22.0-cjs", "ws": {"_callbacks": {"$connect": [Array], "$connecting": [Array], "$disconnect": [Array]}, "acks": {}, "connected": false, "disconnected": true, "flags": {}, "ids": 0, "io": {"_randomizationFactor": 0.5, "_reconnection": true, "_reconnectionAttempts": Infinity, "_reconnectionDelay": 2000, "_reconnectionDelayMax": 5000, "_timeout": 20000, "autoConnect": false, "backoff": [Backoff], "connecting": [Array], "decoder": [Decoder], "encoder": [Encoder], "encoding": false, "lastPing": null, "nsps": [Object], "opts": [Object], "packetBuffer": [Array], "readyState": "closed", "subs": [Array], "uri": "https://api.sg.amity.co"}, "json": [Circular], "nsp": "/", "receiveBuffer": [], "sendBuffer": []}}

```

And I used region EU but still get this error

---

<div class="post-metadata">

### Author: ![topAmity](https://avatars.discourse-cdn.com/v4/letter/t/a88e4f/32.png) [@topAmity](https://forum.social.plus/u/topAmity)
#### Post date: [April 23, 2024, 10:21am UTC](https://forum.social.plus/t/about-query-channel/1274/9 "2024-04-23T10:21:36Z")

</div>

Hi hossam, Can you try login with this code? The login will be completely after you call `Client.login` and pass userId and displayName to the function

```auto
 const client: Amity.Client = Client.createClient(apiKey, 'eu', {
    apiEndpoint: { http: 'https://api.eu.amity.co' },
  });

  const handleConnect = async (userId: string, displayName: string) => {

    const response = await Client.login(
      {
        userId: userId,
        displayName: displayName
      },
      sessionHandler,
    );
    console.log('response:', response)
  };
  

  const sessionHandler: Amity.SessionHandler = {
    sessionWillRenewAccessToken(renewal: Amity.AccessTokenRenewal) {
      // for details on other renewal methods check session handler
      renewal.renew();
    },
  };

```
