buyproxy

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 14 Imported by: 1 module, 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.

README

BuyProxy Go SDK — Residential Proxy API Client for Golang

Go Reference CI Go Report Card license

The official Go SDK for BuyProxy: generate residential, mobile, ISP and datacenter proxies, check bandwidth, top up by card or crypto, and manage reseller customers. Idiomatic Go — context on every call, errors.Is sentinels, and zero third-party dependencies.

Keywords: residential proxies · rotating proxies · mobile proxies · ISP proxies · datacenter proxies · SOCKS5 · proxy API · web scraping · proxy reseller

Features

  • Standard library only — no transitive dependencies
  • context.Context on every call; safe for concurrent use
  • errors.Is(err, buyproxy.ErrInsufficientBandwidth) and friends
  • Proxy.HTTPClient() returns an *http.Client already routed through the proxy

Installation

go get github.com/DishantSinghDev2/buyproxy-go

Go 1.21+. Standard library only.

Quick start

package main

import (
	"context"
	"fmt"
	"io"
	"log"

	buyproxy "github.com/DishantSinghDev2/buyproxy-go"
)

func main() {
	ctx := context.Background()
	client := buyproxy.New() // reads BUYPROXY_API_KEY — or buyproxy.WithAPIKey("bp_key_…")

	plans, err := client.Plans.List(ctx)
	if err != nil || len(plans) == 0 {
		log.Fatal("no plans yet — top up first: ", err)
	}

	res, err := client.Plans.Generate(ctx, plans[0].ID, &buyproxy.GenerateParams{Country: "US", City: "Austin", Count: 5})
	if err != nil {
		log.Fatal(err)
	}

	resp, err := res.Proxies[0].HTTPClient().Get("https://api.ipify.org")
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()
	ip, _ := io.ReadAll(resp.Body)
	fmt.Println("exit IP:", string(ip))
}

Set StickyMinutes: 10 to keep the same IP for ten minutes, or Protocol: buyproxy.SOCKS5 for SOCKS5.

Using the proxies with your stack

net/http
proxy := res.Proxies[0]

client := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxy.URL())}}
// or simply: client := proxy.HTTPClient()
Colly
c := colly.NewCollector()
c.SetProxyFunc(http.ProxyURL(res.Proxies[0].URL()))
chromedp / Rod
opts := append(chromedp.DefaultExecAllocatorOptions[:],
	chromedp.ProxyServer(res.Proxies[0].URL().Host)) // add auth via a fetch.AuthRequired handler
curl & shell
fmt.Println(res.Proxies[0].Curl())  // ready-to-run curl command
fmt.Println(res.Proxies[0].Env())   // HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, …

Buy bandwidth (card & crypto)

// Buy 10 GB of Core Residential by card — open PayURL in a browser
checkout, _ := client.Topup.Card(ctx, buyproxy.TopupCardParams(buyproxy.ProductResidential, 10))
fmt.Println(checkout.PayURL)

// Or subscribe to a plan (monthly or yearly)
client.Topup.Card(ctx, buyproxy.PlanCardParams(buyproxy.PlanPro, buyproxy.Yearly))

// Crypto (pay-as-you-go top-ups only)
client.Topup.Crypto(ctx, buyproxy.ProductResidential, 50)

// Wait for the payment to settle — GB appears on client.Balances.List right after
tx, _ := client.Transactions.Wait(ctx, *checkout.TransactionID, 3*time.Second)
fmt.Println(tx.Status) // "succeeded"

Card payments run through Stripe Checkout; crypto is available for pay-as-you-go top-ups.

Reseller API

Build a proxy product on top of BuyProxy: buy bandwidth in bulk into a reseller pool, create isolated customers, and allocate GB to them. Needs a bp_live_ key on a Business plan or higher.

reseller := buyproxy.New(buyproxy.WithAPIKey("bp_live_…"))

reseller.Reseller.Pool.TopupCard(ctx, buyproxy.PoolTopupParams{ProductKey: buyproxy.ProductResidential, GB: 500})
customer, _ := reseller.Reseller.Customers.Create(ctx, "Acme Inc") // isolated sub-account

