api

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const BaseURL = "https://api.desearch.ai"

BaseURL is the Desearch API base URL.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArxivResult

type ArxivResult struct {
	Title   string `json:"title"`
	Link    string `json:"link"`
	Snippet string `json:"snippet"`
}

ArxivResult represents an arXiv search result.

type Client

type Client struct {
	APIKey     string
	HTTPClient *http.Client
	BaseURL    string
}

Client is a Desearch API client.

func NewClient

func NewClient(apiKey string) *Client

NewClient creates a new Desearch API client.

func (*Client) Search

func (c *Client) Search(ctx context.Context, req *SearchRequest) (*SearchResponse, error)

Search performs a non-streaming search request.

func (*Client) SearchStream

func (c *Client) SearchStream(ctx context.Context, req *SearchRequest) (*streamReadCloser, error)

SearchStream performs a streaming search request and returns an *streamReadCloser (which satisfies io.ReadCloser). The caller MUST close the returned ReadCloser when done.

type HackerNewsResult

type HackerNewsResult struct {
	Title   string `json:"title"`
	Link    string `json:"link"`
	Snippet string `json:"snippet"`
}

HackerNewsResult represents a Hacker News search result.

type RedditResult

type RedditResult struct {
	Title   string `json:"title"`
	Link    string `json:"link"`
	Snippet string `json:"snippet"`
}

RedditResult represents a Reddit search result.

type SearchRequest

type SearchRequest struct {
	Prompt               string   `json:"prompt"`
	Tools                []string `json:"tools,omitempty"`
	StartDate            *string  `json:"start_date,omitempty"`
	EndDate              *string  `json:"end_date,omitempty"`
	DateFilter           *string  `json:"date_filter,omitempty"`
	Streaming            *bool    `json:"streaming,omitempty"`
	ResultType           *string  `json:"result_type,omitempty"`
	SystemMessage        *string  `json:"system_message,omitempty"`
	ScoringSystemMessage *string  `json:"scoring_system_message,omitempty"`
	Count                *int     `json:"count,omitempty"`
}

SearchRequest represents a search request to the Desearch API.

type SearchResponse

type SearchResponse struct {
	Search           []WebResult        `json:"search,omitempty"`
	HackerNewsSearch []HackerNewsResult `json:"hacker_news_search,omitempty"`
	RedditSearch     []RedditResult     `json:"reddit_search,omitempty"`
	YoutubeSearch    []YoutubeResult    `json:"youtube_search,omitempty"`
	Tweets           []TweetResult      `json:"tweets,omitempty"`
	WikipediaSearch  []WikipediaResult  `json:"wikipedia_search,omitempty"`
	ArxivSearch      []ArxivResult      `json:"arxiv_search,omitempty"`
	Text             string             `json:"text,omitempty"`
	MinerLinkScores  map[string]string  `json:"miner_link_scores,omitempty"`
	Completion       string             `json:"completion,omitempty"`
}

SearchResponse represents a search response from the Desearch API.

func (SearchResponse) MarshalJSON

func (r SearchResponse) MarshalJSON() ([]byte, error)

MarshalJSON sorts MinerLinkScores map keys for deterministic JSON output.

func (*SearchResponse) UnmarshalJSON

