# Discourse-user-notes API

**URL:** https://meta.discourse.org/t/discourse-user-notes-api/240948
**Category:** Development
**Tags:** user-notes, rest-api
**Created:** [October 4, 2022, 9:34pm UTC](https://meta.discourse.org/t/discourse-user-notes-api/240948 "2022-10-04T21:34:53Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![codetricity](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codetricity/32/3773_2.png) [@codetricity](https://meta.discourse.org/u/codetricity)
#### Post date: [October 4, 2022, 9:34pm UTC](https://meta.discourse.org/t/discourse-user-notes-api/240948/1 "2022-10-04T21:34:54Z")

</div>

I want to get all the user notes for a user using the Discourse API. The notes are applied with [discourse-user-notes](https://github.com/discourse/discourse-user-notes).

Using [Get a user by id](https://docs.discourse.org/#tag/Users/operation/adminGetUser), I can see the `user_note_count` filed. However, I can’t seem to find the contents of the user note.

I want to attach information to a user such as the body of an email or main points of a video conference that staff have had with the user. I’m hoping to use the Discourse PostgreSQL data instead of creating a duplicate database with fields for notes.

I’m hoping to use the existing discourse-user-notes as it’s already built.

I have a separate desktop application for staff that uses the Discourse API and is written in Dart/Flutter using http requests to talk to Discourse.

I have no experience with Ruby.

Is there a way I can get information from this file that might be exposed as a HTTP API?

[discourse-user-notes/plugin.rb at main · discourse/discourse-user-notes · GitHub](https://github.com/discourse/discourse-user-notes/blob/main/plugin.rb)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 5, 2022, 6:55pm UTC](https://meta.discourse.org/t/discourse-user-notes-api/240948/2 "2022-10-05T18:55:40Z")

</div>

> [@codetricity](#):
>
> I want to get all the user notes for a user using the Discourse API.

I recommend that you use the [data explorer](https://meta.discourse.org/t/32566?silent=true) plugin and [Run Data Explorer queries with the Discourse API](https://meta.discourse.org/t/run-data-explorer-queries-with-the-discourse-api/120063); it sort-of allows you to generate your own API endpoint (to retrieve [data explorer](https://meta.discourse.org/t/32566?silent=true) data).

> [@codetricity](#):
>
> Using [Get a user by id](https://docs.discourse.org/#tag/Users/operation/adminGetUser), I can see the `user_note_count` filed. However, I can’t seem to find the contents of the user note.

Are you requesting as a user that can read those notes?

---

<div class="post-metadata">

### Author: ![codetricity](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codetricity/32/3773_2.png) [@codetricity](https://meta.discourse.org/u/codetricity)
#### Post date: [October 5, 2022, 8:44pm UTC](https://meta.discourse.org/t/discourse-user-notes-api/240948/3 "2022-10-05T20:44:34Z")

</div>

> [@pfaffman](#):
>
> I recommend that you use the [data explorer](https://meta.discourse.org/t/32566?silent=true) plugin and [Run Data Explorer queries with the Discourse API](https://meta.discourse.org/t/run-data-explorer-queries-with-the-discourse-api/120063); it sort-of allows you to generate your own API endpoint (to retrieve [data explorer](https://meta.discourse.org/t/32566?silent=true) data).

Thank you for your help. What is the query I need to run to see the content of the user notes?

Is there some way I can see the fields that the note is stored in from the source code of the plug-in? Maybe I can show a custom\_field for the user somehow?

[discourse-user-notes/plugin.rb at main · discourse/discourse-user-notes · GitHub](https://github.com/discourse/discourse-user-notes/blob/main/plugin.rb)

I do not know how to ready Ruby, but maybe there is a field called user\_notes in Discourse some place that I can search for with the user.id and then there is an object `notes` with a field of `raw`?

I’m just guessing. I may just pull the users and store the notes in a separate database, not Discourse. However, I would like to use the data in Discourse if possible as it will be easier to attach the note to a specific user and post.

```ruby
      notes = notes_for(user.id)
      record = {
        id: SecureRandom.hex(16),
        user_id: user.id,
        raw: raw,
        created_by: created_by,
        created_at: Time.now
      }.merge(opts)

      notes << record
      ::PluginStore.set("user_notes", key_for(user.id), notes)

      user.custom_fields[COUNT_FIELD] = notes.size
      user.save_custom_fields

```

> [@pfaffman](#):
>
> Are you requesting as a user that can read those notes?

I am pulling the list of users as admin to see which users have notes applied to them. After I identify the list of users with notes, I want to display the notes in a table so that staff can respond to questions more easily with the background information for the user.

* * *

I’m trying to use `/user_notes.json?user_id=2`

 ![image](https://global.discourse-cdn.com/meta/original/4X/a/2/1/a213a14b2e9190a31c73e07549678fd243dcc5e3.png)

---

<div class="post-metadata">

### Author: ![codetricity](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codetricity/32/3773_2.png) [@codetricity](https://meta.discourse.org/u/codetricity)
#### Post date: [October 21, 2022, 11:20pm UTC](https://meta.discourse.org/t/discourse-user-notes-api/240948/4 "2022-10-21T23:20:23Z")

</div>

> [@API for Admin Report Data](https://meta.discourse.org/t/api-for-admin-report-data/242426/4):
>
> I just did a test on Meta with curl https://meta.discourse.org/admin/reports/staff\_logins.json \ -H 'Api-Key: asdasdasdasd' \ -H 'Api-Username: Falco' and it worked just fine for me. Can you try like that?

Thanks to @Falco , I am able to get the user\_notes.

```plaintext
curl https://community.domain.com/admin/reports/user_notes.json \
  -H 'Api-Key: abcdefghijklmnop' \
  -H 'Api-Username: system'

```

---

<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: [November 20, 2022, 11:21pm UTC](https://meta.discourse.org/t/discourse-user-notes-api/240948/5 "2022-11-20T23:21:14Z")

</div>

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