API Docs License


$ go get -u

Usage Example

package main

import (


func main() {
    ctx, cancel := context.WithCancel(context.Background())
    defer cancel()

    c := derpigo.New(derpigo.WithAPIKey(os.Getenv("DERPI_API_KEY")))

    const imgID = 1330414 //

    img, interactions, err := c.GetImage(ctx, imgID)
    if err != nil {

    log.Printf("%#v", img)
    log.Printf("#%v", interactions)
Expand ▾ Collapse ▴



    Pacakge derpigo is a set of dead simple Derpibooru [1] API bindings for Go programs.




    This section is empty.


    View Source
    var (
    	ErrNeedsOneSlash = errors.New("derpigo: this needs one slash in its invocation")

      derpigo-specific errors.


      This section is empty.


      type Connection

      type Connection struct {
      	// contains filtered or unexported fields

        Connection models the connection to the Derpibooru API.

        func New

        func New(options ...Option) (c *Connection)

          New creates a new connection to the Derpibooru API.

          func (*Connection) DeleteImage

          func (c *Connection) DeleteImage(ctx context.Context, id, why string) error

            DeleteImage deletes an image from the booru. Needs assistant/mod/admin API key.

            This is useful for handling morons scriptedly. There seems to be a lot of them lately. This is a shame.

            func (*Connection) GetFilter

            func (c *Connection) GetFilter(ctx context.Context, id int64) (f *Filter, err error)

              GetFilter returns a filter or an error.

              func (*Connection) GetForum

              func (c *Connection) GetForum(ctx context.Context, name string) (*Forum, error)

                GetForum returns a forum structure, all ready to go!

                Please note that the creators of this library are not responsible for any mental scarring that may result thanks to usage of this site's API.

                func (*Connection) GetImage

                func (c *Connection) GetImage(ctx context.Context, id int) (*Image, []Interaction, error)

                  GetImage grabs image information with the api key of the recieving Connection. If something fails it returns an error.

                  func (*Connection) GetThreadByName

                  func (c *Connection) GetThreadByName(ctx context.Context, name string) ([]Post, error)

                    GetThreadByName returns a Thread based on the given thread name.

                    func (*Connection) GetUser

                    func (c *Connection) GetUser(ctx context.Context, id string) (*User, error)

                      GetUser returns information on a user based on their ID.

                      type DupeReportModifier

                      type DupeReportModifier struct {
                      	ID           int64  `json:"id"`
                      	Name         string `json:"name"`
                      	Avatar       string `json:"avatar"`
                      	CommentCount int    `json:"comment_count"`
                      	UploadCount  int    `json:"upload_count"`
                      	PostCount    int    `json:"post_count"`
                      	TopicCount   int    `json:"topic_count"`

                        DupeReportModifier is the weighting of the an image duplicate report.

                        type DuplicateReport

                        type DuplicateReport struct {
                        	ID                  int64               `json:"id"`
                        	State               string              `json:"state"`
                        	Reason              string              `json:"reason"`
                        	ImageIDNumber       int                 `json:"image_id_number"`
                        	TargetImageIDNumber int                 `json:"target_image_id_number"`
                        	User                interface{}         `json:"user"`
                        	CreatedAt           string              `json:"created_at"`
                        	Modifier            *DupeReportModifier `json:"modifier"`

                          DuplicateReport is a duplicate image report.

                          type Error

                          type Error struct {
                          	Underlying error
                          	RequestID  string

                            Error is a combination of a Go error and a Derpibooru request ID to help with debugging failed API calls with the Derpibooru staff.

                            func NewError

                            func NewError(underlying error, resp *http.Response) *Error

                              NewError wraps an error with the X-Request-Id.

                              func (*Error) Error

                              func (e *Error) Error() string

                                Error satisfies the error interface.

                                type Filter

                                type Filter struct {
                                	ID               int64    `json:"id"`
                                	Name             string   `json:"name"`
                                	Description      string   `json:"description"`
                                	HiddenTagIds     []int64  `json:"hidden_tag_ids"`
                                	SpoileredTagIds  []int64  `json:"spoilered_tag_ids"`
                                	SpoileredTags    []string `json:"spoilered_tags"`
                                	HiddenTags       []string `json:"hidden_tags"`
                                	HiddenComplex    string   `json:"hidden_complex"`
                                	SpoileredComplex string   `json:"spoilered_complex"`
                                	Public           bool     `json:"public"`
                                	System           bool     `json:"system"`
                                	UserCount        int      `json:"user_count"`
                                	UserID           int64    `json:"user_id"`

                                  Filter is an image or tag filter.

                                  These are really fucking important. If you filter things badly, shit's not gonna be fun.

                                  type Forum

                                  type Forum struct {
                                  	Topics []struct {
                                  		Slug            string    `json:"slug"`
                                  		Title           string    `json:"title"`
                                  		Sticky          bool      `json:"sticky"`
                                  		CreatedAt       time.Time `json:"created_at"`
                                  		UpdatedAt       time.Time `json:"updated_at"`
                                  		ForumID         string    `json:"forum_id"`
                                  		LastRepliedToAt string    `json:"last_replied_to_at"`
                                  		ID              string    `json:"id"`
                                  	} `json:"topics"`

                                    Fourm is one of the discussion forums on Derpibooru.

                                    type Image

                                    type Image struct {
                                    	ID               int                `json:"id"`
                                    	CreatedAt        time.Time          `json:"created_at"`
                                    	UpdatedAt        time.Time          `json:"updated_at"`
                                    	DuplicateReports []*DuplicateReport `json:"duplicate_reports"`
                                    	FirstSeenAt      time.Time          `json:"first_seen_at"`
                                    	UploaderID       interface{}        `json:"uploader_id"`
                                    	FileName         string             `json:"file_name"`
                                    	Description      string             `json:"description"`
                                    	Uploader         string             `json:"uploader"`
                                    	Image            string             `json:"image"`
                                    	Score            int                `json:"score"`
                                    	Upvotes          int                `json:"upvotes"`
                                    	Downvotes        int                `json:"downvotes"`
                                    	Faves            int                `json:"faves"`
                                    	CommentCount     int                `json:"comment_count"`
                                    	Tags             string             `json:"tags"`
                                    	TagIds           []int64            `json:"tag_ids"`
                                    	Width            int                `json:"width"`
                                    	Height           int                `json:"height"`
                                    	AspectRatio      float64            `json:"aspect_ratio"`
                                    	OriginalFormat   string             `json:"original_format"`
                                    	MimeType         string             `json:"mime_type"`
                                    	Sha512Hash       string             `json:"sha512_hash"`
                                    	OrigSha512Hash   string             `json:"orig_sha512_hash"`
                                    	SourceURL        string             `json:"source_url"`
                                    	Representations  struct {
                                    		ThumbTiny  string `json:"thumb_tiny"`
                                    		ThumbSmall string `json:"thumb_small"`
                                    		Thumb      string `json:"thumb"`
                                    		Small      string `json:"small"`
                                    		Medium     string `json:"medium"`
                                    		Large      string `json:"large"`
                                    		Tall       string `json:"tall"`
                                    		Full       string `json:"full"`
                                    	} `json:"representations"`
                                    	IsRendered   bool          `json:"is_rendered"`
                                    	IsOptimized  bool          `json:"is_optimized"`
                                    	Interactions []interface{} `json:"interactions"`

                                      Image is an image on the Booru.

                                      type Interaction

                                      type Interaction struct {
                                      	ID              int    `json:"id"`
                                      	InteractionType string `json:"interaction_type"`
                                      	Value           string `json:"value"`
                                      	UserID          int    `json:"user_id"`
                                      	ImageID         int    `json:"image_id"`

                                        Interaction is the "hard copy" of user interactions on images. Possible kinds include (but are not limited to):

                                        - down
                                        - up
                                        - faved

                                        type Option

                                        type Option func(*Connection)

                                          Option is a function that modifies the given Connection.

                                          func WithAPIKey

                                          func WithAPIKey(apiKey string) Option

                                            WithAPIKey specifies a given API key for all API calls.

                                            func WithDomain

                                            func WithDomain(domain string) Option

                                              WithDomain specifies a different base domain to do API calls against

                                              type Post

                                              type Post struct {
                                              	ID      int64  `json:"id"`
                                              	TopicID int64  `json:"topic_id"`
                                              	Author  string `json:"author"`
                                              	Subject string `json:"subject"`
                                              	// A warning to people. The forums are a very scary place on Derpibooru.
                                              	// Some areas are containement. This is the unformatted Textile version
                                              	// of the body.
                                              	Body string `json:"body"`

                                                Post is an individual forum post.

                                                type User

                                                type User struct {
                                                	ID           int64  `json:"id"`
                                                	Name         string `json:"name"`
                                                	Avatar       string `json:"avatar"`
                                                	CommentCount int    `json:"comment_count"`
                                                	UploadCount  int    `json:"upload_count"`
                                                	PostCount    int    `json:"post_count"`
                                                	TopicCount   int    `json:"topic_count"`

                                                  User represents one of the crazy, crazy people that populate this site.


                                                  Path Synopsis
                                                  Command db-massdelete handles mass deletion of derpibooru images.
                                                  Command db-massdelete handles mass deletion of derpibooru images.
                                                  Command db-archive downloads and serves images from Derpibooru, fetched via derpigo and stored in boltdb.
                                                  Command db-archive downloads and serves images from Derpibooru, fetched via derpigo and stored in boltdb.