This page has details for how to interact with post records through the API.
[hr]
Record field format
| Name | Type | Details |
|---|---|---|
| [code]id[/code] | integer | >0 |
| [code]rating[/code] | string | includes [g, s, q, e] |
| [code]parent_id[/code] | integer or null | >0 |
| [code]source[/code] | string | |
| [code]md5[/code] | string | Only shown if visible to the user. |
| [code]uploader_id[/code] | integer | >0 |
| [code]approver_id[/code] | integer or null | >0 |
| [code]file_ext[/code] | string | |
| [code]file_size[/code] | integer | |
| [code]image_width[/code] | integer | |
| [code]image_height[/code] | integer | |
| [code]score[/code] | integer | |
| [code]up_score[/code] | integer | |
| [code]down_score[/code] | integer | |
| [code]fav_count[/code] | integer | |
| [code]is_pending[/code] | boolean | |
| [code]is_flagged[/code] | boolean | |
| [code]is_deleted[/code] | boolean | |
| [code]tag_string[/code] | string | |
| [code]tag_count[/code] | integer | |
| [code]tag_count_general[/code] | integer | |
| [code]tag_count_artist[/code] | integer | |
| [code]tag_count_copyright[/code] | integer | |
| [code]tag_count_character[/code] | integer | |
| [code]tag_count_meta[/code] | integer | |
| [code]last_commented_at[/code] | timestamp or null | |
| [code]last_comment_bumped_at[/code] | timestamp or null | |
| [code]last_noted_at[/code] | timestamp or null | |
| [code]has_children[/code] | boolean | |
| [code]has_active_children[/code] | boolean | |
| [code]pixiv_id[/code] | integer or null | >0 |
| [code]bit_flags[/code] | bigint | |
| [code]created_at[/code] | timestamp | |
| [code]updated_at[/code] | timestamp |
[hr]
Derived field format
These are values which are not part of the actual record, but instead are derived from calculations and record lookups on the fly.
| Name | Type | Details | Notes |
|---|---|---|---|
| [code]has_large[/code] | boolean | Derived from the media asset. The existence of the sample size. | |
| [code]has_visible_children[/code] | boolean | Derived from the children. Returns true if: - Any child is active - The user has it set to show deleted children - The post itself is deleted | |
| [code]file_url[/code] | string | Only shown if visible to user. | Derived from the media asset. The original size. |
| [code]large_file_url[/code] | string | Only shown if visible to user. | Derived from the media asset, if the sample size exists. |
| [code]preview_file_url[/code] | string | Only shown if visible to user. | Derived from the media asset. The 180x180 size. |
| [code]tag_string_general[/code] | string | Derived from the tag string. | |
| [code]tag_string_artist[/code] | string | Derived from the tag string. | |
| [code]tag_string_copyright[/code] | string | Derived from the tag string. | |
| [code]tag_string_character[/code] | string | Derived from the tag string. | |
| [code]tag_string_meta[/code] | string | Derived from the tag string. |
[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]media_asset[/code] | media asset | single | required | Included by default. |
| [code]media_metadata[/code] | media metadata | single | required | |
| [code]uploader[/code] | user | single | required | |
| [code]approver[/code] | user | single | optional | |
| [code]parent[/code] | post | single | optional | |
| [code]children[/code] | post | multiple | optional | |
| [code]artist_commentary[/code] | artist_commentary | single | optional | |
| [code]notes[/code] | note | multiple | optional | |
| [code]comments[/code] | comment | multiple | optional | |
| [code]flags[/code] | post flag | multiple | optional | |
| [code]appeals[/code] | post appeals | multiple | optional | |
| [code]events[/code] | events | multiple | optional | |
| [code]approvals[/code] | post approval | multiple | optional | |
| [code]disapprovals[/code] | post disapproval | multiple | optional | |
| [code]replacements[/code] | post replacement | multiple | optional | |
| [code]ai_tags[/code] | ai tag | multiple | optional | |
| [code]dtext_links[/code] | dtext link | multiple | optional | |
| [code]embedding_wiki_pages[/code] | wiki page | multiple | optional |
[hr]
Index
Returns multiple post records.
| HTTP Method | GET |
| Base URL | [code]/posts.json[/code] |
| Type | read request |
| Description | The default order is ID descending |
Index parameters
- [code]tags[/code] - The post query to search for using tags and metatags (Help:Cheatsheet).
- [code]random[/code] - Selects a random sampling under the post query.
- [code]md5[/code] - Search for an MD5 match. Takes priority over all other parameters.
Search attributes
Search parameters are not available directly, but can be used via chaining (see Help:Chaining Syntax for more info). The following is an example of what this format can look like:
[code]
search[post][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]created_at[/code]
- [code]updated_at[/code]
- [code]pixiv_id[/code]
- [code]fav_count[/code]
- [code]score[/code]
- [code]up_score[/code]
- [code]down_score[/code]
- [code]file_size[/code]
- [code]image_width[/code]
- [code]image_height[/code]
- [code]tag_count[/code]
- [code]last_comment_bumped_at[/code]
- [code]last_commented_at[/code]
- [code]last_noted_at[/code]
- Text syntax
- [code]rating[/code]
- [code]source[/code]
- [code]md5[/code]
- [code]file_ext[/code]
- Boolean syntax
- [code]has_children[/code]
- [code]has_active_children[/code]
- [code]is_pending[/code]
- [code]is_flagged[/code]
- [code]is_deleted[/code]
- [code]is_banned[/code]
- User syntax
- [code]uploader[/code]
- [code]approver[/code]
- Post syntax
- [code]parent[/code] (unavailable due to current limitations)
- [code]children[/code] (unavailable due to current limitations)
- Chaining syntax
- [code]artist_commentary[/code]
- [code]flags[/code]
- [code]appeals[/code]
- [code]notes[/code]
- [code]comments[/code]
- [code]approvals[/code]
- [code]replacements[/code]
- [code]media_metadata[/code]
Special search parameters
The following are additional search fields.
- [code]tags[/code] - Behaves the same as the regular post search.
[hr]
Show
Returns a single post record.
| HTTP Method | GET |
| Base URL | [code]/posts/$id.json[/code] |
| Type | read request |
| Description | [code]$id[/code] is the post ID |
[hr]
Create
Creates a single post record.
| HTTP method | POST |
| Base URL | /posts.json |
| Type | write request |
Create parameters
Post parameters take the following format (see Help:API Write Requests for more info):
[code]
post[FIELD]=VALUE
[/code]
- Mandatory:
- [code]upload_media_asset_id[/code]
- Optional:
- [code]tag_string[/code]
- [code]rating[/code]
- [code]parent_id[/code]
- [code]source[/code]
- [code]artist_commentary_title[/code]
- [code]artist_commentary_desc[/code]
- [code]translated_commentary_title[/code]
- [code]translated_commentary_desc[/code]
- [code]is_pending[/code] - only matters for users with unrestricted uploads.
[hr]
Update
Updates a single post record.
| HTTP Method | PUT/PATCH |
| Base URL | [code]/posts/$id.json[/code] |
| Type | write request |
| Description | $id is the post ID |
Update parameters
- Optional:
- [code]tag_string[/code]
- [code]old_tag_string[/code]
- [code]parent_id[/code]
- [code]old_parent_id[/code]
- [code]source[/code]
- [code]old_source[/code]
- [code]rating[/code]
- [code]old_rating[/code]
- [code]has_embedded_notes[/code]
[hr]
Destroy
Deletes a single post record.
| HTTP Method | DELETE |
| Base URL | [code]/posts/$id.json[/code] |
| Type | write request |
| Description | $id is the post ID Only available to Approvers and above. |
Revert
| HTTP Method | PUT/PATCH |
| Base URL | [code]/posts/$id/revert.json[/code] |
| Type | write request |
| Description | $id is the post ID |
Revert parameters
- Required:
- version_id - The post version ID to revert to.
[hr]
See also
[hr]
External links
| Controller | <https://github.com/danbooru/danbooru/blob/master/app/controllers/posts_controller.rb> | |
| Model | <https://github.com/danbooru/danbooru/blob/master/app/models/post.rb> | |
| Policy | <https://github.com/danbooru/danbooru/blob/master/app/policies/post_policy.rb> |