reseller.Reseller.Customers.Allocate(ctx, customer.Username, buyproxy.AllocateParams{
	ProductKey: buyproxy.ProductResidential, GB: 20, IdempotencyKey: "order-1042", // safe to retry
})

detail, _ := reseller.Reseller.Customers.Get(ctx, customer.Username)
res, _ := reseller.Reseller.Customers.Generate(ctx, customer.Username, buyproxy.CustomerGenerateParams{
	PlanID: detail.Plans[0].ID, GenerateParams: buyproxy.GenerateParams{Country: "DE"},
})

reseller.Reseller.Customers.Update(ctx, customer.Username, buyproxy.CustomerUpdate{Status: buyproxy.CustomerSuspended})

Error handling

_, err := client.Plans.Generate(ctx, planID, nil)

switch {
case errors.Is(err, buyproxy.ErrInsufficientBandwidth):
	log.Println("Out of GB — top up first")
case errors.Is(err, buyproxy.ErrRateLimited):
	var apiErr *buyproxy.APIError
	errors.As(err, &apiErr)
	log.Printf("Slow down; retry in %s", apiErr.RetryAfter)
case errors.Is(err, buyproxy.ErrAuthentication):
	log.Println("Check your API key")
}

Non-2xx responses are *buyproxy.APIError (with Status, Message, Body); network failures are *buyproxy.ConnectionError.

Configuration

client := buyproxy.New(
	buyproxy.WithAPIKey("bp_key_…"),            // default: $BUYPROXY_API_KEY
	buyproxy.WithBaseURL("https://www.buyproxy.org"),
	buyproxy.WithHTTPClient(&http.Client{Timeout: 10 * time.Second}),
	buyproxy.WithMaxRetries(2),                  // 429s always; 5xx only for safe requests
)

API overview

Capability Call
Catalog & prices client.Products.List(ctx)
Account client.Account.Get(ctx)
Spendable GB per product client.Balances.List(ctx)
Plans client.Plans.List(ctx)
Generate proxies client.Plans.Generate(ctx, planID, params)
Card checkout client.Topup.Card(ctx, params)
Crypto checkout client.Topup.Crypto(ctx, product, gb)
Payments client.Transactions.List/Get/Wait
Create an account client.Auth.Signup/VerifyOTP/ResendOTP
Reseller summary client.Reseller.Me(ctx)
Customers client.Reseller.Customers.List/Create/Get/Update/Usage/Allocate/Generate
Reseller pool client.Reseller.Pool.Get/TopupCard/TopupCrypto

Full endpoint reference: https://www.buyproxy.org/docs/api-reference/introduction · OpenAPI spec: https://www.buyproxy.org/openapi.yaml

FAQ

How do I get an API key? Create a free account at buyproxy.org, then open Dashboard → API keys. Personal keys start with bp_key_; reseller keys (Business plan and above) start with bp_live_. You can create the account from code (signup + verify otp), but keys are issued from the dashboard.

What's the difference between a personal and a reseller key? A personal key (bp_key_…) manages your own bandwidth: balances, plans, generating proxies, top-ups and payments. A reseller key (bp_live_…) manages your customers: create isolated sub-accounts, buy bandwidth into a pool, allocate it, suspend or reactivate, and generate proxies on their behalf.

Which proxy types are available? Core Residential, Premium Residential, ISP Rotating, Mobile, Datacenter IPv4 and IPv6 — call the catalog endpoint for the live list and per-GB prices (from $1.99/GB).

Do generated proxies expire, and when is bandwidth used? Generating a proxy is free and instant; bandwidth is only consumed when traffic flows through it. Lines are on-demand — generate fresh ones rather than storing them.

What are the rate limits? 60 requests per minute per API key. The SDK honours Retry-After and retries rate-limited requests automatically.

Is it free to use the SDK? Yes — the SDK is MIT-licensed. You pay only for the proxy bandwidth you buy.

Other BuyProxy SDKs

Node.js · Python · Go · PHP · Ruby · Java · .NET · Rust · CLI

