api

package
v0.0.0-...-6c0f719 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	VERSION = "0.1.36"
)

Functions

This section is empty.

Types

type APIError

type APIError struct {
	ErrorCode string `json:"error_code"`
	Detail    string `json:"detail"`
	Data      any    `json:"data"`
}

type ActivateRequest

type ActivateRequest struct {
	Sitekey        string `json:"sitekey"`
	WidgetID       string `json:"widget_id"`
	WidgetAnnounce int64  `json:"widget_announce"`
	TS             int64  `json:"ts"`
	Signals        string `json:"signals"`
	SolveContext   string `json:"solve_context"`
}

type ActivateResponse

type ActivateResponse struct {
	Success bool `json:"success"`
	Data    struct {
		Activation string `json:"activation"`
		Details    struct {
			Mode string `json:"mode"`
		} `json:"details"`
	} `json:"data"`
	Error *APIError `json:"error,omitempty"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(sitekey, proxy string) (*Client, error)

func (*Client) Activate

func (c *Client) Activate() (*ActivateResponse, error)

func (*Client) Quote

func (c *Client) Quote(activation string) (*QuoteResponse, error)

func (*Client) Redeem

func (c *Client) Redeem(activation, quote string, submissions []string, solveDuration int) (*RedeemResponse, error)

func (*Client) ScrapeContext

func (c *Client) ScrapeContext() (SolveContext, error)

ScrapeContext fetches the agent iframe page and extracts the solve context variables.

func (*Client) Solve

func (c *Client) Solve() (string, error)

func (*Client) Verify

func (c *Client) Verify(token, apiKey string) (*VerifyResponse, error)

type Payment

type Payment struct {
	Entries []PaymentEntry `json:"entries"`
}

type PaymentEntry

type PaymentEntry struct {
	SolveContext string   `json:"solve_context"`
	Submissions  []string `json:"submissions"`
}

type QuoteRequest

type QuoteRequest struct {
	Sitekey        string `json:"sitekey"`
	WidgetID       string `json:"widget_id"`
	WidgetAnnounce int64  `json:"widget_announce"`
	TS             int64  `json:"ts"`
	Signals        string `json:"signals"`
	SolveContext   string `json:"solve_context"`
	Activation     string `json:"activation"`
}

type QuoteResponse

type QuoteResponse struct {
	Success bool `json:"success"`
	Data    struct {
		Quote   string `json:"quote"`
		Details struct {
			Cost int `json:"cost"`
		} `json:"details"`
	} `json:"data"`
	Error *APIError `json:"error,omitempty"`
}

type RedeemRequest

type RedeemRequest struct {
	Sitekey            string  `json:"sitekey"`
	SolveContext       string  `json:"solve_context"`
	Activation         string  `json:"activation"`
	Quote              string  `json:"quote"`
	Payment            Payment `json:"payment"`
	Signals            string  `json:"signals"`
	WidgetID           string  `json:"widget_id"`
	SolveDurationWall  int     `json:"solve_duration_wall"`
	SolveDurationAccum int     `json:"solve_duration_accumulated"`
	TS                 int64   `json:"ts"`
}

type RedeemResponse

type RedeemResponse struct {
	Success bool `json:"success"`
	Data    struct {
		RedeemToken string `json:"redeem_token"`
		Details     struct {
			ExpiresIn int `json:"expires_in"`
		} `json:"details"`
	} `json:"data"`
	Error *APIError `json:"error,omitempty"`
}

type SolveContext

type SolveContext struct {
	Version   string
	Value     string
	Nonce     uint32
	Timestamp int64
}

type VerifyRequest

type VerifyRequest struct {
	Response string `json:"response"`
	Sitekey  string `json:"sitekey"`
}

type VerifyResponse

type VerifyResponse struct {
	Success   bool `json:"success"`
	Challenge struct {
		Timestamp string `json:"timestamp"`
		Origin    string `json:"origin"`
		Data      any    `json:"data"`
	} `json:"challenge,omitempty"`
	Error *APIError `json:"error,omitempty"`
}

Jump to

Keyboard shortcuts

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