How to get the actual note content via the API?

I am trying to get the content of a note via the API like this (I leave the API token part):

  • /notes → to get all the notes metadata, including their id
  • /notes/<id> → to get “the note”

This is what I retrieve with /notes/29947e4e28c74ff0b1a93b17fe543823:

{
  "id": "29947e4e28c74ff0b1a93b17fe543823",
  "title": "This is a test note",
  "is_todo": 0,
  "todo_completed": 0,
  "parent_id": "70222c4ddbc741d8b9a321ace76a20b5",
  "updated_time": 1588932660411,
  "user_updated_time": 1588932660411,
  "user_created_time": 1588932631881,
  "encryption_applied": 0,
  "type_": 1
}

Where are the contents of this note? The documentation suggests that there should be a body_html field.

I tried to retrieve the resources (/notes/<id>/resources), but the response is empty ([])

By default the body is not returned so you need to add ?fields=id,title,body and any other field you need.

Thanks a lot, it works.

I just realized, searching for fields on the API docs page that this information is actually present:

You can change the fields that will be returned by the API using the fields= query parameter, which takes a list of comma separated fields.

It may be worthwhile to add that should a field not be present in the response, it can be added via this mechanism.

I was looking for the same info. The documentation is, unfortunately, not too clear on this subject.
I would also suggest that the API docs explicitly state that by default the body is not returned when querying for a note. This would make the very useful API more user-friendly
The normal expectation of a user is that, unless otherwise specified, GET-ting a note returns all fields/content.

Does it work with encrypted notes?

I have encryption on and
curl http://localhost:41184/notes/1a05728a2c00479XXXXXXXXX?token=XXXXXX&fields=body
does not returns body, just metadata

Ok its solved. The problem was that curl was cutting url on ampersand.
Url should be in quotes:
curl 'http://localhost:41184/notes/1a05728a2c00479XXXXXXXXX?token=XXXXXX&fields=body'

1 Like

I once suggested to add a way to fetch all the defaults, plus the body (i.e. the old behaviour)…

Is there any plugin API to retrieve parsed note content? I add body_html in fields, but got

Uncaught (in promise) Error: Error: SQLITE_ERROR: no such column: body_html: SELECT `body_html` FROM `notes` WHERE `id` = ?: 70e543a12e30490abd0162f45ffc5403

I would recommend updating the documentation for the GET /note/:id API to indicate that the body is not included by default. I found this post by Googling for how to retrieve the actual note contents.

From a user perspective, I would generally expect that retrieving a note, with a specific ID, would return the payload / body of the note as well. Right now, the description doesn't indicate that this doesn't happen, or where to go from there.

It's strange that you take the time to create a post, make a screenshot, highlight some specific random information in it... and apparently ignore the rest of the doc? There's something before and after that red rectangle... Information about filtering data for instance that says "By default API results will contain the following fields: id, parent_id, title" and that explains how to get more data.

It's a very small doc actually, it takes 10 minutes to read the important information.