# Query data to display on website

**URL:** <https://forum.heroiclabs.com/t/query-data-to-display-on-website/2732>\
**Category:** Runtime Framework\
**Created:** [June 13, 2022, 7:49pm UTC](https://forum.heroiclabs.com/t/query-data-to-display-on-website/2732 "2022-06-13T19:49:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antviss](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/antviss/32/1465_2.png) [@Antviss](https://forum.heroiclabs.com/u/Antviss)\
**Post date:** [June 13, 2022, 7:49pm UTC](https://forum.heroiclabs.com/t/query-data-to-display-on-website/2732/1 "2022-06-13T19:49:38Z")

</div>

Hello all,

Is there a recommended way to query data to be displayed on a website?

I’m looking for:

- Leaderboards
- Tournaments
- List of matches in progress (hopefully with user count)
- Logged in users count (active sessions)
- Registered users count
- list of public groups/clans

Can all of these be done from Server to Server calls? Or do they require a userId in the context?

Is there a “best practices” way to query this data as a payload to be displayed on a website/dashboard?

Many thanks in advance for your reply.

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [June 14, 2022, 10:17am UTC](https://forum.heroiclabs.com/t/query-data-to-display-on-website/2732/2 "2022-06-14T10:17:00Z")

</div>

Hello @Antviss,

It would help to know what you’re trying to accomplish. If this is for a custom dashboard, you can achieve most of what you want setting up RPCs and using S2S calls as advised [here](https://forum.heroiclabs.com/t/nakama-get-requests-from-a-different-server/2648/2). However, doing some of these operations frequently won’t scale.

I’ve inlined the answer for each point or linked the relevant docs page.

> \*Leaderboards  
> [Heroic Labs Documentation | Function Reference](https://heroiclabs.com/docs/nakama/server-framework/go-runtime/function-reference/#LeaderboardList)

> \*Tournaments  
> [Heroic Labs Documentation | Function Reference](https://heroiclabs.com/docs/nakama/server-framework/go-runtime/function-reference/#TournamentList)

- List of matches in progress (hopefully with user count)

You’d have to use the match listing API [Heroic Labs Documentation | Match Listing](https://heroiclabs.com/docs/nakama/concepts/multiplayer/match-listing/), as for the user count, you’d have to appropriately use the labels to keep track of that yourself.

- Logged in users count (active sessions)

The right way of keeping track of this would be using Prometheus, as we expose the count of current active sessions.

- Registered users count

We purposefully don’t provide an API for this, as it’s an operation that won’t scale. You could use a custom db query, but we strongly discourage it because of the above.

You can get an **estimate** on the Nakama dashboard: [Heroic Labs Documentation | Accounts](https://heroiclabs.com/docs/nakama/getting-started/console/accounts/).

- list of public groups/clans  
[Heroic Labs Documentation | Function Reference](https://heroiclabs.com/docs/nakama/server-framework/go-runtime/function-reference/#GroupsList)

---

<div class="post-metadata">

**Author:** ![Antviss](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/antviss/32/1465_2.png) [@Antviss](https://forum.heroiclabs.com/u/Antviss)\
**Post date:** [June 14, 2022, 4:38pm UTC](https://forum.heroiclabs.com/t/query-data-to-display-on-website/2732/3 "2022-06-14T16:38:48Z")

</div>

Thank you so much for the reply @sesposito It definitely helps.

To answer your initial question, it’s not quite a dashboard per se, but instead showing some live game data on our website to show users. I will have an Express JS internal server which caches most of the data from Nakama and the public website will get data from it in the backend instead of the Nakama server directly.

Am I right in my understanding that S2S RPC calls do not allow a userID (context) to be sent?

If that’s correct, do all these Runtime Functions work without a user context? If not, is it ok to use the 0000 default user inside the function to get the data?

As for the Match Listing API, does this include matches already in progress/which have started?

Thank you again!

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [June 14, 2022, 6:23pm UTC](https://forum.heroiclabs.com/t/query-data-to-display-on-website/2732/4 "2022-06-14T18:23:02Z")

</div>

The context is not sent explicitly by the clients, it is provided to the registered RPC functions when invoked. If the call comes from a client with a session token, the context will contain the userID, but if it’s a S2S call authenticated using the server http key, no userID will be populated in the context.

You can however set up the RPC calls to receive any payload you’d like to send in the requests.

The match listing API can be used to list all matches, to filter matches for a given state according to your game semantics, you have to update the label from within the match handlers and then use the query language [Nakama: Query Syntax | Heroic Labs Documentation](https://heroiclabs.com/docs/nakama/concepts/multiplayer/query-syntax/). Labels are only supported in authoritative matches.

---

<div class="post-metadata">

**Author:** ![Antviss](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/antviss/32/1465_2.png) [@Antviss](https://forum.heroiclabs.com/u/Antviss)\
**Post date:** [June 14, 2022, 7:46pm UTC](https://forum.heroiclabs.com/t/query-data-to-display-on-website/2732/5 "2022-06-14T19:46:32Z")

</div>

Thank you for your thoroughness, @sesposito . It is much appreciated!
