Skip to content

Dnote HTTP API

Sung edited this page Mar 3, 2023 · 6 revisions

API

The API request and response payloads use JSON. Set HTTP header Content-Type: application/json to use JSON.

How to authenticate

  • Obtain the session key using the "sign in" API.
  • Set HTTP header "Authorization" to Bearer [your session key] to authenticate.

Example

$ curl http://localhost:3000/api/v3/notes -H "Authorization: Bearer MyLpsk2o/qidblP0yiGdgPNgZZp2q3WJdp5GFGaaoMs="

Sign in

/api/v3/signin

Request Params

Key Type Description Required
email string Email address for the account Yes
password string Password for the account Yes

Response

Key Type Description
key string The secret session key
expires_at number Unix timestamp of when the session key expires

Example

$ curl -X POST http://localhost:3000/api/v3/signin -d '{"email": "alice@example.com", "password": "randompassword"}' -H "Content-Type: application/json"
{"key":"MyLpsk2o/qidblP0yiGdgPNgZZp2q3WJdp5GFGaaoMs=","expires_at":1686526664

Sign out

/api/v3/signout

Expires the given session key.

Request Params

None.

Response

HTTP 204 if successful.

Get notes

/v3/notes/

Request Params

Key Type Description Required
year string The year in which notes are created
month string The month in which notes are created
books []string The list of books to which notes belong
page number The page of the search result
q string a string to match for full text search

Response

Key Type Description
notes []Note Notes
total number The total number of results

Note is

Key Type Description
uuid string Notes
created_at timestamp a timestmap
updated_at timestamp a timestmap
body string The content of note
added_on number Unix timestamp for when note is added
public bool Currently always true
usn number an internal mechanism used for sync
book Book The book that the note belong to
user User User that created the note

Show note

/v3/notes/{noteUUID}

Request Params

None.

Response

Note. Please see previous sections for its shape.

Create note

POST - /v3/notes/

Request Params

Key Type Description Required
book_uuid string UID for the book the note will belong to Yes
content string The content of the note Yes
added_on number Unix timestamp of creation
edited_on number Unix timestamp of last edit

Response

Key Type Description
result Note Note

Example

$ curl -X POST http://localhost:3000/api/v3/notes -H "Authorization: Bearer MyLpsk2o/qidblP0yiGdgPNgZZp2q3WJdp5GFGaaoMs=" -H "Content-Type: application/json" -d '{"book_uuid": "bdf6cadb-38da-49d1-bbc8-98f8bcdd3ff7", "content": "my note content"}

Delete note

DELETE - /v3/notes/{noteUUID}

Request Params

None.

Response

Key Type Description
status number HTTP status
result Note Note

Update note

PATCH - /v3/notes/{noteUUID}

Request Params

Key Type Description Required
book_uuid string UID for the book the note will belong to
content string The content of the note
public number Not used

Response

Key Type Description
status number HTTP status
result Note Note

Get books

PATCH - /v3/books

Request Params

Key Type Description Required
name string name to match for the books

Response

A list of books.

A book is:

Key Type Description
uuid string UUID for the book
usn string an internal mechanism
created_at string a timestamp for creation
updated_at string a timestamp for the last update
label string The name of the book

Get book

PATCH - /v3/books/{bookUUID}

Request Params

None.

Response

A book. Please see previous session for the shape of a book.

Create book

POST - /v3/books/

Request Params

Key Type Description Required
name string The name of the book Yes

Response

Key Type Description
book Book book

Update book

PATCH - /v3/books/{bookUUID}

Request Params

Key Type Description Required
name string The name of the book

Response

Key Type Description
book Book book

Delete book

Delete - /v3/books/{bookUUID}

Request Params

None

Response

Key Type Description
status number an HTTP status
book Book book