zyte

package
v0.0.0-...-1405280 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Type   string `json:"type"`
	Title  string `json:"title"`
	Status int    `json:"status"`
	Detail string `json:"detail"`
}

Error is an error from the Zyte API.

func (Error) Error

func (z Error) Error() string

func (Error) Is

func (z Error) Is(o error) bool

type LimitFunc

type LimitFunc func(n int) error

LimitFunc is called to add n to the number of requests made (may be zero), and returns an error if the limit has been reached or exceeded.

func FixedLimit

func FixedLimit(limit int) LimitFunc

FixedLimit allows a fixed number of requests.

type RetryFunc

type RetryFunc func(ctx context.Context, tries, code int) bool

RetryFunc is called with the number of retries attempted and the last response status for ban responses. It should delay and return true. It should return false to prevent a retry. It should also return false if ctx is canceled.

func RetryLimit

func RetryLimit(n int) RetryFunc

RetryLimit returns a RetryFunc with a fixed retry limit, using the recommended retry interval.

type Transport

type Transport struct {
	// APIKey is used to authenticate with Zyte. To use x402, handle it in Next.
	APIKey string

	// Retry controls retry behaviour for unsuccessful requests. If nil,
	// unsuccessful requests are not retried. It is not called for rate-limiting
	// responses, which are retried infinitely until the context is canceled.
	Retry RetryFunc

	// Limit is called for cost-incurring responses and before making requests,
	// If nil, requests are unlimited.
	Limit LimitFunc

	// FollowRedirect controls whether to follow redirects internally. This is
	// not how a [http.RoundTripper] is expected to behave, but costs less. If
	// false, beware of redirect loops.
	FollowRedirect bool

	// Next is used for making Zyte API requests. If nil,
	// [http.DefaultTransport] is used.
	Next http.RoundTripper
}

Transport implements a http.RoundTripper using the Zyte API.

func (*Transport) RoundTrip

func (z *Transport) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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