Home / GitHub Page

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)…