func (r *SearchResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON handles both map and sorted-array formats for MinerLinkScores.

type TweetEntities

type TweetEntities struct {
	Hashtags     []TweetHashtag `json:"hashtags"`
	Symbols      []TweetSymbol  `json:"symbols"`
	URLs         []TweetURL     `json:"urls"`
	UserMentions []TweetMention `json:"user_mentions"`
	Media        []TweetMedia   `json:"media"`
	Timestamps   []string       `json:"timestamps"`
}

TweetEntities represents tweet entities (hashtags, mentions, etc.).

type TweetFaceRect

type TweetFaceRect struct {
	X int `json:"x"`
	Y int `json:"y"`
	W int `json:"w"`
	H int `json:"h"`
}

TweetFaceRect represents detected faces in tweet media.

type TweetFocusRect

type TweetFocusRect struct {
	X int `json:"x"`
	Y int `json:"y"`
	W int `json:"w"`
	H int `json:"h"`
}

TweetFocusRect represents a focus rectangle for crop.

type TweetHashtag

type TweetHashtag struct {
	Indices [2]int `json:"indices"`
	Text    string `json:"text"`
}

TweetHashtag represents a hashtag in a tweet.

type TweetMedia

type TweetMedia struct {
	ID                   string                 `json:"id_str"`
	MediaURL             string                 `json:"media_url"`
	Type                 string                 `json:"type"`
	DisplayURL           string                 `json:"display_url"`
	ExpandedURL          string                 `json:"expanded_url"`
	URL                  string                 `json:"url"`
	Indices              [2]int                 `json:"indices"`
	Sizes                TweetMediaSizes        `json:"sizes"`
	OriginalInfo         TweetOriginalInfo      `json:"original_info"`
	Features             TweetMediaFeatures     `json:"features"`
	ExtMediaAvailability TweetMediaAvailability `json:"ext_media_availability"`
	MediaKey             string                 `json:"media_key,omitempty"`
}

TweetMedia represents media attached to a tweet.

type TweetMediaAvailability

type TweetMediaAvailability struct {
	Status string `json:"status"`
}

TweetMediaAvailability represents availability status of tweet media.

type TweetMediaFeatures

type TweetMediaFeatures struct {
	Large  TweetFaceRect `json:"large"`
	Medium TweetFaceRect `json:"medium"`
	Small  TweetFaceRect `json:"small"`
	Orig   TweetFaceRect `json:"orig"`
}

TweetMediaFeatures represents detected features for tweet media.

type TweetMediaSize

type TweetMediaSize struct {
	W      int    `json:"w"`
	H      int    `json:"h"`
	Resize string `json:"resize"`
}

TweetMediaSize represents dimensions for tweet media.

type TweetMediaSizes

type TweetMediaSizes struct {
	Large  TweetMediaSize `json:"large"`
	Medium TweetMediaSize `json:"medium"`
	Small  TweetMediaSize `json:"small"`
	Thumb  TweetMediaSize `json:"thumb"`
}

TweetMediaSizes represents available sizes for tweet media.

type TweetMention

type TweetMention struct {
	Indices    [2]int `json:"indices"`
	IDStr      string `json:"id_str"`
	Name       string `json:"name"`
	ScreenName string `json:"screen_name"`
}

TweetMention represents a user mention in a tweet.

type TweetOriginalInfo

type TweetOriginalInfo struct {
	Width     int              `json:"width"`
	Height    int              `json:"height"`
	FocusRect []TweetFocusRect `json:"focus_rects,omitempty"`
}

TweetOriginalInfo represents original dimensions of tweet media.

type TweetResult

type TweetResult struct {
	ID               string         `json:"id"`
	Text             string         `json:"text"`
	URL              string         `json:"url,omitempty"`
	User             TweetUser      `json:"user"`
	LikeCount        int            `json:"like_count"`
	RetweetCount     int            `json:"retweet_count"`
	ReplyCount       int            `json:"reply_count"`
	QuoteCount       int            `json:"quote_count"`
	BookmarkCount    int            `json:"bookmark_count"`
	CreatedAt        string         `json:"created_at,omitempty"`
	Lang             string         `json:"lang,omitempty"`
	IsRetweet        bool           `json:"is_retweet,omitempty"`
	IsQuoteTweet     bool           `json:"is_quote_tweet,omitempty"`
	ConversationID   string         `json:"conversation_id,omitempty"`
	DisplayTextRange []int          `json:"display_text_range,omitempty"`
	Entities         *TweetEntities `json:"entities,omitempty"`
	ExtendedEntities *TweetEntities `json:"extended_entities,omitempty"`
	Media            []TweetMedia   `json:"media,omitempty"`
}

TweetResult represents a tweet search result.

type TweetSymbol

type TweetSymbol struct {
	Indices [2]int `json:"indices"`
	Text    string `json:"text"`
}

TweetSymbol represents a symbol/cashtag in a tweet.

type TweetURL

type TweetURL struct {
	Indices     [2]int `json:"indices"`
	URL         string `json:"url"`
	DisplayURL  string `json:"display_url"`
	ExpandedURL string `json:"expanded_url"`
}

TweetURL represents a URL in a tweet.

type TweetUser

type TweetUser struct {
	Username       string `json:"username"`
	Name           string `json:"name"`
	ID             string `json:"id_str"`
	Description    string `json:"description"`
	FollowersCount int    `json:"followers_count,omitempty"`
	FollowingCount int    `json:"following_count,omitempty"`
}

TweetUser represents a Twitter user.

type WebResult

type WebResult struct {
	Title   string `json:"title"`
	Link    string `json:"link"`
	Snippet string `json:"snippet"`
}

WebResult represents a web search result.

type WikipediaResult

type WikipediaResult struct {
	Title   string `json:"title"`
	Link    string `json:"link"`
	Snippet string `json:"snippet"`
}

WikipediaResult represents a Wikipedia search result.

type YoutubeResult

type YoutubeResult struct {
	Title   string `json:"title"`
	Link    string `json:"link"`
	Snippet string `json:"snippet"`
}

YoutubeResult represents a YouTube search result.

Jump to

Keyboard shortcuts

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