Danbooru Reference

pybooru.danbooru

This module contains Danbooru class for access to API calls, authentication, build url and return JSON response.

Classes:
Danbooru – Danbooru main classs.
class pybooru.danbooru.Danbooru(site_name='', site_url='', username='', api_key='')

Bases: pybooru.pybooru._Pybooru, pybooru.api_danbooru.DanbooruApi_Mixin

Danbooru class (inherits: Pybooru and DanbooruApi_Mixin).

To initialize Pybooru, you need to specify one of these two parameters: ‘site_name’ or ‘site_url’. If you specify ‘site_name’, Pybooru checks whether there is in the list of default sites (You can get list of sites in the ‘resources’ module).

To specify a site that isn’t in list of default sites, you need use ‘site_url’ parameter and specify url.

Some actions may require you to log in. always specify two parameters to log in: ‘username’ and ‘api_key’.

site_name

Get or set site name set.

Type:str
site_url

Get or set the URL of Moebooru/Danbooru based site.

Type:str
username

Return user name.

Type:str
api_key

Return API key.

Type:str
last_call

Return last call.

Type:dict
__init__(site_name='', site_url='', username='', api_key='')

Initialize Danbooru.

Keyword Arguments:
 
  • site_name (str) – Get or set site name set.
  • site_url (str) – Get or set the URL of Moebooru/Danbooru based site.
  • username (str) – Your username of the site (Required only for functions that modify the content).
  • api_key (str) – Your api key of the site (Required only for functions that modify the content).
_get(api_call, params=None, method='GET', auth=False, file_=None)

Function to preapre API call.

Parameters:
  • api_call (str) – API function to be called.
  • params (str) – API function parameters.
  • method (str) – (Defauld: GET) HTTP method (GET, POST, PUT or DELETE)
  • file (file) – File to upload (only uploads).
Raise:
PybooruError: When ‘username’ or ‘api_key’ are not set.