douyin

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package douyin is the library behind the douyin command: the HTTP client, request shaping, and the typed data models for Douyin (抖音) hot search.

The client fetches trending topics from the public iesdouyin API at https://www.iesdouyin.com/web/api/v2/hotsearch/billboard/word/. No authentication is required. It sets a real browser User-Agent (the API is UA-sensitive), paces requests, and retries transient 429/5xx errors with exponential backoff.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client talks to the Douyin iesdouyin API.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured by cfg.

func (*Client) Hot

func (c *Client) Hot(ctx context.Context, limit int) ([]Topic, error)

Hot fetches Douyin hot-search trending topics. limit <= 0 returns all items (up to 50 as the API provides). Topics are ranked 1-based.

type Config

type Config struct {
	BaseURL   string
	UserAgent string
	Rate      time.Duration
	Retries   int
	Timeout   time.Duration
}

Config holds constructor parameters for Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults. The UserAgent mimics a real browser because iesdouyin returns errors on non-browser UAs.

type Topic

type Topic struct {
	Rank     int    `json:"rank"`
	Word     string `json:"word"`
	HotValue int64  `json:"hot_value"`
	Label    string `json:"label"`
}

Topic is one Douyin hot-search entry as returned to callers.

Jump to

Keyboard shortcuts

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