appapi

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAPIBase      = "https://app-api.pixiv.net"
	DefaultUserAgent    = "PixivAndroidApp/5.0.234 (Android 11; Pixel 5)"
	DefaultAppOS        = "android"
	DefaultAppOSVersion = "11"
	DefaultAppVersion   = "5.0.234"
)

Variables

View Source
var ErrMalformedResponse = errors.New("app api returned a malformed response")

ErrMalformedResponse 标识成功 HTTP 响应无法构成约定 JSON,不包含原始响应体。

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Body       string
}

func (APIError) Error

func (e APIError) Error() string

type Client

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

func New

func New(opts ...Option) *Client

func (*Client) AddBookmark

func (c *Client) AddBookmark(ctx context.Context, illustID int64, restrict string, tags []string) error

AddBookmark 收藏作品。成功响应可为空,因此不走 JSON 解码路径。

func (*Client) FollowUser

func (c *Client) FollowUser(ctx context.Context, userID int64, restrict string) error

FollowUser 关注用户。

func (*Client) IllustDetail

func (c *Client) IllustDetail(ctx context.Context, id int64) (*model.IllustDetail, error)

func (*Client) IllustFollow

func (c *Client) IllustFollow(ctx context.Context, restrict string, offset int) (*model.IllustList, error)

func (*Client) IllustRanking

func (c *Client) IllustRanking(ctx context.Context, mode, date string, offset int) (*model.IllustList, error)

func (*Client) IllustRecommended

func (c *Client) IllustRecommended(ctx context.Context, offset int) (*model.IllustList, error)

func (*Client) IllustRelated

func (c *Client) IllustRelated(ctx context.Context, id int64, offset int) (*model.IllustList, error)

func (*Client) RemoveBookmark

func (c *Client) RemoveBookmark(ctx context.Context, illustID int64) error

RemoveBookmark 取消收藏作品。

func (*Client) SearchIllust

func (c *Client) SearchIllust(ctx context.Context, word, target, sort, duration string, offset int) (*model.IllustList, error)

func (*Client) SearchUser

func (c *Client) SearchUser(ctx context.Context, word string, offset int) (*model.UserPreviewList, error)

func (*Client) TrendingTagsIllust

func (c *Client) TrendingTagsIllust(ctx context.Context) (*model.TrendTags, error)

func (*Client) UgoiraMetadata

func (c *Client) UgoiraMetadata(ctx context.Context, id int64) (*model.UgoiraMetadataResult, error)

func (*Client) UnfollowUser

func (c *Client) UnfollowUser(ctx context.Context, userID int64) error

UnfollowUser 取消关注用户。

func (*Client) UserArtworks

func (c *Client) UserArtworks(ctx context.Context, userID int64, illustType string, offset int) (*model.IllustList, error)

UserArtworks 返回用户作品的单个 App API 批次。

func (*Client) UserBookmarks

func (c *Client) UserBookmarks(ctx context.Context, userID int64, restrict, tag string, maxBookmarkID int64) (*model.IllustList, error)

func (*Client) UserDetail

func (c *Client) UserDetail(ctx context.Context, userID int64) (*model.User, error)

func (*Client) UserFollowing

func (c *Client) UserFollowing(ctx context.Context, userID int64, restrict string, offset int) (*model.UserPreviewList, error)

type Option

type Option func(*Client)

func WithAccessToken

func WithAccessToken(token string) Option

WithAccessToken 注入已取得的 access token,供无需刷新流程的 SDK 调用复用 App API。

func WithBaseURL

func WithBaseURL(apiBase string) Option

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

func WithSession

func WithSession(session Session) Option

type Session

type Session interface {
	AccessToken() string
	Refresh(context.Context) error
}

Session 是 App 内容 API 仅需知道的最小认证边界。

Jump to

Keyboard shortcuts

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