This page has details for how to interact with tag records through the API.
01 Record field format
[hr]
| Name | Type | Details |
|---|---|---|
| [code]id[/code] | integer | >0 |
| [code]name[/code] | string | |
| [code]category[/code] | integer | includes [0,1,3,4,5] |
| [code]post_count[/code] | integer | >=0 |
| [code]is_deprecated[/code] | boolean | |
| [code]created_at[/code] | timestamp | |
| [code]updated_at[/code] | timestamp |
Category
| Value | Description |
|---|---|
| 0 | General |
| 1 | Artist |
| 3 | Copyright |
| 4 | Character |
| 5 | Meta |
[hr]
02 Associated attributes
[hr]
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]wiki_page[/code] | wiki page | single | optional | Wiki page whose title matches the tag name. |
| [code]artist[/code] | artist | single | optional | Artist whose name matches the tag name. |
| [code]antecedent_alias[/code] | tag alias | single | optional | Alias where the tag is the antecedent. |
| [code]consequent_aliases[/code] | tag alias | multiple | optional | Aliases where the tag is the consequent. |
| [code]antecedent_implications[/code] | tag implication | multiple | optional | Implications where the tag is the antecedent. |
| [code]consequent_implications[/code] | tag implication | multiple | optional | Implications where the tag is the consequent. |
| [code]dtext_links[/code] | dtext link | multiple | optional | Dtext links to the page whose title matches the tag name. |
03 Index
[hr]
Returns multiple tag records.
| HTTP Method | GET |
| Base URL | [code]/tags.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]category[/code]
- [code]post_count[/code]
- [code]created_at[/code]
- [code]updated_at[/code]
- String syntax
- [code]name[/code]
- Boolean syntax
- [code]is_deprecated[/code]
- Chaining syntax
- [code]wiki_page[/code]
- [code]artist[/code]
- [code]antecedent_alias[/code]
- [code]consequent_aliases[/code]
- [code]antecedent_implications[/code]
- [code]consequent_implications[/code]
- [code]consequent_implications[/code]
- [code]dtext_links[/code]
Special search parameters
The following are additional search fields.
- [code]fuzzy_name_matches[/code] - Shows tags with names that are within a certain percentage of similarity.
- [code]name_matches[/code] - Normalized wildcard search on the name field.
- [code]name_normalize[/code] - Normalized wildcard search on the name field that supports multiple tags split by a comma ",".
- [code]name_or_alias_matches[/code] - Normalized wildcard search on the name field that also checks for aliases where the search term is the antecedent.
- [code]hide_empty[/code] - Shows tags with a post count of 0 (true) or all tags (false) (Help:Boolean Syntax).
- [code]is_empty[/code] - Shows tags with a post count of 0 (true) or a post count greater than 0 (false) (Help:Boolean Syntax).
Search order
Using the search parameter [code]order[/code] with one of the following values changes the order of the results.
- [code]name[/code] - Name ascending.
- [code]date[/code] - ID descending.
- [code]count[/code] - Post count descending.
- [code]similarity[/code] - Orders by similarity to the search term, then by post count descending, then tag name ascending.
- Only when the [code]fuzzy_name_matches[/code] parameter is used.
- [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.
04 Show
[hr]
Returns a single tag record.
| HTTP Method | GET |
| Base URL | [code]/tags/$id.json[/code] |
| Type | read request |
| Description | [code]$id[/code] is the tag ID. |
05 Update
[hr]
Updates a single tag record.
| HTTP Method | PUT/PATCH |
| Base URL | [code]/tags/$id.json[/code] |
| Type | write request |
| Description | [code]$id[/code] is the tag ID. |
Update parameters
Tag parameters take the following format (see Help:API Write Requests for more info):
[code]
tag[FIELD]=VALUE
[/code]
- Optional:
- [code]is_deprecated[/code]
- can only be set to [code]false[/code] by admins
- can only be set to [code]true[/code] if the tag has a wiki page, and either its post count is zero or the user is an admin
- [code]category[/code] Restricted by user level
- Member+: < 50 posts
- Builder+: < 1000 posts
- Admin+: No limit
06 See also
[hr]
07 External links
[hr]
| Controller | <https://github.com/danbooru/danbooru/blob/master/app/controllers/tags_controller.rb> | |
| Model | <https://github.com/danbooru/danbooru/blob/master/app/models/tag.rb> | |
| Policy | <https://github.com/danbooru/danbooru/blob/master/app/policies/tag_policy.rb> |