All SDKs are checked against the same request log, so behaviour is identical across languages — see buyproxy-sdks.

Development

go vet ./... && go test -race ./...

Issues and pull requests are welcome — see CONTRIBUTING.md. Security reports: SECURITY.md.

License

MIT © BuyProxy

Documentation

Overview

Package buyproxy is the official Go SDK for BuyProxy — residential, mobile, ISP and datacenter proxies over a typed API.

client := buyproxy.New() // reads BUYPROXY_API_KEY
plans, _ := client.Plans.List(ctx)
res, _ := client.Plans.Generate(ctx, plans[0].ID, &buyproxy.GenerateParams{Country: "US", Count: 5})
resp, _ := res.Proxies[0].HTTPClient().Get("https://api.ipify.org")

Index

Constants

View Source
const DefaultBaseURL = "https://www.buyproxy.org"

DefaultBaseURL is the production API.

View Source
const Version = "1.0.0"

Version is the SDK version, sent in the User-Agent.

Variables

View Source
var (
	ErrValidation            = errors.New("buyproxy: invalid request")
	ErrAuthentication        = errors.New("buyproxy: authentication failed")
	ErrInsufficientBandwidth = errors.New("buyproxy: insufficient bandwidth")
	ErrForbidden             = errors.New("buyproxy: forbidden")
	ErrNotFound              = errors.New("buyproxy: not found")
	ErrRateLimited           = errors.New("buyproxy: rate limited")
	ErrServer                = errors.New("buyproxy: server error")
)

Sentinel errors for use with errors.Is:

if errors.Is(err, buyproxy.ErrInsufficientBandwidth) { ... }

Functions

This section is empty.

Types

type APIError

type APIError struct {
	// HTTP status code.
	Status int
	// Message is the API's own error text.
	Message string
	// Body is the raw response body.
	Body []byte
	// RetryAfter is set on 429 when the API said how long to wait.
	RetryAfter time.Duration
}

APIError is returned for every non-2xx response.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) Is

func (e *APIError) Is(target error) bool

Is makes errors.Is(err, ErrAuthentication) and friends work.

type Account

type Account struct {
	Email         string  `json:"email"`
	Name          string  `json:"name"`
	Plan          string  `json:"plan"`
	PlanExpiresAt *string `json:"planExpiresAt"`
	// BalanceGB is the lifetime GB credited. Spendable per-product balances come from Balances.List.
	BalanceGB float64 `json:"balanceGb"`
	CreatedAt string  `json:"createdAt"`
}

Account is the account behind the API key.

type AccountService

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

func (*AccountService) Get

func (s *AccountService) Get(ctx context.Context) (*Account, error)

type AllocateParams

type AllocateParams struct {
	ProductKey ProductKey `json:"productKey"`
	GB         int        `json:"gb"` // whole GB, at least the product's minimum
	// IdempotencyKey makes retries safe: repeating a key returns AlreadyApplied and moves nothing.
	IdempotencyKey string `json:"-"`
}

AllocateParams moves GB from your pool onto a customer.

type Allocation

type Allocation struct {
	ProductKey      ProductKey `json:"productKey"`
	ProductID       string     `json:"productId"`
	GB              int        `json:"gb"`
	AlreadyApplied  bool       `json:"alreadyApplied"`
	PoolRemainingGB float64    `json:"poolRemainingGb"`
}

Allocation is the result of an allocation.

type AuthService

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

AuthService creates an account without a browser: Signup, then VerifyOTP with the emailed code.

func (*AuthService) ResendOTP

func (s *AuthService) ResendOTP(ctx context.Context, email string) error

func (*AuthService) Signup

func (s *AuthService) Signup(ctx context.Context, p SignupParams) (*SignupResult, error)

func (*AuthService) VerifyOTP

func (s *AuthService) VerifyOTP(ctx context.Context, email, code string) (*VerifyResult, error)

type Balance

