# 「API」でオンラインになっているのは誰ですか？

**URL:** https://meta.discourse.org/t/whos-online-api/166411
**Category:** Support
**Created:** [2020 年 10 月 6 日午後 5:36 UTC](https://meta.discourse.org/t/whos-online-api/166411 "2020-10-06T17:36:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mentalstring](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mentalstring/32/168934_2.png) [@mentalstring](https://meta.discourse.org/u/mentalstring)
#### Post date: [2020 年 10 月 6 日午後 5:36 UTC](https://meta.discourse.org/t/whos-online-api/166411/1 "2020-10-06T17:36:14Z")

</div>

Grafana などの外部ツールを使用して、フォーラムのアクティビティ（時間の経過に伴うオンラインユーザー数）を監視することを検討しています。すでに「whos-online」プラグインを使用しているため、プラグインが計算したオンラインユーザー数を API リクエストやルートを通じて取得する方法があるかどうか疑問に思っています。必要以上のデータが返されても構いません。後で解析できます。

あるいは、既存のコア API でこれを実現するより簡単な方法があるかもしれませんか？

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2020 年 10 月 6 日午後 5:50 UTC](https://meta.discourse.org/t/whos-online-api/166411/2 "2020-10-06T17:50:12Z")

</div>

/whosonline/get.json から whos-online プラグインのデータを取得できますが、URL やデータ形式はパブリック API と見なすべきではない点にご注意ください。いつでも削除または変更される可能性があります。

別の選択肢として、データエクスプローラーでクエリを実行し、[Discourse API を通じて呼び出す](https://meta.discourse.org/t/how-to-run-data-explorer-queries-with-the-discourse-api/120063)方法があります。以下のようなクエリを実行すれば、whos-online プラグインとほぼ同じ結果が得られます。

```plaintext
SELECT id AS user_id 
FROM users 
WHERE last_seen_at >= NOW() - INTERVAL '5 minutes'

```

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2020 年 11 月 5 日午後 6:00 UTC](https://meta.discourse.org/t/whos-online-api/166411/3 "2020-11-05T18:00:43Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
