Documentation
¶
Overview ¶
Package chocodata is the official Go SDK for the Chocodata web scraping API.
The API is one GET per call:
https://api.chocodata.com/api/v1/{target}/{resource}?api_key=...
The key travels as a QUERY PARAMETER. There is no header auth: sending Authorization: Bearer or X-API-Key returns 401 (verified 2026-07-28).
Parameters are not uniform across targets, so this SDK exposes the endpoints it has verified as methods with their real parameter names, and everything else through Scrape. amazon.product takes "query", walmart.product takes "url" or "id" and rejects "query", and bing.search takes "q".
Index ¶
- Constants
- type Client
- func (c *Client) AmazonProduct(ctx context.Context, p Params) (Result, error)
- func (c *Client) AmazonSearch(ctx context.Context, p Params) (Result, error)
- func (c *Client) BingImages(ctx context.Context, p Params) (Result, error)
- func (c *Client) BingSearch(ctx context.Context, p Params) (Result, error)
- func (c *Client) EbayProduct(ctx context.Context, p Params) (Result, error)
- func (c *Client) EbaySearch(ctx context.Context, p Params) (Result, error)
- func (c *Client) InstagramProfile(ctx context.Context, p Params) (Result, error)
- func (c *Client) Scrape(ctx context.Context, target, resource string, params Params, out any) error
- func (c *Client) TiktokProfile(ctx context.Context, p Params) (Result, error)
- func (c *Client) WalmartProduct(ctx context.Context, p Params) (Result, error)
- func (c *Client) WalmartSearch(ctx context.Context, p Params) (Result, error)
- func (c *Client) YoutubeVideo(ctx context.Context, p Params) (Result, error)
- type Error
- type Option
- type Params
- type Result
Constants ¶
const ( // Version of this SDK, sent in the User-Agent. Version = "0.1.0" // DefaultBaseURL is the production API root. DefaultBaseURL = "https://api.chocodata.com/api/v1" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
BaseURL string
HTTPClient *http.Client
// MaxRetries applies to retryable failures only. Default 2.
MaxRetries int
// Debug logs each call to stderr via the Logf hook.
Debug bool
Logf func(format string, args ...any)
// contains filtered or unexported fields
}
Client talks to the Chocodata API. The zero value is not usable; call New.
func New ¶
New returns a Client. The API key is required; get one at https://chocodata.com.
func (*Client) AmazonProduct ¶
AmazonProduct fetches one product. Pass "query" (ASIN/ISBN) or "url", optionally "domain" to pick the marketplace (prices localise to it).
func (*Client) AmazonSearch ¶
AmazonSearch runs a search. Requires "query".
func (*Client) BingImages ¶
BingImages returns image results. Requires "q". safe_search "strict" (the default) also drops rows Bing flagged explicit and reports filtered_count.
func (*Client) BingSearch ¶
BingSearch returns web results. The parameter is "q", not "query".
func (*Client) EbayProduct ¶
EbayProduct fetches one listing by "url" or "id". Returns an ISO currency plus currency_symbol, so listings are comparable across marketplaces.
func (*Client) EbaySearch ¶
EbaySearch runs a search. Requires "query".
func (*Client) InstagramProfile ¶
InstagramProfile fetches a public profile. Requires "username".
func (*Client) Scrape ¶
Scrape calls any endpoint in the catalog and decodes the JSON into out, which is typically *map[string]any or a struct you define. This is the same code path the typed helpers use.
func (*Client) TiktokProfile ¶
TiktokProfile fetches a public profile by "username" or "url". A handle that no longer resolves returns a 404 item_not_found.
func (*Client) WalmartProduct ¶
WalmartProduct fetches one item. Pass "url" or "id"; it does not accept "query".
func (*Client) WalmartSearch ¶
WalmartSearch runs a search. Requires "query".
type Error ¶
Error is a structured API failure. Retryable is the server's own judgement, so a 404 is never retried while a 502 is.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithBaseURL ¶
WithBaseURL overrides the API root. Mostly for testing.
func WithHTTPClient ¶
WithHTTPClient supplies your own *http.Client, e.g. with a custom transport.
func WithMaxRetries ¶
WithMaxRetries sets the retry budget for retryable failures.