Code examples
The API from curl, Python and Node.js; the gateway from eight languages.
The examples read two secrets from the environment: BOXAFOX_KEY (an API key) and BOXAFOX_PROXY_PASSWORD (a proxy user's password).
Call the API
curl https://api.boxafox.com/v1/residential/summary \
-H "X-API-Key: $BOXAFOX_KEY"Handle errors
Branch on the error code and keep the request_id:
r = api.post("https://api.boxafox.com/v1/proxy-users", json={"username": "acme_scraper1"})
if r.status_code == 409 and r.json()["error"] == "username_taken":
... # pick another name
elif not r.ok:
body = r.json()
raise RuntimeError(f'{body["error"]} ({body["request_id"]})')Buy data safely
Generate the Idempotency-Key once and reuse it on every retry of the same purchase:
import uuid
key = str(uuid.uuid4())
order = api.post(
"https://api.boxafox.com/v1/checkout",
headers={"Idempotency-Key": key},
json={"items": [{"product_code": "mobile_gb", "gb": 5}]},
)Send traffic through the gateway
Replace acme with your proxy username and PASSWORD with its password. Each example prints the exit IP and its location.
curl -x "http://acme_net_res_c_de:PASSWORD@gw.boxafox.com:8000" https://ipinfo.io/jsonOver SOCKS5
The same host, port and credentials speak SOCKS5. socks5h lets the gateway resolve host names. Ruby's standard library has no SOCKS client, so its example stays on HTTP.
curl -x "socks5h://acme_net_res_c_de:PASSWORD@gw.boxafox.com:8000" https://ipinfo.io/jsonWhen the gateway refuses a connection, the reason is in the X-Proxy-Error response header: see Errors.