import "github.com/AstraBert/linkup-go-sdk"
[Linkup](https://linkup.so\) Go SDK, providing `search` and `fetch` functionalities.
const LinkupServerUrl string = "https://api.linkup.so"
func GenerateJSONSchema[T any]() (json.RawMessage, error)
Utility function to generate a JSON schema, provided a struct type as generic type
func GetResultFromRawJSON[T any](jsonOutput string) (any, error)
Utility function to get struct-typed results from a raw JSON output
func GetResultFromSourcedOutput[T any](sourcedOutput *StructuredWithSourcesDto) (any, error)
Utility function to get struct-typed results from the Data field of a StructuredWithSources output
Additional option to be used with the fetch method for customization
type AdditionalFetchOptions struct {
// ExtractImages Defines whether the API should extract the images from the webpage in its response.
ExtractImages bool `json:"extractImages,omitempty"`
// IncludeRawHtml Defines whether the API should include the raw HTML of the webpage in its response.
IncludeRawHtml bool `json:"includeRawHtml,omitempty"`
// RenderJs Defines whether the API should render the JavaScript of the webpage.
RenderJs bool `json:"renderJs,omitempty"`
}
func DefaultAdditionalFetchOptions() AdditionalFetchOptions
Additional search options to be used with search methods for customization
type AdditionalSearchOptions struct {
// ExcludeDomains The domains you want to exclude of the search. By default, don't restrict the search.
ExcludeDomains []string `json:"excludeDomains,omitempty"`
// FromDate The date from which the search results should be considered, in ISO 8601 format (YYYY-MM-DD). It must be before `toDate`, if provided, and later than 1970-01-01.
FromDate *string `json:"fromDate,omitempty"`
// IncludeDomains The domains you want to search on. By default, don't restrict the search. You can provide up to 100 domains.
IncludeDomains []string `json:"includeDomains,omitempty"`
// IncludeImages Defines whether the API should include images in its results.
IncludeImages bool `json:"includeImages,omitempty"`
// IncludeInlineCitations Relevant only when `outputType` is `sourcedAnswer`. Defines whether the answer should include inline citations.
IncludeInlineCitations bool `json:"includeInlineCitations,omitempty"`
// IncludeSources Relevant only when `outputType` is `structured`. Defines whether the response should include sources. **Please note that it modifies the schema of the response, see below**
IncludeSources bool `json:"includeSources,omitempty"`
// MaxResults The maximum number of results to return.
MaxResults *float32 `json:"maxResults,omitempty"`
// ToDate The date until which the search results should be considered, in ISO 8601 format (YYYY-MM-DD). It must be later than `fromDate`, if provided, or than 1970-01-01.
ToDate *string `json:"toDate,omitempty"`
}
func DefaultAdditionalSearchOptions() AdditionalSearchOptions
Struct type representing the results from the `/v1/fetch` endpoint
type FetchOutput = FetchResponseDto
Struct type representing a client to perform operations with the Linkup API
type LinkupClient struct {
// contains filtered or unexported fields
}
func NewLinkupClient(apiKey string) (*LinkupClient, error)
Constructor to create a new LinkupClient instance. If the API Key is passed as an empty string, it will be loaded from the environment
func (l *LinkupClient) Fetch(url string, fetchOptions ...AdditionalFetchOptions) (*FetchOutput, error)
func (l *LinkupClient) GetBalance() (float32, error)
Get the credit balance for the account associated with the API key the client are using
func (l *LinkupClient) GetSearchResults(query string, depth SearchDepth, searchOptions ...AdditionalSearchOptions) (*SearchResultsOutput, error)
Method to query the /v1/search API endpoint with `searchResults` as output type.
func (l *LinkupClient) GetSourcedAnswer(query string, depth SearchDepth, searchOptions ...AdditionalSearchOptions) (*SourcedAnswerOutput, error)
Method to query the /v1/search API endpoint with `sourcedAnswer` as output type.
func (l *LinkupClient) GetStructuredResults(query string, depth SearchDepth, jsonSchema json.RawMessage, searchOptions ...AdditionalSearchOptions) (*StructuredOutput, error)
Method to query the /v1/search API endpoint with `structured` as output type. Use `GenerateJSONSchema` to create the JSON schema needed as an argument to this method.
Helper interface to reduce the scope of the underlying HTTP client for Linkup (mostly for testing purposes)
type LinkupHttpClient interface {
SearchWithResponse(context.Context, SearchJSONRequestBody, ...RequestEditorFn) (*SearchResponse, error)
BalanceWithResponse(context.Context, ...RequestEditorFn) (*BalanceResponse, error)
FetchWithResponse(context.Context, FetchJSONRequestBody, ...RequestEditorFn) (*FetchResponse, error)
}
String enum representing the depth that a search should have (alias type)
type SearchDepth = QuerySearchDtoDepth
Struct type representing results from the `/v1/search` endpoint when `searchResults` is used as output type
type SearchResultsOutput struct {
ImageResults []ImageSearchResultDto
TextResults []TextSearchResultDto
}
Struct type representing results from the `/v1/search` endpoint when `sourcedAnswer` is used as output type
type SourcedAnswerOutput = SourcedAnswerDto
Struct type representing results from the `/v1/search` endpoint when `structured` is used as output type
type StructuredOutput struct {
// Raw JSON output following the provided schema.
// This field is non-null only if `includeSources` is set to `false`
// and can be parsed back into the original struct type
// using the `GetResultFromRawJSON` generic function
RawJson *string
// Structured output with sources.
// This field is non-null only if `includeSources` is set to `true`
SourcedOutput *StructuredWithSourcesDto
}
Generated by gomarkdoc