This page has details for how to interact with note records through the API.
[hr]
Record field format
| Name | Type | Details |
|---|---|---|
| [code]id[/code] | integer | >0 |
| [code]post_id[/code] | integer | >0 |
| [code]body[/code] | string | |
| [code]x[/code] | integer | >0 |
| [code]y[/code] | integer | >0 |
| [code]width[/code] | integer | >0 |
| [code]height[/code] | integer | >0 |
| [code]is_active[/code] | boolean | |
| [code]version[/code] | integer | >0 |
| [code]created_at[/code] | timestamp | |
| [code]updated_at[/code] | timestamp |
[hr]
Associated attributes
The following is the list of relations that can be included in the API results (see Help:Common URL Parameters for more info):
| Name | Type | Number | Availability | Details |
|---|---|---|---|---|
| [code]post[/code] | post | single | required |
[hr]
Index
Returns multiple note records.
| HTTP Method | GET |
| Base URL | [code]/notes.json[/code] |
| Type | read request |
| Description | The default order is ID descending. |
Search attributes
Search parameters take the following format (see Help:Common URL Parameters for more info):
[code]
search[FIELD]=VALUE
[/code]
The following are the base fields along with their associated type. Check the syntax pages for all of the available variations.
- Number syntax
- [code]id[/code]
- [code]x[/code]
- [code]y[/code]
- [code]width[/code]
- [code]height[/code]
- [code]version[/code]
- [code]created_at[/code]
- [code]updated_at[/code]
- Text syntax
- [code]body[/code]
- Boolean syntax
- [code]is_active[/code]
- Post syntax
- [code]post[/code]
Search order
Using the search parameter [code]order[/code] with one of the following values changes the order of the results.
- [code]custom[/code] - Help:Common URL Parameters
- In order to use this order, [code]search[id][/code] must also be set with a list of comma-separated IDs.
[hr]
Show
Returns a single note record.
| HTTP Method | GET |
| Base URL | [code]/notes/$id.json[/code] |
| Type | read request |
| Description | [code]$id[/code] is the note ID. |
Note: This does a redirect to the post with that note when using the HTML interface, specifically highlighting that note when it gets there.
[hr]
Create
Creates a single note record.
| HTTP Method | POST |
| Base URL | [code]/notes.json[/code] |
| Type | write request |
Create parameters
Note parameters take the following format (see Help:API Write Requests for more info):
[code]
note[FIELD]=VALUE
[/code]
- Required:
- [code]post_id[/code] - The post ID the note belongs to.
- [code]x[/code] - X coordinate of the note starting from the left of the image.
- [code]y[/code] - y coordinate of the note starting from the top of the image.
- [code]height[/code]
- [code]width[/code]
- [code]body[/code]
- Optional
- [code]is_active[/code] - Whether the note is active or not (i.e. deleted).
Note: The note box must fit within the full-size dimensions of the image.
[hr]
Update
Updates a single note record.
| HTTP Method | PUT/PATCH |
| Base URL | [code]/notes/$id.json[/code] |
| Type | write request |
| Description | [code]$id[/code] is the note ID. |
Update parameters
Accepts the same parameters as the Create action, except for the post ID. All parameters are optional.
[hr]
Delete
Deletes a single note record.
| HTTP Method | DELETE |
| Base URL | [code]/notes/$id.json[/code] |
| Type | write request |
| Description | [code]$id[/code] is the note ID. |
[hr]
Revert
Reverts a single note record to a prior version.
| HTTP Method | PUT |
| Base URL | [code]/notes/$id/revert.json[/code] |
| Type | write request |
| Description | [code]$id[/code] is the note ID. |
Revert parameters
- Required:
- [code]version_id[/code] - The note version ID to revert to.
Note: The version ID may be passed along as a URL parameter instead of in the body.
[hr]
Preview
Returns the sanitized version of HTML that Danbooru uses for notes.
| HTTP Method | POST |
| Base URL | [code]/notes/preview.json[/code] |
| Type | write request |
| Description | Returns a JSON object that has the same attributes as a note record, with the addition of a [code]sanitized_body[/code] field. |
Preview parameters
- Required:
- [code]body[/code] - The HTML text to sanitize.
Note: The body variable may be passed along as a URL parameter instead of in the request body.
[hr]
See also
[hr]
External links
| Controller | <https://github.com/danbooru/danbooru/blob/master/app/controllers/notes_controller.rb> | |
| Model | <https://github.com/danbooru/danbooru/blob/master/app/models/note.rb> | |
| Policy | <https://github.com/danbooru/danbooru/blob/master/app/policies/note_policy.rb> |