api

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleErrorResponse

func HandleErrorResponse(resp *http.Response) error

HandleErrorResponse checks an HTTP response for errors and returns a user-friendly error.

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
	Err        string
}

APIError represents an error returned by the ClickUp API.

func (*APIError) Error

func (e *APIError) Error() string

type AuthExpiredError added in v0.5.1

type AuthExpiredError struct {
	Detail string
}

AuthExpiredError indicates the API token is invalid, expired, or revoked. Detail preserves the original API response body for debugging.

func (*AuthExpiredError) Error added in v0.5.1

func (e *AuthExpiredError) Error() string

type Client

type Client struct {
	HTTPClient  *http.Client
	RateLimiter *RateLimiter
	// contains filtered or unexported fields
}

Client provides authenticated access to the ClickUp API with rate limiting.

func NewClient

func NewClient(token string) *Client

NewClient creates a new API client with the given token.

func NewTestClient added in v0.21.0

func NewTestClient(baseURL string) *Client

NewTestClient creates a Client that routes all requests to the given base URL (typically an httptest.Server). Used in tests to avoid hitting the real ClickUp API.

func (*Client) BaseURL added in v0.21.0

func (c *Client) BaseURL() string

BaseURL returns the base API URL. For production this is "https://api.clickup.com/api/v2"; for tests it points to httptest.Server.

func (*Client) BaseURLV3 added in v0.22.0

func (c *Client) BaseURLV3() string

BaseURLV3 returns the base URL for the ClickUp v3 API. For production this is "https://api.clickup.com/api/v3"; for tests it derives from the test server by replacing "/api/v2" with "/api/v3".

func (*Client) DoRequest

func (c *Client) DoRequest(req *http.Request) (*http.Response, error)

DoRequest makes a raw HTTP request to the ClickUp API.

func (*Client) Token

func (c *Client) Token() string

Token returns the API token used by this client.

func (*Client) URL added in v0.21.0

func (c *Client) URL(pathFmt string, args ...any) string

URL builds a full API URL from a relative path. Example: client.URL("task/%s", taskID) → "https://api.clickup.com/api/v2/task/abc123"

type RateLimiter

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

RateLimiter tracks ClickUp API rate limits and provides backoff.

func NewRateLimiter

func NewRateLimiter() *RateLimiter

NewRateLimiter creates a new rate limiter.

func (*RateLimiter) ShouldRetry

func (rl *RateLimiter) ShouldRetry(resp *http.Response) bool

ShouldRetry returns true if the response indicates rate limiting and the request should be retried.

func (*RateLimiter) Update

func (rl *RateLimiter) Update(resp *http.Response)

Update reads rate limit headers from a response.

func (*RateLimiter) Wait

func (rl *RateLimiter) Wait()

Wait blocks until it's safe to make another request.

Jump to

Keyboard shortcuts

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