Documentation
¶
Overview ¶
Package reghelp is the official Go SDK for the REGHelp Key API — push tokens (APNS, FCM), Cloudflare Turnstile, reCAPTCHA Mobile, Google Play Integrity, iCloud Hide My Email, Gmail OAuth and VoIP push, with typed errors, configurable retries and zero external dependencies.
It mirrors the Python SDK (github.com/REGHELPNET/reghelp_client) in feature coverage and method naming while following Go idioms: context-first APIs, typed errors via errors.As / errors.Is, and stdlib-only HTTP transport.
Quick start ¶
cli := reghelp.New("your_api_key")
ctx := context.Background()
bal, err := cli.GetBalance(ctx)
if err != nil {
log.Fatal(err)
}
log.Printf("balance: %.4f %s", bal.Balance, bal.Currency)
task, err := cli.GetPushToken(ctx, reghelp.PushTokenRequest{
AppName: "tgiOS",
AppDevice: reghelp.AppDeviceIOS,
})
if err != nil {
log.Fatal(err)
}
status, err := cli.WaitForResult(ctx, task.ID, reghelp.ServicePush, 180*time.Second, 2*time.Second)
if err != nil {
log.Fatal(err)
}
log.Printf("push token: %s", status.(*reghelp.PushStatusResponse).Token)
All services (Push, VoIP, Email, Integrity, Turnstile, RecaptchaMobile) are supported. See examples/basic for an end-to-end demo.
Index ¶
- Constants
- Variables
- type AnyStatus
- type AppDevice
- type AttestationStatusResponse
- type AttestationTokenRequest
- type BalanceResponse
- type Client
- func (c *Client) BaseURL() string
- func (c *Client) GetAttestationStatus(ctx context.Context, taskID string) (*AttestationStatusResponse, error)
- func (c *Client) GetAttestationToken(ctx context.Context, req AttestationTokenRequest) (*TokenResponse, error)
- func (c *Client) GetBalance(ctx context.Context) (*BalanceResponse, error)
- func (c *Client) GetEmail(ctx context.Context, req EmailRequest) (*EmailGetResponse, error)
- func (c *Client) GetEmailStatus(ctx context.Context, taskID string) (*EmailStatusResponse, error)
- func (c *Client) GetIntegrityStatus(ctx context.Context, taskID string) (*IntegrityStatusResponse, error)
- func (c *Client) GetIntegrityToken(ctx context.Context, req IntegrityTokenRequest) (*TokenResponse, error)
- func (c *Client) GetPushStatus(ctx context.Context, taskID string) (*PushStatusResponse, error)
- func (c *Client) GetPushToken(ctx context.Context, req PushTokenRequest) (*TokenResponse, error)
- func (c *Client) GetRecaptchaMobileStatus(ctx context.Context, taskID string) (*RecaptchaMobileStatusResponse, error)
- func (c *Client) GetRecaptchaMobileToken(ctx context.Context, req RecaptchaMobileRequest) (*TokenResponse, error)
- func (c *Client) GetTurnstileStatus(ctx context.Context, taskID string) (*TurnstileStatusResponse, error)
- func (c *Client) GetTurnstileToken(ctx context.Context, req TurnstileRequest) (*TokenResponse, error)
- func (c *Client) GetVoIPStatus(ctx context.Context, taskID string) (*VoipStatusResponse, error)
- func (c *Client) GetVoIPToken(ctx context.Context, req VoIPTokenRequest) (*TokenResponse, error)
- func (c *Client) HealthCheck(ctx context.Context) (bool, error)
- func (c *Client) SetPushStatus(ctx context.Context, taskID, phoneNumber string, status PushStatusType) (*SetPushStatusResult, error)
- func (c *Client) WaitForResult(ctx context.Context, taskID string, service Service, timeout time.Duration, ...) (AnyStatus, error)
- type EmailGetResponse
- type EmailRequest
- type EmailStatusResponse
- type EmailType
- type Error
- type IntegrityStatusResponse
- type IntegrityTokenRequest
- type IntegrityTokenType
- type Option
- type ProxyConfig
- type ProxyType
- type PushStatusResponse
- type PushStatusType
- type PushTokenRequest
- type RecaptchaMobileRequest
- type RecaptchaMobileStatusResponse
- type Service
- type SetPushStatusResult
- type StatusResponse
- type TaskStatus
- type TokenResponse
- type TurnstileRequest
- type TurnstileStatusResponse
- type VoIPTokenRequest
- type VoipStatusResponse
Constants ¶
const DefaultBaseURL = "https://api.reghelp.net"
DefaultBaseURL is the production REGHelp Key API endpoint.
Variables ¶
var ( ErrRateLimit = errors.New("reghelp: rate limit exceeded") ErrServiceDisabled = errors.New("reghelp: service temporarily disabled") ErrMaintenance = errors.New("reghelp: api in maintenance mode") ErrTaskNotFound = errors.New("reghelp: task not found") ErrInvalidParameter = errors.New("reghelp: invalid parameter") ErrExternalService = errors.New("reghelp: external service error") ErrUnknown = errors.New("reghelp: unknown error") ErrNetwork = errors.New("reghelp: network error") ErrTimeout = errors.New("reghelp: timeout waiting for task result") ErrInvalidJSONResult = errors.New("reghelp: invalid JSON in response") )
Sentinel error codes. Compare with errors.Is(err, reghelp.ErrUnauthorized).
Functions ¶
This section is empty.
Types ¶
type AnyStatus ¶
type AnyStatus interface {
// contains filtered or unexported methods
}
AnyStatus is the return type of WaitForResult — one of *PushStatusResponse, *VoipStatusResponse, *EmailStatusResponse, *IntegrityStatusResponse, *RecaptchaMobileStatusResponse, *TurnstileStatusResponse, *AttestationStatusResponse.
type AppDevice ¶
type AppDevice string
AppDevice identifies the target mobile platform of a request.
type AttestationStatusResponse ¶ added in v1.1.0
type AttestationStatusResponse struct {
StatusResponse
Authorization string `json:"authorization,omitempty"`
Sign string `json:"sign,omitempty"`
LeafPrivateKeyB64 string `json:"leafPrivateKeyB64,omitempty"`
KeyboxDeviceID string `json:"keyboxDeviceId,omitempty"`
}
AttestationStatusResponse is the attestation.getStatus result.
On TaskStatusDone the full SignResponse payload is returned: an X.509 certificate chain (base64-encoded DER concatenation), the optional ECDSA signature over the request's enc field, the leaf private key (PKCS#8 / base64), and the keybox device id used for debugging which keybox served the request.
type AttestationTokenRequest ¶ added in v1.1.0
type AttestationTokenRequest struct {
// AuthKey is the Google-issued challenge nonce.
// Hex or base64 (std/url-safe), 4..512 characters.
AuthKey string
// Optional 32-byte hex overrides. Empty values fall back to the
// server's zero-array placeholder (C3/C4 normalisation rule in
// attestation-server).
VerifiedBootKey string
VerifiedBootHash string
// Optional embedded APK metadata overrides. Leave zero/empty to
// use the attestation-server defaults.
APKVersionCode int
PackageName string
APKSignatureSha256 string
// Optional base64 payload to ECDSA-sign with the leaf key. The
// signature comes back as `Sign` in the status response.
Enc string
// Ref is an optional referral tag.
Ref string
// Webhook is an optional URL to receive completion notifications.
Webhook string
}
AttestationTokenRequest contains the parameters for Client.GetAttestationToken.
AuthKey is the only mandatory field — every other knob has a sensible default on the attestation-server side. The flow is generic Android Key Attestation: wraps a TEE-bound keybox from the server-side pool and returns an X.509 chain with the KeyMint attestation extension (OID 1.3.6.1.4.1.11129.2.1.17). Override package name, APK version and signature to target any Google-issued challenge.
type BalanceResponse ¶
type BalanceResponse struct {
Status string `json:"status"`
Balance float64 `json:"balance"`
Currency string `json:"currency"`
}
BalanceResponse is the result of GetBalance.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the REGHelp Key API. Construct with New; all methods are safe for concurrent use.
func (*Client) GetAttestationStatus ¶ added in v1.1.0
func (c *Client) GetAttestationStatus(ctx context.Context, taskID string) (*AttestationStatusResponse, error)
GetAttestationStatus polls an Android Key Attestation task.
func (*Client) GetAttestationToken ¶ added in v1.1.0
func (c *Client) GetAttestationToken(ctx context.Context, req AttestationTokenRequest) (*TokenResponse, error)
GetAttestationToken creates an Android Key Attestation task.
The result is asynchronous: the returned TokenResponse carries the task ID; poll GetAttestationStatus (or WaitForResult with service="attestation") until Status == TaskStatusDone.
func (*Client) GetBalance ¶
func (c *Client) GetBalance(ctx context.Context) (*BalanceResponse, error)
GetBalance returns the current account balance.
func (*Client) GetEmail ¶
func (c *Client) GetEmail(ctx context.Context, req EmailRequest) (*EmailGetResponse, error)
GetEmail allocates a temporary email address (iCloud HME or Gmail OAuth) for the given phone. The verification code is delivered asynchronously — poll via Client.WaitForResult / Client.GetEmailStatus.
func (*Client) GetEmailStatus ¶
GetEmailStatus polls an email-task for the verification code.
func (*Client) GetIntegrityStatus ¶
func (c *Client) GetIntegrityStatus(ctx context.Context, taskID string) (*IntegrityStatusResponse, error)
GetIntegrityStatus polls a Play Integrity task.
func (*Client) GetIntegrityToken ¶
func (c *Client) GetIntegrityToken(ctx context.Context, req IntegrityTokenRequest) (*TokenResponse, error)
GetIntegrityToken creates a Play Integrity attestation task.
func (*Client) GetPushStatus ¶
GetPushStatus polls a push-token task.
func (*Client) GetPushToken ¶
func (c *Client) GetPushToken(ctx context.Context, req PushTokenRequest) (*TokenResponse, error)
GetPushToken creates an asynchronous task for an APNS / FCM push token.
func (*Client) GetRecaptchaMobileStatus ¶
func (c *Client) GetRecaptchaMobileStatus(ctx context.Context, taskID string) (*RecaptchaMobileStatusResponse, error)
GetRecaptchaMobileStatus polls a mobile reCAPTCHA task.
func (*Client) GetRecaptchaMobileToken ¶
func (c *Client) GetRecaptchaMobileToken(ctx context.Context, req RecaptchaMobileRequest) (*TokenResponse, error)
GetRecaptchaMobileToken creates an asynchronous mobile reCAPTCHA task.
func (*Client) GetTurnstileStatus ¶
func (c *Client) GetTurnstileStatus(ctx context.Context, taskID string) (*TurnstileStatusResponse, error)
GetTurnstileStatus polls a Turnstile task.
func (*Client) GetTurnstileToken ¶
func (c *Client) GetTurnstileToken(ctx context.Context, req TurnstileRequest) (*TokenResponse, error)
GetTurnstileToken solves a Cloudflare Turnstile challenge.
func (*Client) GetVoIPStatus ¶
GetVoIPStatus polls a VoIP token task.
func (*Client) GetVoIPToken ¶
func (c *Client) GetVoIPToken(ctx context.Context, req VoIPTokenRequest) (*TokenResponse, error)
GetVoIPToken creates an asynchronous task for an iOS VoIP push token. On iOS both push (APNS) and VoIP tokens are required for registerDevice.
func (*Client) HealthCheck ¶
HealthCheck pings GET /health. Returns true iff the API answers 200. Does not require an API key.
func (*Client) SetPushStatus ¶
func (c *Client) SetPushStatus(ctx context.Context, taskID, phoneNumber string, status PushStatusType) (*SetPushStatusResult, error)
SetPushStatus reports a failed push-token task to enable refund. Status is one of PushStatusType values (NOSMS, FLOOD, BANNED, 2FA). PhoneNumber must be in E.164 format.
func (*Client) WaitForResult ¶
func (c *Client) WaitForResult( ctx context.Context, taskID string, service Service, timeout time.Duration, pollInterval time.Duration, ) (AnyStatus, error)
WaitForResult polls the matching getStatus endpoint until the task reaches a terminal state (done or error), the deadline elapses, or ctx is canceled.
timeout 0 → 180s (matches Python SDK default). pollInterval 0 → 2s (matches Python SDK default).
Returns the concrete *XxxStatusResponse (use AnyStatus for the interface boundary). On timeout returns ErrTimeout; on ctx cancel returns ctx.Err().
type EmailGetResponse ¶
type EmailGetResponse struct {
Status string `json:"status"`
ID string `json:"id"`
Email string `json:"email"`
Service string `json:"service"`
Product string `json:"product"`
Price float64 `json:"price"`
Balance float64 `json:"balance"`
}
EmailGetResponse is the result of GetEmail (the email is allocated immediately; the verification code is retrieved later via WaitForResult / GetEmailStatus).
type EmailRequest ¶
type EmailRequest struct {
AppName string
AppDevice AppDevice
Phone string // E.164
Type EmailType
Ref string // optional
Webhook string // optional
}
EmailRequest contains the parameters for Client.GetEmail.
type EmailStatusResponse ¶
type EmailStatusResponse struct {
StatusResponse
Email string `json:"email,omitempty"`
Code string `json:"code,omitempty"`
}
EmailStatusResponse is the email.getStatus result.
type Error ¶
type Error struct {
Status int
Code string
Message string
Raw map[string]any
// Unwrapped underlying error, if any (e.g. network/timeout).
Cause error
}
Error is the base error type returned by the SDK.
Status is the HTTP status code (or 0 for transport errors). Code mirrors the `id` field from the REGHelp error envelope when present (RATE_LIMIT, SERVICE_DISABLED, MAINTENANCE_MODE, TASK_NOT_FOUND, INVALID_PARAM, EXTERNAL_ERROR …). Raw holds the decoded error envelope for callers that need the original fields (e.g. balance on push.setStatus error).
type IntegrityStatusResponse ¶
type IntegrityStatusResponse struct {
StatusResponse
Token string `json:"token,omitempty"`
}
IntegrityStatusResponse is the integrity.getStatus result.
type IntegrityTokenRequest ¶
type IntegrityTokenRequest struct {
AppName string
AppDevice AppDevice
Nonce string // URL-safe Base64, 16..500 chars
AppVersionCode int // 1..2_147_483_647 (mandatory)
TokenType IntegrityTokenType
Ref string
Webhook string
}
IntegrityTokenRequest contains the parameters for Client.GetIntegrityToken.
AppVersionCode is mandatory since Key API v2026-05 — it must match the APK versionCode of the target app at signing time. Valid range: 1..2_147_483_647.
TokenType selects the Play Integrity flow:
- "" or IntegrityTokenTypeClassic — Classic (MEETS_STRONG_INTEGRITY, ~1-3s); the `type` parameter is omitted on the wire.
- IntegrityTokenTypeStd — Standard/Express (MEETS_DEVICE_INTEGRITY, ~200-600ms); sent as `type=std`.
type IntegrityTokenType ¶
type IntegrityTokenType string
IntegrityTokenType selects the Play Integrity flow.
CLASSIC is the default and is sent on the wire by omitting the `type` parameter (returns a long-lived strong-integrity token, ~1-3s). STD opts into the Standard/Express flow with `type=std` (returns a device-integrity token, ~200-600ms).
const ( IntegrityTokenTypeClassic IntegrityTokenType = "classic" IntegrityTokenTypeStd IntegrityTokenType = "std" )
type Option ¶
type Option func(*Client)
Option customizes the Client returned by New.
func WithBaseURL ¶
WithBaseURL overrides the API base URL (default DefaultBaseURL).
func WithHTTPClient ¶
WithHTTPClient supplies a custom *http.Client. The client must honor context cancellation — i.e., its Transport should propagate ctx deadlines.
func WithMaxRetries ¶
WithMaxRetries sets the maximum number of retry attempts on transient failures (429, network errors). Default 3.
func WithRetryDelay ¶
WithRetryDelay sets the base back-off delay between retries (default 1s). Effective delay scales as base * 2^attempt.
func WithTimeout ¶
WithTimeout sets the HTTP client's per-request timeout (default 30s). Ignored if WithHTTPClient is also passed.
func WithUserAgent ¶
WithUserAgent overrides the User-Agent header sent on every request.
type ProxyConfig ¶
type ProxyConfig struct {
Type ProxyType
Address string
Port int
Login string // optional
Password string // optional
}
ProxyConfig describes an upstream proxy for services that support it (currently only RecaptchaMobile via proxyType/proxyAddress/...).
Address up to 255 chars, Login up to 128, Password up to 256 (limits enforced by the REGHelp API since v1.2.1).
func (ProxyConfig) Validate ¶
func (p ProxyConfig) Validate() error
Validate reports whether p is structurally valid for an outgoing request.
type PushStatusResponse ¶
type PushStatusResponse struct {
StatusResponse
Token string `json:"token,omitempty"`
}
PushStatusResponse is the push.getStatus result.
type PushStatusType ¶
type PushStatusType string
PushStatusType is the failure reason for SetPushStatus refund flow.
const ( PushStatusTypeNoSMS PushStatusType = "NOSMS" PushStatusTypeFlood PushStatusType = "FLOOD" PushStatusTypeBanned PushStatusType = "BANNED" PushStatusType2FA PushStatusType = "2FA" )
type PushTokenRequest ¶
type PushTokenRequest struct {
AppName string // e.g. "tgiOS", "tg", "tg_beta", "tg_x"
AppDevice AppDevice // AppDeviceIOS / AppDeviceAndroid
AppVersion string // optional
AppBuild string // optional
Ref string // optional referral tag
Webhook string // optional notification URL
}
PushTokenRequest contains the parameters for Client.GetPushToken.
type RecaptchaMobileRequest ¶
type RecaptchaMobileRequest struct {
AppName string // e.g. "org.telegram.messenger"
AppDevice AppDevice // iOS / Android
AppKey string // reCAPTCHA site key
AppAction string // e.g. "login"
Proxy *ProxyConfig
Ref string
Webhook string
}
RecaptchaMobileRequest contains the parameters for Client.GetRecaptchaMobileToken.
type RecaptchaMobileStatusResponse ¶
type RecaptchaMobileStatusResponse struct {
StatusResponse
Token string `json:"token,omitempty"`
}
RecaptchaMobileStatusResponse is the RecaptchaMobile.getStatus result.
type SetPushStatusResult ¶
type SetPushStatusResult struct {
Success bool
// Balance is set when the server returned an updated balance on either
// "success" or recoverable "error" envelopes (e.g. refund flow).
Balance *float64
// Raw is the original decoded JSON envelope, in case the caller needs more.
Raw map[string]any
}
SetPushStatusResult is the parsed envelope returned by SetPushStatus.
type StatusResponse ¶
type StatusResponse struct {
ID string `json:"id"`
Status TaskStatus `json:"status"`
Message string `json:"message,omitempty"`
}
StatusResponse is the common shape of all *getStatus endpoints. Concrete token / code fields are populated only when Status == TaskStatusDone.
type TaskStatus ¶
type TaskStatus string
TaskStatus is the lifecycle state of an asynchronous REGHelp task.
const ( TaskStatusWait TaskStatus = "wait" TaskStatusPending TaskStatus = "pending" TaskStatusSubmitted TaskStatus = "submitted" TaskStatusRunning TaskStatus = "running" TaskStatusProcessing TaskStatus = "processing" TaskStatusDone TaskStatus = "done" TaskStatusError TaskStatus = "error" )
func (TaskStatus) IsTerminal ¶
func (s TaskStatus) IsTerminal() bool
IsTerminal reports whether the task has reached a final state.
type TokenResponse ¶
type TokenResponse struct {
Status string `json:"status"`
ID string `json:"id"`
Service string `json:"service"`
Product string `json:"product"`
Price float64 `json:"price"`
Balance float64 `json:"balance"`
}
TokenResponse is the create-task response shared by Push / VoIP / Email / Integrity / Recaptcha / Turnstile getToken endpoints.
type TurnstileRequest ¶
type TurnstileRequest struct {
URL string // page URL with the widget
SiteKey string // Turnstile site key
Action string // optional expected action
CData string // optional custom data
Proxy string // optional, "scheme://host:port"
Actor string // optional
Scope string // optional
Ref string
Webhook string
}
TurnstileRequest contains the parameters for Client.GetTurnstileToken.
type TurnstileStatusResponse ¶
type TurnstileStatusResponse struct {
StatusResponse
Token string `json:"token,omitempty"`
}
TurnstileStatusResponse is the turnstile.getStatus result.
type VoIPTokenRequest ¶
VoIPTokenRequest contains the parameters for Client.GetVoIPToken (iOS).
type VoipStatusResponse ¶
type VoipStatusResponse struct {
StatusResponse
Token string `json:"token,omitempty"`
}
VoipStatusResponse is the pushVoip.getStatus result.