buyproxy

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 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, buy it from your wallet (topped 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 pass buyproxy.WithAPIKey("bp_key_…")

	plans, err := client.Plans.List(ctx)
	if err != nil || len(plans) == 0 {
		log.Fatal("no plans yet, buy bandwidth from your wallet first: ", err)
	}

	res, err := client.Plans.Generate(ctx, plans[0].ID, &buyproxy.GenerateParams{Country: "US", 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 for a sticky session: on Premium Residential it sets the length (3 minutes to 24 hours), and on Core Residential it turns sticky on. For SOCKS5, set Protocol: buyproxy.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, …

Wallet: add money, then buy bandwidth

Every account has one USD wallet. Add money by card (Stripe Checkout) or crypto, from $5 to $2,000 per deposit, then spend it on bandwidth for any product (from 1 GB; Premium Residential from 2 GB), Scraper API credit or dedicated rentals: a purchase is charged and delivered in one call. Pass an idempotency key (sent as the Idempotency-Key header, up to 128 characters) so a purchase you repeat after a timeout is charged once; purchases are never retried automatically. Plans stay card subscriptions.

// 1. Add $15 to your wallet by card (buyproxy.PayByCrypto for a crypto invoice)
topup, _ := client.Wallet.Topup(ctx, buyproxy.PayByCard, 1500)
fmt.Println(topup.CheckoutURL())                                // open it in a browser
client.Transactions.Wait(ctx, topup.TransactionID, 3*time.Second) // the money is in the wallet once it says "succeeded"

// 2. Buy 10 GB of Core Residential from the wallet: charged and delivered at once
order, _ := client.Wallet.Purchase(ctx, buyproxy.BuyGB(buyproxy.ProductResidential, 10).WithIdempotencyKey("order-1042"))
fmt.Println(order.Summary, order.BalanceCents) // 10 GB Core Residential 510

// Scraper API credit and dedicated rentals come out of the same wallet
client.Wallet.Purchase(ctx, buyproxy.BuyScraperCredit(500))
client.Wallet.Purchase(ctx, buyproxy.RentDedicated(buyproxy.DedicatedIPv4, "USA", 30, 5))

wallet, _ := client.Wallet.Get(ctx)
fmt.Println(wallet.BalanceCents)

// Plans are card subscriptions, monthly or yearly
client.Topup.Card(ctx, buyproxy.PlanCardParams(buyproxy.PlanPro, buyproxy.Yearly))

Wallet methods need v1.1.0 or later. From v1.1.0 the retired v1.0.x top-ups fail before any request with an error matching errors.Is(err, buyproxy.ErrRetired).

The per-product top-up calls from 1.0.x (card or crypto top-ups and pool top-ups) were retired on 9 November 2026. They now fail straight away with a 410 error that names the wallet call to use, without sending a request.

Reseller API

Build a proxy product on top of BuyProxy: buy bandwidth in bulk into a reseller pool from your wallet, 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.Purchase(ctx, buyproxy.PoolPurchaseParams{ProductKey: buyproxy.ProductResidential, GB: 500}) // from your wallet
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: buy more from your wallet")
case errors.Is(err, buyproxy.ErrRateLimited):
	wait := 5 * time.Second // used when the API sends no Retry-After
	var apiErr *buyproxy.APIError
	if errors.As(err, &apiErr) && apiErr.RetryAfter > 0 {
		wait = apiErr.RetryAfter
	}
	log.Printf("Slow down; retry in %s", wait)
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)
Wallet client.Wallet.Get(ctx) · .Topup(ctx, method, amountCents) · .Purchase(ctx, params)
Plan subscription (card) client.Topup.Card(ctx, buyproxy.PlanCardParams(...))
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(ctx) · .Purchase(ctx, params)

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: the wallet, balances, plans, generating proxies and payments. A reseller key (bp_live_…) manages your customers: create isolated sub-accounts, buy bandwidth into a pool from your wallet, 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 (residential from $0.99/GB, IPv6 from $0.29/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 what you buy from your wallet.

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.1.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")
	// ErrRetired matches calls the API no longer serves (HTTP 410), such as the old bandwidth top-ups. The
	// error's message names the wallet call to use instead.
	ErrRetired = errors.New("buyproxy: retired endpoint")
)

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 plan subscription by card (Kind "plan", Plan, Interval). Build it with PlanCardParams. Kind "topup" was retired on 9 November 2026: bandwidth is bought from the wallet (see WalletService).

func PlanCardParams

func PlanCardParams(plan PaidPlan, interval BillingInterval) CardCheckoutParams

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

func TopupCardParams deprecated

func TopupCardParams(product ProductKey, gb int) CardCheckoutParams

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

Deprecated: retired on 9 November 2026, Topup.Card now fails with ErrRetired for these params. Add money with Wallet.Topup, then buy with Wallet.Purchase(ctx, BuyGB(product, gb)).

type Catalog

type Catalog struct {
	Products []Product `json:"products"`
	// MinTopupCents is the smallest wallet deposit, in cents ($5.00 is 500).
	MinTopupCents int `json:"minTopupCents"`
	// VolumeBonus: bandwidth orders of ThresholdGB or more get floor(gb × Rate) extra GB free.
	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
	Wallet       *WalletService
	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 DedicatedFamily added in v1.1.0

type DedicatedFamily string

DedicatedFamily is a dedicated (per-IP) product, or ISP Unlimited.

const (
	DedicatedISP    DedicatedFamily = "isp"
	DedicatedIPv4   DedicatedFamily = "ipv4"
	DedicatedIPv6   DedicatedFamily = "ipv6"
	DedicatedMobile DedicatedFamily = "mobile"
	ISPUnlimited    DedicatedFamily = "ispunlimited"
)

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 MobileSelection added in v1.1.0

type MobileSelection struct {
	OperatorID  string `json:"operatorId"`
	RotationID  string `json:"rotationId"`
	ServiceType string `json:"serviceType"` // "dedicated" or "shared"
}

MobileSelection picks the carrier and rotation for a dedicated mobile rental.

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 PaymentMethod added in v1.1.0

type PaymentMethod string

PaymentMethod is how money goes into the wallet: PayByCard or PayByCrypto.

const (
	PayByCard   PaymentMethod = "card"
	PayByCrypto PaymentMethod = "crypto"
)

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 PoolPurchaseParams added in v1.1.0

type PoolPurchaseParams struct {
	ProductKey ProductKey `json:"productKey"`
	GB         int        `json:"gb"` // whole GB, from the product's MinGB to 10,000
	// IdempotencyKey (up to 128 characters) is sent as the Idempotency-Key header: repeat the purchase with the
	// same key after a timeout and you are charged once.
	IdempotencyKey string `json:"-"`
}

PoolPurchaseParams buys bandwidth into the reseller pool, paid from the wallet.

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) Purchase added in v1.1.0

Purchase buys GB into your pool, paid from your wallet. The GB is in the pool as soon as this returns. It is never retried on a server error: set IdempotencyKey and repeat the call yourself to retry safely.

func (*PoolService) TopupCard deprecated

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

TopupCard started a card checkout for pool bandwidth.

Deprecated: retired on 9 November 2026, it now fails with ErrRetired without a request. Use Wallet.Topup, then Pool.Purchase.

func (*PoolService) TopupCrypto deprecated

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

TopupCrypto started a crypto invoice for pool bandwidth.

Deprecated: retired on 9 November 2026, it now fails with ErrRetired without a request. Use Wallet.Topup, then Pool.Purchase.

type PoolTopupParams deprecated

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

PoolTopupParams buys bandwidth into the reseller pool.

Deprecated: used only by the retired Pool.TopupCard and Pool.TopupCrypto. Use Pool.Purchase with PoolPurchaseParams.

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"`           // smallest order in whole GB (1 GB; 2 GB for Premium Residential)
	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 bandwidth purchase 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 plan subscription by card (Stripe Checkout). Open PayURL to pay. Build p with PlanCardParams. Bandwidth top-ups (TopupCardParams) were retired and fail with ErrRetired: use Wallet.Topup and Wallet.Purchase.

func (*TopupService) Crypto deprecated

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

Crypto started a crypto bandwidth top-up.

Deprecated: retired on 9 November 2026, it now fails with ErrRetired without a request. Use Wallet.Topup(ctx, PayByCrypto, amountCents), then Wallet.Purchase(ctx, BuyGB(product, gb)).

type Transaction

type Transaction struct {
	ID string `json:"id"`
	// Kind is "wallet" for a wallet deposit, "plan" for a subscription payment, and "topup", "scraper" or
	// "dedicated" for older direct payments.
	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.

type Wallet added in v1.1.0

type Wallet struct {
	BalanceCents       int           `json:"balanceCents"`
	TotalToppedUpCents int           `json:"totalToppedUpCents"`
	TotalSpentCents    int           `json:"totalSpentCents"`
	Recent             []WalletEntry `json:"recent"` // newest first
}

Wallet is your account's USD balance, topped up by card or crypto and spent on any product.

type WalletEntry added in v1.1.0

type WalletEntry struct {
	ID                string `json:"_id"`
	Type              string `json:"type"`        // topup | purchase | refund
	AmountCents       int    `json:"amountCents"` // signed: positive adds to the wallet, negative spends it
	BalanceAfterCents int    `json:"balanceAfterCents"`
	Description       string `json:"description"`
	CreatedAt         string `json:"createdAt"`
}

WalletEntry is one line of wallet activity.

type WalletPurchase added in v1.1.0

type WalletPurchase struct {
	OK           bool   `json:"ok"`
	Summary      string `json:"summary"`      // what was bought, e.g. "10 GB Core Residential"
	AmountCents  int    `json:"amountCents"`  // what it cost
	BalanceCents int    `json:"balanceCents"` // wallet balance afterwards
	OrderID      string `json:"orderId,omitempty"`
}

WalletPurchase is the result of a wallet or pool purchase.

type WalletPurchaseParams added in v1.1.0

type WalletPurchaseParams struct {
	Kind        string           `json:"kind"` // gb | scraper | dedicated
	ProductKey  ProductKey       `json:"productKey,omitempty"`
	GB          int              `json:"gb,omitempty"`
	AmountCents int              `json:"amountCents,omitempty"`
	Family      DedicatedFamily  `json:"family,omitempty"`
	Country     string           `json:"country,omitempty"` // ISO 3166-1 alpha-3, e.g. "USA"
	PeriodDays  int              `json:"periodDays,omitempty"`
	Quantity    int              `json:"quantity,omitempty"`
	Mobile      *MobileSelection `json:"mobile,omitempty"`
	// IdempotencyKey (up to 128 characters) is sent as the Idempotency-Key header: repeat a purchase with the same
	// key after a timeout and you are charged once. Derive it from your own data, such as an order id.
	IdempotencyKey string `json:"-"`
}

WalletPurchaseParams says what to buy from the wallet. Build it with BuyGB, BuyScraperCredit, RentDedicated or RentISPUnlimited; zero fields are left out of the request.

func BuyGB added in v1.1.0

func BuyGB(product ProductKey, gb int) WalletPurchaseParams

BuyGB buys whole GB of one product (from its MinGB to 10,000). Orders of 100 GB or more include the volume bonus.

func BuyScraperCredit added in v1.1.0

func BuyScraperCredit(amountCents int) WalletPurchaseParams

BuyScraperCredit moves amountCents (at least 100) of wallet money onto the Scraper API balance.

func RentDedicated added in v1.1.0

func RentDedicated(family DedicatedFamily, country string, periodDays, quantity int) WalletPurchaseParams

RentDedicated rents quantity dedicated IPs in a country (ISO alpha-3) for periodDays (7, 14, 30, 60, 90, 180, 270 or 365). Set Mobile for DedicatedMobile.

func RentISPUnlimited added in v1.1.0

func RentISPUnlimited(mbps int) WalletPurchaseParams

RentISPUnlimited rents one month of ISP Unlimited at mbps (10, 25, 50 or 100).

func (WalletPurchaseParams) WithIdempotencyKey added in v1.1.0

func (p WalletPurchaseParams) WithIdempotencyKey(key string) WalletPurchaseParams

WithIdempotencyKey returns a copy of p that is safe to retry with the same key.

type WalletService added in v1.1.0

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

WalletService is your account's USD wallet: add money by card or crypto, then spend it on any product. It works with a personal or a reseller key.

func (*WalletService) Get added in v1.1.0

func (s *WalletService) Get(ctx context.Context) (*Wallet, error)

Get returns the balance in cents and the most recent wallet activity.

func (*WalletService) Purchase added in v1.1.0

Purchase spends wallet money on bandwidth, Scraper API credit or a dedicated rental, charged and delivered at once. A short wallet returns an error matching ErrInsufficientBandwidth whose Body carries shortfallCents. It is never retried on a server error: set IdempotencyKey and repeat the call yourself to retry safely.

func (*WalletService) Topup added in v1.1.0

func (s *WalletService) Topup(ctx context.Context, method PaymentMethod, amountCents int) (*WalletTopup, error)

Topup starts a payment that adds amountCents (500 to 200000, so $5 to $2,000) to the wallet. Open CheckoutURL() to pay, then Transactions.Wait: the money is in the wallet once it says "succeeded".

type WalletTopup added in v1.1.0

type WalletTopup struct {
	PayURL        string `json:"payUrl,omitempty"`
	URL           string `json:"url,omitempty"`
	TransactionID string `json:"transactionId"`
}

WalletTopup is a payment page that adds money to the wallet: PayURL for card, URL for crypto.

func (*WalletTopup) CheckoutURL added in v1.1.0

func (t *WalletTopup) CheckoutURL() string

CheckoutURL returns the page to pay on, for either method.

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