api

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMinimumDocTokens = 10000

Variables

This section is empty.

Functions

func ValidateResourceURI

func ValidateResourceURI(uri, optionalType string) (*url.URL, error)

ValidateResourceURI validates a resource URI, and optionally checks that the provided type matches the host portion of the URI.

Types

type Client

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

func New

func New(ctx context.Context, logger *slog.Logger, httpClient *http.Client) (*Client, error)

New creates a new API client, with associated rate limiting and caching.

func (*Client) SearchLibraries

func (c *Client) SearchLibraries(ctx context.Context, query string) (results []*SearchResult, err error)

SearchLibraries searches the Context7 API for libraries matching the given query. It returns a list of search results, sorted by relevance.

func (*Client) SearchLibraryDocsText

func (c *Client) SearchLibraryDocsText(
	ctx context.Context,
	resourceURI string,
	params *SearchLibraryDocsParams,
) (results string, err error)

SearchLibraryDocsText searches the Context7 API for library documentation text matching the given resource URI. Result is formatted as LLM-friendly text.

type Resource

type Resource interface {
	GetResourceURI() string
}

type SearchLibraryDocsParams

type SearchLibraryDocsParams struct {
	Topic   string   `json:"topic"`
	Tokens  int      `json:"tokens"`
	Folders []string `json:"folders"`
}

type SearchResp

type SearchResp struct {
	Results []*SearchResult `json:"results"`
}

type SearchResult

type SearchResult struct {
	ID            string    `json:"id"`
	Title         string    `json:"title"`
	Description   string    `json:"description"`
	LastUpdate    time.Time `json:"lastUpdateDate"`
	TotalTokens   int       `json:"totalTokens"`
	TotalSnippets int       `json:"totalSnippets"`
	Stars         int       `json:"stars"`
	TrustScore    float64   `json:"trustScore,omitempty"`
}

func (*SearchResult) GetResourceURI

func (s *SearchResult) GetResourceURI() string

Jump to

Keyboard shortcuts

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