Documentation
¶
Overview ¶
Package synoppy is the official Go SDK for the Synoppy web-data API — scrape, screenshot, crawl, map, extract, classify, enrich (brand), images, and search on one key.
Every successful response carries metered billing fields: use Result.CreditsUsed and Result.CreditsRemaining to read them.
Index ¶
- Constants
- type APIError
- type BrandInput
- type Client
- func (c *Client) Brand(ctx context.Context, in BrandInput) (Result, error)
- func (c *Client) Classify(ctx context.Context, url string, labels []string) (Result, error)
- func (c *Client) Crawl(ctx context.Context, url string, limit int) (Result, error)
- func (c *Client) Enrich(ctx context.Context, url string) (Result, error)
- func (c *Client) Extract(ctx context.Context, url, prompt string) (Result, error)
- func (c *Client) ExtractWithSchema(ctx context.Context, url, prompt string, schema json.RawMessage) (Result, error)
- func (c *Client) Images(ctx context.Context, url string) (Result, error)
- func (c *Client) Map(ctx context.Context, url string) (Result, error)
- func (c *Client) Read(ctx context.Context, url string, opts map[string]any) (Result, error)
- func (c *Client) Screenshot(ctx context.Context, url string, opts map[string]any) (Result, error)
- func (c *Client) Search(ctx context.Context, opts SearchOptions) (*SearchResponse, error)
- type Option
- type Result
- type SearchOptions
- type SearchResponse
- type SearchResult
Constants ¶
const Version = "1.1.1"
Version is the SDK version, sent as part of the User-Agent header.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BrandInput ¶
BrandInput selects how a brand is looked up. Exactly one of URL, Domain, or Email should be set; the API maps a work Email to its Domain. If more than one is set, URL takes precedence, then Domain, then Email.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Synoppy API client.
func New ¶
New creates a Client. apiKey is required and must be a Synoppy key (prefixed "syn_"), sent as "Authorization: Bearer syn_...".
func (*Client) Brand ¶
Brand (POST /api/brand) resolves a URL, domain, or work email into a brand profile. See Enrich for the response shape.
func (*Client) Classify ¶
Classify (POST /api/classify) returns an industry classification or a best-matching label (requires a key).
With labels == nil the default NAICS/SIC mode runs, returning data{industry, naics_code, naics_title, naics_sector, naics_sector_title, naics_valid, sic_code, sic_title, sic_division, sic_division_title, sic_valid, categories, confidence}. When labels are supplied, the result data is {label, matched, confidence, reasoning}. Both modes carry creditsUsed/creditsRemaining.
func (*Client) Crawl ¶
Crawl (POST /api/crawl) reads each page of a site (requires a key). limit is clamped by the API to 1-25; a limit <= 0 uses the API default. The result carries domain, discovered, count, pages[{url,title,markdown,words}], credits, latencyMs, and creditsUsed/creditsRemaining.
func (*Client) Enrich ¶
Enrich (POST /api/brand) resolves a URL into a brand profile. It is a convenience wrapper over Brand for the common url case.
The result carries domain, name, description, logo, colors ([]string), fonts ([]string), address, socials ([{label,url}]), bytesIn, latencyMs, and creditsUsed/creditsRemaining.
func (*Client) Extract ¶
Extract (POST /api/extract) returns structured JSON via AI (requires a key). prompt may be empty; it is sent under the "prompt" key (the API also accepts the "instruction" alias). The result carries url, model, data, metadata, truncated, usage{inputTokens,outputTokens}, latencyMs, and creditsUsed/creditsRemaining.
func (*Client) ExtractWithSchema ¶ added in v1.1.0
func (c *Client) ExtractWithSchema(ctx context.Context, url, prompt string, schema json.RawMessage) (Result, error)
ExtractWithSchema is Extract with an optional JSON Schema that constrains the output to a caller-defined shape (for example a Zod schema's JSON-Schema output). When schema is nil this behaves exactly like Extract; otherwise the schema is sent under the "schema" key and the returned data conforms to it.
func (*Client) Images ¶
Images (POST /api/images) returns every image on a page. The result carries url, count, images ([{src,alt,width,height}]), bytesIn, latencyMs, and creditsUsed/creditsRemaining.
func (*Client) Map ¶
Map (POST /api/map) discovers every URL on a domain. The result carries domain, urls ([]string), count, source ("sitemap"|"links"), latencyMs, and creditsUsed/creditsRemaining.
func (*Client) Read ¶
Read (POST /api/scrape) fetches a URL and returns clean markdown / HTML / text plus page metadata.
opts may include any of: "formats" ([]string of "markdown"|"html"|"text"), "onlyMainContent" (bool), "timeoutMs" (number), "render" (bool or "auto"), "waitMs" (number). The result carries metadata{title, description, language, siteName, author, ogImage, sourceUrl, statusCode, wordCount, fetchedAt, rendered, bytesIn}, markdown/html/text, renderMs, latencyMs, and creditsUsed/creditsRemaining.
func (*Client) Screenshot ¶
Screenshot (POST /api/screenshot) captures a PNG of a page and returns it as a data URL in result["screenshot"].
opts may include any of: "fullPage" (bool), "waitMs" (number), "timeoutMs" (number). The result carries screenshot, sourceUrl, statusCode, fullPage, latencyMs, and creditsUsed/creditsRemaining. The endpoint can return 503 RENDER_UNAVAILABLE, surfaced as an *APIError.
func (*Client) Search ¶ added in v1.1.0
func (c *Client) Search(ctx context.Context, opts SearchOptions) (*SearchResponse, error)
Search (POST /api/search) runs a web search for agents and returns clean source URLs (requires a key). With opts.Markdown the clean markdown of each result is read in the same trip. opts.Query is required.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithBaseURL ¶
WithBaseURL overrides the API base URL (default https://synoppy.com).
func WithHTTPClient ¶
WithHTTPClient sets a custom *http.Client.
type Result ¶
Result is a decoded JSON response body. Because the underlying type is map[string]any, every field returned by the API is reachable by key (for example result["metadata"], result["pages"], result["screenshot"]). Helper accessors are provided for the billing fields common to every successful response.
func (Result) CreditsRemaining ¶
CreditsRemaining reports the credits left on the key after the call. The API may return null (unmetered/unlimited keys), in which case the second return value is false even though the field was present.
func (Result) CreditsUsed ¶
CreditsUsed reports how many credits the call consumed. The boolean is false when the field is absent.
type SearchOptions ¶ added in v1.1.0
type SearchOptions struct {
// Query is the search query (required).
Query string `json:"query"`
// MaxResults bounds the number of results returned (1-15, default 5).
MaxResults int `json:"maxResults,omitempty"`
// Markdown also reads each result to clean markdown, in one trip. Billed
// as additional reads.
Markdown bool `json:"markdown,omitempty"`
// IncludeDomains restricts results to these domains.
IncludeDomains []string `json:"includeDomains,omitempty"`
// ExcludeDomains drops results from these domains.
ExcludeDomains []string `json:"excludeDomains,omitempty"`
// Fanout expands the query into variations for higher recall (costs more).
Fanout bool `json:"fanout,omitempty"`
}
SearchOptions configures Search. Query is required; the remaining fields are optional and omitted from the request when left at their zero value.
type SearchResponse ¶ added in v1.1.0
type SearchResponse struct {
Success bool `json:"success"`
Query string `json:"query"`
Results []SearchResult `json:"results"`
LatencyMs int `json:"latencyMs"`
CreditsUsed int `json:"creditsUsed"`
CreditsRemaining *int `json:"creditsRemaining"`
}
SearchResponse is the decoded response from Search. CreditsRemaining is nil for unmetered/unlimited keys (the API returns null).
type SearchResult ¶ added in v1.1.0
type SearchResult struct {
Title string `json:"title"`
URL string `json:"url"`
Snippet string `json:"snippet"`
Markdown string `json:"markdown,omitempty"`
}
SearchResult is a single hit returned by Search. Markdown is populated only when SearchOptions.Markdown was set.