This page has details for how to interact with favorite group records through the API.
01 Record field format
[hr]
[table]
[thead][tr]
[th]Name[/th][th]Type[/th][th]Details[/th]
[/tr][/thead]
[tbody]
[tr][td][code]id[/code][/td][td]integer[/td][td]>0[/td][/tr]
[tr][td][code]name[/code][/td][td]string[/td][td][/td][/tr]
[tr][td][code]creator_id[/code][/td][td]integer[/td][td]>0[/td][/tr]
[tr][td][code]post_ids[/code][/td][td]array[/td][td]integers > 0[/td][/tr]
[tr][td][code]is_public[/code][/td][td]boolean[/td][td][/td][/tr]
[tr][td][code]created_at[/code][/td][td]timestamp[/td][td][/td][/tr]
[tr][td][code]updated_at[/code][/td][td]timestamp[/td][td][/td][/tr]
[/tbody]
[/table]
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):
[table]
[thead][tr]
[th]Name[/th][th]Type[/th][th]Availability[/th][th]Number[/th][th]Details[/th]
[/tr][/thead]
[tbody]
[tr][td][code]creator[/code][/td][td]user
[/tbody]
[/table]
03 Index
[hr]
Returns multiple favorite group records.
[table][tbody]
[tr][td]HTTP Method[/td][td]GET[/td][/tr]
[tr][td]Base URL[/td][td][code]/favorite_groups.json[/code][/td][/tr]
[tr][td]Type[/td][td]read request
[tr][td]Description[/td][td]The default order is ID descending.[/td][/tr]
[/tbody][/table]
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]created_at[/code]
- [code]updated_at[/code]
- Text syntax
- [code]name[/code]
- User syntax
- [code]creator[/code]
- Array syntax
- [code]post_ids[/code]
- Boolean syntax
- [code]is_public[/code]
Special search parameters
The following are additional search fields.
- [code]name_contains[/code] - Normalized case-insensitive wildcard searching on the name text field.
Search order
Using the search parameter [code]order[/code] with one of the following values changes the order of the results.
- [code]name[/code] - Alphabetic order by name, then ID descending.
- [code]created_at[/code] - Orders by creation time descending.
- [code]updated_at[/code] - Orders by update time descending, then ID descending.
- [code]post_count[/code] - Orders by post count, then ID descending.
04 Show
[hr]
Returns a single favorite group record.
[table][tbody]
[tr][td]HTTP Method[/td][td]GET[/td][/tr]
[tr][td]Base URL[/td][td][code]/favorite_groups/$id.json[/code][/td][/tr]
[tr][td]Type[/td][td]read request
[tr][td]Description[/td][td][code]$id[/code] is the favorite group ID.[/td][/tr]
[/tbody][/table]
05 Create
[hr]
Creates a single favorite group record.
[table][tbody]
[tr][td]HTTP Method[/td][td]POST[/td][/tr]
[tr][td]Base URL[/td][td][code]/favorite_groups.json[/code][/td][/tr]
[tr][td]Type[/td][td]write request
[tr][td]Description[/td][td][/td][/tr]
[/tbody][/table]
Create parameters
Favorite group parameters take the following format (see Help:API Write Requests for more info):
[code]
favorite_group[FIELD]=VALUE
[/code]
- Required:
- [code]name[/code]
- Optional:
- [code]post_ids[/code] - Uses URL array parameter format.
- [code]post_ids_string[/code] - Space delimited list of post IDs.
- [code]is_public[/code] - Only Gold+ users can set this to [code]false[/code].
06 Update
[hr]
[table][tbody]
[tr][td]HTTP Method[/td][td]PUT/PATCH[/td][/tr]
[tr][td]Base URL[/td][td][code]/favorite_groups/$id.json[/code][/td][/tr]
[tr][td]Type[/td][td]write request
[tr][td]Description[/td][td][code]$id[/code] is the favorite group ID.[/td][/tr]
[/tbody][/table]
Update parameters
Accepts the same parameters create action. All parameters are optional.
07 Add post
[hr]
Adds a single post to a favorite group.
[table][tbody]
[tr][td]HTTP Method[/td][td]PUT[/td][/tr]
[tr][td]Base URL[/td][td][code]/favorite_groups/$id/add_post.json[/code][/td][/tr]
[tr][td]Type[/td][td]write request
[tr][td]Description[/td][td][code]$id[/code] is the favorite group ID.[/td][/tr]
[/tbody][/table]
Add post parameters
- Required:
- [code]post_id[/code] - The post ID to add to the favorite group.
08 Remove post
[hr]
Removes a single post from a favorite group.
[table][tbody]
[tr][td]HTTP Method[/td][td]PUT[/td][/tr]
[tr][td]Base URL[/td][td][code]/favorite_groups/$id/remove_post.json[/code][/td][/tr]
[tr][td]Type[/td][td]write request
[tr][td]Description[/td][td][code]$id[/code] is the favorite group ID.[/td][/tr]
[/tbody][/table]
Remove post parameters
- Required:
- [code]post_id[/code] - The post ID to remove from the favorite group.
09 Destroy
[hr]
Deletes a single favorite group record.
[table][tbody]
[tr][td]HTTP Method[/td][td]DELETE[/td][/tr]
[tr][td]Base URL[/td][td][code]/favorite_groups/$id.json[/code][/td][/tr]
[tr][td]Type[/td][td]write request
[tr][td]Description[/td][td][code]$id[/code] is the favorite group ID.[/td][/tr]
[/tbody][/table]
Note: Favorite group records are destroyed rather than deleted and cannot be viewed or retrieved later.
10 See also
[hr]
11 External links
[hr]
[table][tbody]
[tr][td]Controller[/td][td]https://github.com/danbooru/danbooru/blob/master/app/controllers/favorite_groups_controller.rb[/td][/tr]
[tr][td]Model[/td][td]https://github.com/danbooru/danbooru/blob/master/app/models/favorite_group.rb[/td][/tr]
[tr][td]Policy[/td][td]https://github.com/danbooru/danbooru/blob/master/app/policies/favorite_group_policy.rb[/td][/tr]
[/tbody][/table]