First baby steps

Being very new (3 days) at this, api’s in general and json:api. So I set up some toy db’s and am poking at them. There’s some JSON below for ref. In the db a table that holds all notes, a table with the books and a many to many table to link notes to the notebooks. A note can appear in several book but in a book only once.

Questions come up as the specs don’t specify what to do with the api, as it shouldn’t.

Relationships:
does it make sense to add a relation to the parent?
“notebook”: {
“links”: {
“related”: “/notebook”
}
}
The parent type would be notebook_collection?

There is no data object in the relations (the spec doesn’t require it), as there can be thousands of notes in a book, just leave it out as I did? Or is there some cleverness to add here?

In the relation “note” I omitted the link “self” as it would allow its modification, but without a specific note_id it would only destroy the underlying many2many table. Is this right?

Links:
“links”:{
“self”: “/notebook/garden/relationships/note/999”
“related”: “/notebook/garden/note/999”
}
If the self link points to a webpage then I could there modify the relation book:note, say also add the not to another book or ‘unlink’ it and make it an orphant?

The related link points to a page where I can read the note and maybe modify it, but not its relations?

GET /notebook/1
decompose:
  args=('notebook', 1)
  kwargs={}

GET /notebook?book=garden
decompose:
  args=('notebook')
  kwargs={"book": "garden"}

GET /notebook/garden
decompose:
  args=('notebook', 'garden')
  kwargs={}

All should result in:

{
  "links": { 
    "self": "/notebook/garden"
  },
  "data": {
    "type": "notebook",
    "id":"1",
    "attributes": {
      "book": "garden"
      "total_notes": "421"
    }
    "relationships": {
      "note": {
        "links": {
          "related": "/notebook/garden/note"
        }
      }
    }
  },
  "included": [
    {
      "type": "note",
      "id": "999",
      "attributes": {
        "title": "last note",
        "body": "nothing more to say",
        "ref": "1",
        "ts_from": "2000-01-01T12:00:00"
      },
      "links":{
        "self": "/notebook/garden/relationships/note/999"
        "related": "/notebook/garden/note/999"
      }
    },
    {
      ... etc ...
    },
    "meta":{
      "info": "last 5 (updated) notes"
    }
  ]
}

assume a client hits /notebook/timeline, that would imply all notes in all notebooks would be returned. This can be restricted by just returning the notes of the past two days and with adding the links to next, previous etc.

Or should the result of the above query be a 303 redirect to /notebook/timeline?filter[notebook]={},{},…,{}&filter[from]={}&filter[to]={}

Or can I just ignore /notebook/timeline and 404. /notebook would have links / relations to the filter version.

In similar vain /notebook/{book}/note/{id} should /notebook/{book}/note exist / be something else than 404?

TIA,

ingo