Documentation
¶
Overview ¶
Package axioapi is the official Go SDK for the AxioAPI REST API (https://axioapi.com): temp mail API, receive SMS and OTP API, email validation API, proxy API, SEO API (keyword data and backlink API), search API and social scraper APIs.
c, _ := axioapi.New("ak_...")
data, err := c.Group("seo").Call(ctx, "keywordMetrics", axioapi.Params{"keywords": []string{"api gateway"}, "country": "us"})
Index ¶
- Constants
- Variables
- type APIError
- type Client
- func (c *Client) Call(ctx context.Context, operation string, params Params) (json.RawMessage, error)
- func (c *Client) CallBinary(ctx context.Context, operation string, params Params) ([]byte, error)
- func (c *Client) CallInto(ctx context.Context, operation string, params Params, out any) error
- func (c *Client) Group(name string) *Group
- func (c *Client) Operations() map[string]Operation
- func (c *Client) Request(ctx context.Context, method, path string, query url.Values, body any) (*Response, error)
- func (c *Client) Resolve(group, name string) (string, bool)
- type ConnectionError
- type Group
- type Operation
- type Option
- type Params
- type Response
Constants ¶
const Version = "1.0.0"
Version is the SDK version.
Variables ¶
var ( ErrAuthentication = errors.New("axioapi: authentication failed") ErrInsufficientCredits = errors.New("axioapi: insufficient credits") ErrNotFound = errors.New("axioapi: not found") ErrValidation = errors.New("axioapi: validation failed") ErrRateLimit = errors.New("axioapi: rate limited") )
Sentinel errors for errors.Is.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
Status int
Code string
Message string
RequestID string
// Fields holds per-field messages for 422 responses.
Fields map[string][]string
// RetryAfter is in seconds for 429 responses, 0 when the server sent none.
RetryAfter float64
Body json.RawMessage
}
APIError is returned for every non-2xx response. Use errors.Is with the Err* sentinels or errors.As to read fields.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the AxioAPI. It is safe for concurrent use.
func New ¶
New creates a client. An empty apiKey falls back to the AXIOAPI_KEY environment variable.
func (*Client) Call ¶
func (c *Client) Call(ctx context.Context, operation string, params Params) (json.RawMessage, error)
Call runs an operation by capability key (for example "seo.keyword-metrics") and returns its data.
func (*Client) CallBinary ¶
CallBinary runs an operation that returns a file (image or audio).
func (*Client) Group ¶
Group scopes calls to one API group, for example c.Group("seo").Call(ctx, "keywordMetrics", params).
func (*Client) Operations ¶
Operations returns the registry of every operation.
type ConnectionError ¶
type ConnectionError struct{ Message string }
ConnectionError means the request never produced an HTTP response (DNS, TLS, timeout).
func (*ConnectionError) Error ¶
func (e *ConnectionError) Error() string
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group is a set of operations that share a prefix.
type Operation ¶
type Operation struct {
Key string `json:"-"`
Method string `json:"method"`
Path string `json:"path"`
Summary string `json:"summary"`
Cost *float64 `json:"cost"`
PathParams []string `json:"path_params"`
Query []string `json:"query"`
Body []string `json:"body"`
Binary bool `json:"binary"`
}
Operation describes one API operation from the registry.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithHTTPClient ¶
WithHTTPClient replaces the default http.Client (set your own Timeout or Transport).
func WithMaxRetries ¶
WithMaxRetries sets retries for 429 and, on GET/DELETE, 502/503/504 and network errors. Default 2.
func WithUserAgent ¶
WithUserAgent overrides the User-Agent header.
type Response ¶
type Response struct {
Status int
Header http.Header
// Data is the "data" field of the envelope (nil for files).
Data json.RawMessage
// Envelope is the whole JSON body (nil for files).
Envelope json.RawMessage
// Bytes is set instead of Data when the response is not JSON (images, audio).
Bytes []byte
}
Response is a raw API response.