wallhaven

package
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseURL = "https://wallhaven.cc/api/v1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a Wallhaven API client

func NewClient

func NewClient(apiKey string) *Client

NewClient creates a new Wallhaven API client

func (*Client) GetWallpaper

func (c *Client) GetWallpaper(id string) (*WallpaperDetail, error)

GetWallpaper gets detailed information about a specific wallpaper

func (*Client) Search

func (c *Client) Search(params SearchParams) (*SearchResult, error)

Search searches for wallpapers

type Meta

type Meta struct {
	CurrentPage int    `json:"current_page"`
	LastPage    int    `json:"last_page"`
	PerPage     string `json:"per_page"` // Wallhaven API returns this as string
	Total       int    `json:"total"`
	Query       string `json:"query,omitempty"`
	Seed        string `json:"seed,omitempty"`
}

Meta represents pagination metadata

type SearchParams

type SearchParams struct {
	Query      string // Search query
	Categories string // Categories: general, anime, people (100/010/001)
	Purity     string // Purity: sfw, sketchy, nsfw (100/010/001)
	Sorting    string // Sorting: date_added, relevance, random, views, favorites, toplist
	Order      string // Order: desc, asc
	TopRange   string // Top range: 1d, 3d, 1w, 1M, 3M, 6M, 1y
	AtLeast    string // Minimum resolution (e.g., 1920x1080)
	Ratios     string // Aspect ratios (e.g., 16x9,16x10)
	Colors     string // Color search
	Page       int    // Page number
	Seed       string // Random seed
}

SearchParams represents search parameters for the Wallhaven API

type SearchResult

type SearchResult struct {
	Data []Wallpaper `json:"data"`
	Meta Meta        `json:"meta"`
}

SearchResult represents the search API response

type Tag

type Tag struct {
	ID         int    `json:"id"`
	Name       string `json:"name"`
	Alias      string `json:"alias"`
	CategoryID int    `json:"category_id"`
	Category   string `json:"category"`
	Purity     string `json:"purity"`
	CreatedAt  string `json:"created_at"`
}

Tag represents a wallpaper tag

type Thumbs

type Thumbs struct {
	Large    string `json:"large"`
	Original string `json:"original"`
	Small    string `json:"small"`
}

Thumbs represents thumbnail URLs

type Uploader

type Uploader struct {
	Username string            `json:"username"`
	Group    string            `json:"group"`
	Avatar   map[string]string `json:"avatar"`
}

Uploader represents the wallpaper uploader

type Wallpaper

type Wallpaper struct {
	ID         string    `json:"id"`
	URL        string    `json:"url"`
	ShortURL   string    `json:"short_url"`
	Views      int       `json:"views"`
	Favorites  int       `json:"favorites"`
	Source     string    `json:"source"`
	Purity     string    `json:"purity"`
	Category   string    `json:"category"`
	DimensionX int       `json:"dimension_x"`
	DimensionY int       `json:"dimension_y"`
	Resolution string    `json:"resolution"`
	Ratio      string    `json:"ratio"`
	FileSize   int       `json:"file_size"`
	FileType   string    `json:"file_type"`
	CreatedAt  string    `json:"created_at"`
	Colors     []string  `json:"colors"`
	Path       string    `json:"path"`
	Thumbs     Thumbs    `json:"thumbs"`
	Tags       []Tag     `json:"tags,omitempty"`
	Uploader   *Uploader `json:"uploader,omitempty"`
}

Wallpaper represents a wallpaper from the API

type WallpaperDetail

type WallpaperDetail struct {
	Data Wallpaper `json:"data"`
}

WallpaperDetail represents detailed wallpaper information

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL