curl Integration
curl is the fastest way to test and verify your proxy credentials. All examples use the residential rotating endpoint — swap the host for dc.ninjasproxy.com (datacenter) or m.ninjasproxy.com (mobile) as needed.
Basic Syntax
curl -x http://USERNAME:API_KEY@r.ninjasproxy.com:8080 https://api.ipify.org?format=json
The -x / --proxy flag sets the proxy URL. curl encodes and forwards your credentials as a Proxy-Authorization header automatically.
HTTPS Through a Proxy
For HTTPS targets, curl opens an HTTP CONNECT tunnel through the proxy then performs the TLS handshake directly with the origin — your traffic is end-to-end encrypted from your machine to the target:
curl --proxy "http://USERNAME:API_KEY@r.ninjasproxy.com:8080" \
"https://httpbin.org/ip"Both -x and --proxy work identically. Use --proxy in scripts for clarity.
SOCKS5
NinjasProxy also accepts SOCKS5 connections on port 1080. SOCKS5 proxies DNS resolution to the proxy server, which can help with geo-sensitive DNS responses:
# SOCKS5 curl --socks5 "USERNAME:API_KEY@r.ninjasproxy.com:1080" "https://api.ipify.org?format=json" # SOCKS5 with remote DNS resolution (recommended) curl --socks5-hostname "USERNAME:API_KEY@r.ninjasproxy.com:1080" "https://api.ipify.org?format=json"
Ignore SSL Errors (Testing Only)
# -k / --insecure disables certificate verification — never use in production
curl -k --proxy "http://USERNAME:API_KEY@r.ninjasproxy.com:8080" "https://self-signed.example.com"
# Also suppress proxy certificate errors
curl --proxy "http://USERNAME:API_KEY@r.ninjasproxy.com:8080" \
--proxy-insecure \
"https://target.example.com"Geo-Targeting
# US exit node
curl --proxy "http://USERNAME-country-US:API_KEY@r.ninjasproxy.com:8080" \
"https://api.ipify.org?format=json"
# US AT&T mobile
curl --proxy "http://USERNAME-country-US-carrier-att:API_KEY@m.ninjasproxy.com:8080" \
"https://api.ipify.org?format=json"
# Sticky session — same IP across requests
curl --proxy "http://USERNAME-session-myrun01:API_KEY@r.ninjasproxy.com:8080" \
"https://api.ipify.org?format=json"Custom Headers
curl --proxy "http://USERNAME:API_KEY@r.ninjasproxy.com:8080" \
-H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" \
-H "Accept-Language: en-US,en;q=0.9" \
-H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" \
"https://httpbin.org/headers"POST Request with JSON Body
curl --proxy "http://USERNAME:API_KEY@r.ninjasproxy.com:8080" \
-X POST \
-H "Content-Type: application/json" \
-d '{"query": "proxy test", "page": 1}' \
"https://httpbin.org/post"Multiple Requests (Bash Loop)
#!/usr/bin/env bash
# Fetch 10 URLs through rotating proxies (new IP per request)
PROXY="http://USERNAME:API_KEY@r.ninjasproxy.com:8080"
URLS=(
"https://api.ipify.org?format=json"
"https://httpbin.org/ip"
"https://ifconfig.me/ip"
)
for url in "${URLS[@]}"; do
echo -n "$url → "
curl -s --proxy "$PROXY" "$url"
echo
done#!/usr/bin/env bash
# Parallel requests with xargs (10 concurrent)
PROXY="http://USERNAME:API_KEY@r.ninjasproxy.com:8080"
printf '%s\n' https://api.ipify.org?format=json{,,,,,,,,,} | \
xargs -P 10 -I{} curl -s --proxy "$PROXY" "{}"
echoDebugging Flags
| Flag | Effect |
|---|---|
| -v / --verbose | Print full request/response headers including CONNECT tunnel negotiation |
| --proxy-insecure | Skip TLS verification for the proxy connection (not the target) |
| -w "%{http_code} %{time_total}\n" | Print HTTP status and total time after each request |
| --connect-timeout N | Abort if TCP connection to proxy not established within N seconds |
| --max-time N | Abort entire request (incl. response download) after N seconds |
| -o /dev/null | Discard response body — useful when only testing proxy connectivity |
# Full debug output — shows CONNECT tunnel, headers, and timing
curl -v --proxy "http://USERNAME:API_KEY@r.ninjasproxy.com:8080" \
-w "\nStatus: %{http_code} | Time: %{time_total}s\n" \
-o /dev/null \
"https://api.ipify.org?format=json"Next Steps
- Python integration — requests, httpx, playwright, scrapy
- Node.js integration — axios, got, Puppeteer
- Authentication guide — IP whitelist and key rotation
- Rate limits — concurrency and retry patterns