type Balance struct {
	ProductKey *ProductKey `json:"productKey"`
	ProductID  string      `json:"productId"`
	// PlanID is what to pass to Plans.Generate; nil until the product has been funded once.
	PlanID    *string `json:"planId"`
	ActiveGB  float64 `json:"activeGb"`
	PendingGB float64 `json:"pendingGb"` // paid for but still being added
	TotalGB   float64 `json:"totalGb"`
	ExpiresAt *string `json:"expiresAt"`
}

Balance is the spendable bandwidth on one product.

type BalancesService

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

func (*BalancesService) List

func (s *BalancesService) List(ctx context.Context) ([]Balance, error)

List returns spendable GB per product, including GB still being added after a payment.

type BillingInterval

type BillingInterval string

BillingInterval is "month" or "year".

const (
	Monthly BillingInterval = "month"
	Yearly  BillingInterval = "year"
)

type CardCheckout

type CardCheckout struct {
	PayURL string `json:"payUrl"`
	// TransactionID is nil when PayURL is the subscription portal rather than a new payment.
	TransactionID *string `json:"transactionId"`
}

CardCheckout is a Stripe checkout to open in a browser.

type CardCheckoutParams

type CardCheckoutParams struct {
	Kind       string          `json:"kind"`
	ProductKey ProductKey      `json:"productKey,omitempty"`
	GB         int             `json:"gb,omitempty"`
	Plan       PaidPlan        `json:"plan,omitempty"`
	Interval   BillingInterval `json:"interval,omitempty"`
}

CardCheckoutParams starts a card checkout: either a top-up (Kind "topup", ProductKey, GB) or a subscription (Kind "plan", Plan, Interval). Use TopupCardParams / PlanCardParams to build one.

func PlanCardParams

func PlanCardParams(plan PaidPlan, interval BillingInterval) CardCheckoutParams

PlanCardParams builds the params for a plan subscription. An empty interval means monthly.

func TopupCardParams

func TopupCardParams(product ProductKey, gb int) CardCheckoutParams

TopupCardParams builds the params for a pay-as-you-go card top-up.

type Catalog

type Catalog struct {
	Products    []Product `json:"products"`
	VolumeBonus struct {
		ThresholdGB int     `json:"thresholdGb"`
		Rate        float64 `json:"rate"`
	} `json:"volumeBonus"`
	Plans []struct {
		Plan              PaidPlan `json:"plan"`
		MonthlyPriceCents int      `json:"monthlyPriceCents"`
		IncludedGB        float64  `json:"includedGb"`
	} `json:"plans"`
}

Catalog is the public product catalog with live prices.

type Client

type Client struct {
	Products     *ProductsService
	Auth         *AuthService
	Account      *AccountService
	Balances     *BalancesService
	Plans        *PlansService
	Topup        *TopupService
	Transactions *TransactionsService
	Reseller     *ResellerService
	// contains filtered or unexported fields
}

Client talks to the BuyProxy API. It is safe for concurrent use.

func New

func New(opts ...Option) *Client

New creates a Client.

func (*Client) KeyKind

func (c *Client) KeyKind() string

KeyKind returns "reseller" for bp_live_ keys, "personal" for bp_key_ keys, and "" with no key.

type ConnectionError

type ConnectionError struct{ Err error }

ConnectionError means the request never got a response (DNS, reset, timeout, offline).

func (*ConnectionError) Error

func (e *ConnectionError) Error() string

func (*ConnectionError) Unwrap

func (e *ConnectionError) Unwrap() error

type CryptoCheckout

type CryptoCheckout struct {
	URL           string `json:"url"`
	TransactionID string `json:"transactionId"`
}

CryptoCheckout is a crypto invoice to open in a browser.

type Customer

type Customer struct {
	Username  string         `json:"username"`
	Label     string         `json:"label"`
	Status    CustomerStatus `json:"status"`
	CreatedAt string         `json:"createdAt"`
}

Customer is a reseller sub-account.

type CustomerDetail

type CustomerDetail struct {
	Customer
	Plans   []CustomerPlan      `json:"plans"`
	Pending []PendingAllocation `json:"pending"`
}

CustomerDetail is a customer with their plans.

type CustomerGenerateParams

type CustomerGenerateParams struct {
	PlanID string `json:"planId"`
	GenerateParams
}

