CLI
Guides & recipes
Worked examples that combine several commands to get something done. New to the CLI? Start with the overview. Every command is documented in detail on its own page — see the command list.
Give a scraper rotating proxies
Most tools — curl, wget, pip, git, many scraping frameworks — honour the standard proxy environment variables. generate -f env prints them for you.
- Generate and export in one step:
eval "$(buyproxy generate residential -c US -f env)"- Confirm the tool now exits from a US address:
curl https://api.ipify.org- Run your scraper as normal in the same shell.
HTTP_PROXY,HTTPS_PROXYandALL_PROXYare set.
-s 10 (keep the same IP for ten minutes). To rotate between *different* proxies, generate several with -n and pick one per worker.Build a proxy list for another tool
Plenty of tools want a file of proxies. Generate as many as you need (up to 1000 per call) and redirect:
# 500 rotating German proxies, one per line: username:password@host:port
buyproxy generate premium -c DE -n 500 -f plain > proxies.txt
# the same as full URLs
buyproxy generate premium -c DE -n 500 -f url > proxies-urls.txt
# or as JSON for your own program
buyproxy generate premium -c DE -n 500 --json > proxies.jsonBecause the CLI prints only data when its output is redirected, there's no banner or colour to strip. Lines are on-demand, so regenerate the file when it's time to refresh rather than keeping it for weeks.
Get a ready snippet for Playwright or Python
Print a configuration you can paste directly into code, optionally onto your clipboard:
buyproxy generate -c US -f playwright --copy # Playwright launch options
buyproxy generate -c US -f requests # a Python requests example
buyproxy generate -c US -f curl # a curl command that prints your exit IPFor more than a snippet, use an SDK — each has helpers for Playwright, Puppeteer, requests, httpx, Scrapy, Guzzle and more.
Monitor bandwidth in CI and get warned early
Run this on a schedule (cron, GitHub Actions) to fail loudly before a job runs dry. Store the key as a secret and export it as BUYPROXY_API_KEY.
#!/usr/bin/env bash
set -euo pipefail
# products that are funded but have less than 2 GB left
low=$(buyproxy balance --json | jq -r '[.balances[] | select(.planId != null and .activeGb < 2) | .productKey] | join(", ")')
if [ -n "$low" ]; then
echo "Low on proxy bandwidth: $low" >&2
exit 1
fiHook the failure into your alerting (Slack, email, PagerDuty). When it fires, buyproxy topup — or your own automation calling buyproxy topup <product> --gb 50 --crypto --no-open --no-wait --json — creates the payment link to act on.
Health-check your proxies on a schedule
buyproxy test exits non-zero when a proxy doesn't work, so it drops straight into a cron job:
# every 15 minutes: alert if a US exit stops working
*/15 * * * * BUYPROXY_API_KEY=… buyproxy test residential -c US --json >/dev/null || /usr/local/bin/alert "BuyProxy US exit failing"To keep the history, log latency:
buyproxy test --json | jq -c '{at: now, ok, latencyMs, ip: .body.ip}' >> proxy-health.jsonlEach check uses a few kilobytes of bandwidth.
Onboard a reseller customer end to end
You need a reseller key (bp_live_…, Business plan or higher) — log in with it first: buyproxy login.
- Fund your pool (once, or whenever it runs low):
buyproxy pool topup residential --gb 500 --card
buyproxy pool # confirm the GB arrived- Create the customer and note the username it prints:
buyproxy customers new "Acme Inc"
# Username bp_acme_1a2b- Allocate what they paid for — the CLI attaches an idempotency key, so retries are safe:
buyproxy customers allocate bp_acme_1a2b residential 20- Generate proxies for them and hand them over:
buyproxy customers generate bp_acme_1a2b -c DE -n 5 -f plain- Watch usage to bill or alert:
buyproxy customers usage bp_acme_1a2b
buyproxy customers show bp_acme_1a2b- Pause them if they stop paying, and bring them back when they do:
buyproxy customers suspend bp_acme_1a2b
buyproxy customers activate bp_acme_1a2bWas this page helpful?