Skip to content

Getting Started

RG TQ UG edited this page Feb 13, 2016 · 2 revisions

#Getting Started with Lamia

To get started, import the user module like so:

from lamia import user

The user module contains all of the basic functions and has access to the submodules. To use the user module, you will have to create an api object. You will need your Danbooru username and api key, which can be found on your profile page. Danbooru accounts are free, but they offer premium accounts.

The api object takes two parameters, user and key, which are your username and api key respectively.

To upload an image, call your_user_object.(filepath, rating, tag_string, source), where filepath is the path to your image, rating is a string that can be safe, questionable, or explicit, that describes the image, tag_string is a string of tags formatted in danbooru's tagging style, and source is the source url of the image (source is optional but recommended!).

To create a post object, call your_api_object.create_image(image_id), where image_id is the image ID of the post you want to fetch on Danbooru. To create a list of post objects from search results, call your_api_object.search_images(tag_string, pages), where tag_string is a string of tags formatted in Danbooru's search style (free Danbooru users have a limit of 2 tags, paid users can search more), and pages is the amount of pages to search (limit of 1000). This returns a list of post objects with size 24*pages (maybe less, if there isn't that many results).

To download an image, call your_post_object.download_image().

To up/downvote the image, call your_post_object.rate_post_up() or .rate_post_down(), respectively.

To flag the post for deletion, call your_post_object.flag_post(reason), where reason is a string with the reason you want the post to be deleted off of the site. You have to do this for your own posts if you want them off the site, as there is no way to delete them manually.

Clone this wiki locally