CustomerGenerateParams is GenerateParams plus the customer's plan.

type CustomerPlan

type CustomerPlan struct {
	Plan
	RemainingGB float64 `json:"remainingGb"`
}

CustomerPlan is a Plan plus the customer's remaining GB.

type CustomerStatus

type CustomerStatus string

CustomerStatus is "active" or "suspended".

const (
	CustomerActive    CustomerStatus = "active"
	CustomerSuspended CustomerStatus = "suspended"
)

type CustomerUpdate

type CustomerUpdate struct {
	Label  string         `json:"label,omitempty"`
	Status CustomerStatus `json:"status,omitempty"`
}

CustomerUpdate renames and/or suspends/reactivates; empty fields are left unchanged.

type CustomerUsage

type CustomerUsage struct {
	Plans []struct {
		ID          string      `json:"id"`
		ProductID   string      `json:"productId"`
		ProductKey  *ProductKey `json:"productKey"`
		RemainingGB float64     `json:"remainingGb"`
		TotalGB     float64     `json:"totalGb"`
		UsedGB      float64     `json:"usedGb"`
		ExpiresAt   *string     `json:"expiresAt"`
	} `json:"plans"`
	Pending []PendingAllocation `json:"pending"`
}

CustomerUsage is a snapshot of a customer's consumption.

type CustomersService

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

func (*CustomersService) Allocate

func (s *CustomersService) Allocate(ctx context.Context, username string, p AllocateParams) (*Allocation, error)

Allocate moves GB from your pool onto a customer. Set IdempotencyKey to make retries safe.

func (*CustomersService) Create

func (s *CustomersService) Create(ctx context.Context, label string) (*Customer, error)

Create makes an isolated sub-account with no bandwidth — fund it with Allocate.

func (*CustomersService) Generate

func (*CustomersService) Get

func (s *CustomersService) Get(ctx context.Context, username string) (*CustomerDetail, error)

func (*CustomersService) List

func (s *CustomersService) List(ctx context.Context, status CustomerStatus) ([]Customer, error)

List returns your customers; pass a status ("active"/"suspended") to filter, or "" for all.

func (*CustomersService) Update

func (s *CustomersService) Update(ctx context.Context, username string, u CustomerUpdate) (*Customer, error)

func (*CustomersService) Usage

func (s *CustomersService) Usage(ctx context.Context, username string) (*CustomerUsage, error)

type GenerateCapabilities

type GenerateCapabilities struct {
	MaxCount         int        `json:"maxCount"`
	MaxStickyMinutes int        `json:"maxStickyMinutes"` // 0 means no sticky sessions on this product
	Protocols        []Protocol `json:"protocols"`
	Targeting        struct {
		Country bool `json:"country"`
		State   bool `json:"state"`
		City    bool `json:"city"`
		ISP     bool `json:"isp"`
	} `json:"targeting"`
}

GenerateCapabilities describes what a plan's generate call accepts.

type GenerateParams

type GenerateParams struct {
	Protocol Protocol `json:"protocol,omitempty"` // default "http"
	Count    int      `json:"count,omitempty"`    // 1–1000, default 1
	Country  string   `json:"country,omitempty"`  // ISO 3166-1 alpha-2, e.g. "US"
	State    string   `json:"state,omitempty"`
	City     string   `json:"city,omitempty"`
	ISP      string   `json:"isp,omitempty"`
	// StickyMinutes keeps the same IP for that long. Leave 0 for a fresh IP per request (rotating).
	StickyMinutes int `json:"stickyMinutes,omitempty"`
}

GenerateParams controls proxy generation. Zero values are omitted, so the API's defaults apply.

type GeneratedProxies

type GeneratedProxies struct {
	Lines   []string
	Proxies []Proxy
}

GeneratedProxies is the result of a Generate call: the raw lines plus parsed proxies.

type Option

type Option func(*Client)

Option configures a Client.

func WithAPIKey

func WithAPIKey(key string) Option

WithAPIKey sets the key (bp_key_… personal, bp_live_… reseller). Default: $BUYPROXY_API_KEY.

