client

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// UserAgent is the Chrome user-agent string sent with all requests.
	UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"

	// DefaultDelay is the pause between consecutive API requests.
	DefaultDelay = 1 * time.Second
)

Variables

View Source
var ErrNotAuthenticated = errors.New("authentication failed — run 'deplexity login' to refresh your session")

ErrNotAuthenticated indicates the session is invalid or expired.

Functions

func RetryWithBackoff

func RetryWithBackoff(cfg RetryConfig, fn func() error) error

RetryWithBackoff executes fn with exponential backoff and jitter on failure. It stops retrying when fn returns nil or the max retries are exhausted.

Types

type Client

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

Client is an authenticated HTTP client for the Perplexity internal API.

func New

func New(session *models.SavedSession) (*Client, error)

New creates a new authenticated client from a saved session.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, dest interface{}) error

Get performs an authenticated GET request to the given API path and decodes the JSON response into dest.

func (*Client) GetRaw

func (c *Client) GetRaw(ctx context.Context, path string) ([]byte, error)

GetRaw performs an authenticated GET request and returns the raw response body.

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, body interface{}, dest interface{}) error

Post performs an authenticated POST request with a JSON body and decodes the response into dest.

func (*Client) SetDelay

func (c *Client) SetDelay(d time.Duration)

SetDelay configures the minimum time between consecutive requests.

func (*Client) SetVerbose

func (c *Client) SetVerbose(v bool)

SetVerbose enables debug output.

type RetryConfig

type RetryConfig struct {
	MaxRetries  int
	BaseBackoff time.Duration
	MaxBackoff  time.Duration
}

RetryConfig holds configuration for retry behavior.

func DefaultRetryConfig

func DefaultRetryConfig() RetryConfig

DefaultRetryConfig returns sensible defaults for retry behavior.

Jump to

Keyboard shortcuts

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