Documentation
¶
Index ¶
- Constants
- Variables
- func RetryWithBackoff(cfg RetryConfig, fn func() error) error
- type Client
- func (c *Client) Get(ctx context.Context, path string, dest interface{}) error
- func (c *Client) GetRaw(ctx context.Context, path string) ([]byte, error)
- func (c *Client) Post(ctx context.Context, path string, body interface{}, dest interface{}) error
- func (c *Client) SetDelay(d time.Duration)
- func (c *Client) SetVerbose(v bool)
- type RetryConfig
Constants ¶
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 ¶
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 ¶
Get performs an authenticated GET request to the given API path and decodes the JSON response into dest.
func (*Client) GetRaw ¶
GetRaw performs an authenticated GET request and returns the raw response body.
func (*Client) Post ¶
Post performs an authenticated POST request with a JSON body and decodes the response into dest.
type RetryConfig ¶
RetryConfig holds configuration for retry behavior.
func DefaultRetryConfig ¶
func DefaultRetryConfig() RetryConfig
DefaultRetryConfig returns sensible defaults for retry behavior.