func WithBaseURL

func WithBaseURL(u string) Option

WithBaseURL overrides the API origin (default https://www.buyproxy.org).

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

WithHTTPClient supplies your own *http.Client (timeouts, tracing, proxies).

func WithMaxRetries

func WithMaxRetries(n int) Option

WithMaxRetries sets retries for rate limits and transient failures (default 2).

type PaidPlan

type PaidPlan string

PaidPlan is a plan you can buy by card.

const (
	PlanPro      PaidPlan = "pro"
	PlanBusiness PaidPlan = "business"
	PlanAdvanced PaidPlan = "advanced"
)

type PendingAllocation

type PendingAllocation struct {
	ProductID  string      `json:"productId"`
	ProductKey *ProductKey `json:"productKey"`
	GB         float64     `json:"gb"`
}

PendingAllocation is GB allocated but still being added to a plan.

type Plan

type Plan struct {
	ID              string                `json:"id"`
	ProductID       string                `json:"productId"`
	ProductKey      *ProductKey           `json:"productKey"`
	Name            string                `json:"name"`
	Label           *string               `json:"label"`
	DataGBRemaining float64               `json:"dataGbRemaining"`
	DataGBTotal     float64               `json:"dataGbTotal"`
	ExpiresAt       *string               `json:"expiresAt"`
	CreatedAt       string                `json:"createdAt"`
	Generate        *GenerateCapabilities `json:"generate"`
}

Plan is bandwidth you hold on one product.

type PlansService

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

func (*PlansService) Generate

func (s *PlansService) Generate(ctx context.Context, planID string, p *GenerateParams) (*GeneratedProxies, error)

Generate creates proxy lines against one of your plans. Lines are on-demand — don't store them.

func (*PlansService) List

func (s *PlansService) List(ctx context.Context) ([]Plan, error)

type PoolEntry

type PoolEntry struct {
	ProductKey ProductKey `json:"productKey"`
	ProductID  string     `json:"productId"`
	Label      string     `json:"label"`
	GB         float64    `json:"gb"`
}

PoolEntry is unallocated reseller bandwidth on one product.

type PoolService

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

func (*PoolService) Get

func (s *PoolService) Get(ctx context.Context) ([]PoolEntry, error)

Get returns your unallocated bandwidth, per product.

func (*PoolService) TopupCard

func (s *PoolService) TopupCard(ctx context.Context, p PoolTopupParams) (*CardCheckout, error)

func (*PoolService) TopupCrypto

func (s *PoolService) TopupCrypto(ctx context.Context, p PoolTopupParams) (*CryptoCheckout, error)

type PoolTopupParams

type PoolTopupParams struct {
	ProductKey ProductKey `json:"productKey"`
	GB         int        `json:"gb"`
}

PoolTopupParams buys bandwidth into the reseller pool.

type Product

type Product struct {
	ProductKey      ProductKey `json:"productKey"`
	ProductID       string     `json:"productId"`
	Name            string     `json:"name"`
	Description     string     `json:"description"`
	MinGB           int        `json:"minGb"`
	PricePerGBCents *int       `json:"pricePerGbCents"` // nil if pricing is momentarily unavailable
	Currency        string     `json:"currency"`
}

Product is one item in the catalog.

type ProductKey

type ProductKey string

ProductKey is accepted by every top-up and allocation call — see Products.List.

const (
	ProductResidential ProductKey = "residential"
	ProductPremium     ProductKey = "premium"
	ProductISP         ProductKey = "isp"
	ProductMobile      ProductKey = "mobile"
	ProductIPv4        ProductKey = "ipv4"
	ProductIPv6        ProductKey = "ipv6"
)

type ProductsService

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

ProductsService is the public catalog.

func (*ProductsService) List

func (s *ProductsService) List(ctx context.Context) (*Catalog, error)

List returns every product with its key, minimum GB and live price. No API key needed.

type Protocol

type Protocol string

Protocol is the proxy protocol: "http" or "socks5".

const (
	HTTP   Protocol = "http"
	SOCKS5 Protocol = "socks5"
)

type Proxy

type Proxy struct {
	Host     string
	Port     int
	Username string
	Password string
	Protocol Protocol
}

Proxy is one generated proxy. The API returns username:password@host:port lines.

func ParseProxy

func ParseProxy(line string, protocol Protocol) (Proxy, error)

ParseProxy parses a username:password@host:port line. '@' and ':' are allowed inside the password.

func (Proxy) Curl

func (p Proxy) Curl() string

Curl returns a ready-to-run curl command that prints your exit IP through this proxy.

func (Proxy) Env

func (p Proxy) Env() map[string]string

Env returns the environment variables understood by curl, wget, git and most CLIs.

func (Proxy) HTTPClient

func (p Proxy) HTTPClient() *http.Client

HTTPClient returns an *http.Client that sends every request through this proxy.

func (Proxy) String

func (p Proxy) String() string

String returns the username:password@host:port form the API uses.

func (Proxy) Transport

func (p Proxy) Transport() *http.Transport

Transport returns an *http.Transport that sends every request through this proxy (HTTP or SOCKS5).

func (Proxy) URL

func (p Proxy) URL() *url.URL

URL returns the proxy as a *url.URL with credentials, ready for http.ProxyURL.

type ResellerService

type ResellerService struct {
	Customers *CustomersService
	Pool      *PoolService
	// contains filtered or unexported fields
}

func (*ResellerService) Me

type ResellerSummary

type ResellerSummary struct {
	Email               string      `json:"email"`
	CustomerCount       int         `json:"customerCount"`
	ActiveCustomerCount int         `json:"activeCustomerCount"`
	Pool                []PoolEntry `json:"pool"`
}

ResellerSummary is the result of Reseller.Me.

type SignupParams

type SignupParams struct {
	Email    string `json:"email"`
	Password string `json:"password"`
	Name     string `json:"name,omitempty"`
}

SignupParams creates an account (no API key needed).

type SignupResult

type SignupResult struct {
	OK              bool `json:"ok"`
	CooldownSeconds int  `json:"cooldownSeconds"`
}

SignupResult is the result of Auth.Signup.

type TopupService

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

func (*TopupService) Card

Card starts a Stripe checkout — a top-up or a plan subscription. Open PayURL to pay.

func (*TopupService) Crypto

func (s *TopupService) Crypto(ctx context.Context, product ProductKey, gb int) (*CryptoCheckout, error)

Crypto starts a crypto top-up (pay-as-you-go only). Open URL to pay.

type Transaction

type Transaction struct {
	ID            string           `json:"id"`
	Kind          string           `json:"kind"`
	Status        string           `json:"status"` // pending | succeeded | failed
	PaymentMethod string           `json:"paymentMethod"`
	Interval      *BillingInterval `json:"interval"`
	AmountCents   int              `json:"amountCents"`
	Currency      string           `json:"currency"`
	GB            *float64         `json:"gb"` // including any volume bonus
	ProductKey    *ProductKey      `json:"productKey"`
	Plan          *string          `json:"plan"`
	ResellerPool  bool             `json:"resellerPool"`
	CreatedAt     string           `json:"createdAt"`
}

Transaction is one payment.

type TransactionsService

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

func (*TransactionsService) Get

func (*TransactionsService) List

func (s *TransactionsService) List(ctx context.Context, limit int) ([]Transaction, error)

List returns recent payments. limit <= 0 uses the API default.

func (*TransactionsService) Wait

func (s *TransactionsService) Wait(ctx context.Context, id string, interval time.Duration) (*Transaction, error)

Wait polls until the payment settles (succeeded or failed) or ctx ends.

type VerifyResult

type VerifyResult struct {
	OK    bool `json:"ok"`
	IsNew bool `json:"isNew"`
	User  struct {
		Email string `json:"email"`
		Name  string `json:"name"`
	} `json:"user"`
}

VerifyResult is the result of Auth.VerifyOTP.

Directories

Path Synopsis
Command example generates five US proxies and checks your exit IP through the first one.
Command example generates five US proxies and checks your exit IP through the first one.

Jump to

Keyboard shortcuts

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