> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cafescraper.com/llms.txt
> Use this file to discover all available pages before exploring further.

# socks5 network proxy

### **🌐 Proxy Environment Overview**

To ensure stable access to target websites worldwide, the platform provides an encrypted network channel (proxy server) at runtime.

**You do not need to purchase, deploy, or maintain proxies yourself.**\
Simply read the proxy credentials injected by the platform and configure them correctly in your HTTP requests.

***

### **📌 Proxy Configuration**

* **Protocol**: `SOCKS5`
* **Endpoint**: `proxy-inner.cafescraper.com:6000`
* **Authentication**:
  * **Environment Variable**: `PROXY_AUTH`
  * **Format**: `username:password`
* **Cost**: **Built-in and free — no extra payment or manual setup required**

***

### **🐍 Python Example**

```python theme={null}
import os
import requests

# 1. Proxy service address
proxyDomain = "proxy-inner.cafescraper.com:6000"

# 2. Get proxy credentials (automatically injected by the platform)
try:
    proxyAuth = os.environ.get("PROXY_AUTH")
    print(f"Proxy credentials: {proxyAuth}")
except Exception as e:
    print(f"Failed to get proxy credentials: {e}")
    proxyAuth = None

# 3. Build proxy URL
proxy_url = f"socks5://{proxyAuth}@{proxyDomain}" if proxyAuth else None
print(f"Proxy URL: {proxy_url}")

# 4. Example request
target_url = "https://ipinfo.io/ip"  # Example endpoint

try:
    proxies = None
    if proxy_url:
        proxies = {
            "http": proxy_url,
            "https": proxy_url
        }

    response = requests.get(
        target_url,
        proxies=proxies,
        timeout=30,
        headers={
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
        }
    )

    print(f"Status code: {response.status_code}")
    print(f"Response body: {response.text}")

except Exception as e:
    print(f"Request failed: {e}")
```

***

### **🧱 Go Example**

```go theme={null}
// 1. Proxy service address
proxyDomain := "proxy-inner.cafescraper.com:6000"

// 2. Get proxy credentials
proxyAuth := os.Getenv("PROXY_AUTH")
cafesdk.Log.Info(ctx, fmt.Sprintf("Proxy credentials: %s", proxyAuth))

// 3. Build proxy URL
var proxyURL string
if proxyAuth != "" {
	proxyURL = fmt.Sprintf("socks5://%s@%s", proxyAuth, proxyDomain)
}
cafesdk.Log.Info(ctx, fmt.Sprintf("Proxy URL: %s", proxyURL))

// 4. Create HTTP client
httpClient := &http.Client{
	Timeout: time.Second * 30,
}

// 5. Configure transport if proxy is enabled
if proxyURL != "" {
	proxyParsed, err := url.Parse(proxyURL)
	if err != nil {
		cafesdk.Log.Error(ctx, fmt.Sprintf("Failed to parse proxy URL: %v", err))
		return
	}

	httpClient.Transport = &http.Transport{
		Proxy: http.ProxyURL(proxyParsed),
		TLSClientConfig: &tls.Config{
			InsecureSkipVerify: true, // OK for testing; disable in production
		},
	}

	cafesdk.Log.Info(ctx, "SOCKS5 proxy configured")
}

// 6. Example request
targetURL := "https://ipinfo.io/ip"
req, err := http.NewRequestWithContext(ctx, "GET", targetURL, nil)
if err != nil {
	cafesdk.Log.Error(ctx, fmt.Sprintf("Failed to create request: %v", err))
	return
}

resp, err := httpClient.Do(req)
if err != nil {
	cafesdk.Log.Error(ctx, fmt.Sprintf("Request failed: %v", err))
	return
}
defer resp.Body.Close()

body, _ := io.ReadAll(resp.Body)
ip := strings.TrimSpace(string(body))

cafesdk.Log.Info(ctx, fmt.Sprintf("Status code: %d", resp.StatusCode))
cafesdk.Log.Info(ctx, fmt.Sprintf("Current exit IP: %s", ip))
```

***

### **🟢 Node.js Example**

> **Dependencies**
>
> ```shellscript theme={null}
> npm install axios socks-proxy-agent
>
> ```

```javascript theme={null}
import axios from 'axios'
import { SocksProxyAgent } from 'socks-proxy-agent'

// 1. Proxy service address
const proxyDomain = 'proxy-inner.cafescraper.com:6000'

// 2. Get proxy credentials
let proxyAuth = null
try {
  proxyAuth = process.env.PROXY_AUTH || null
  await cafesdk.log.info(`Proxy credentials: ${proxyAuth}`)
} catch (err) {
  await cafesdk.log.error(`Failed to get proxy credentials: ${err.message}`)
}

// 3. Build proxy URL
const proxyUrl = proxyAuth
  ? `socks5://${proxyAuth}@${proxyDomain}`
  : null

await cafesdk.log.info(`Proxy URL: ${proxyUrl}`)

// 4. Create HTTP client config
let axiosConfig = {
  timeout: 30000,
  headers: {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'
  }
}

// 5. Configure SOCKS5 agent if proxy is enabled
if (proxyUrl) {
  const agent = new SocksProxyAgent(proxyUrl)
  axiosConfig.httpAgent = agent
  axiosConfig.httpsAgent = agent
  axiosConfig.proxy = false // Required to disable axios default proxy
  await cafesdk.log.info('SOCKS5 proxy configured')
}

// 6. Example request
try {
  const targetUrl = 'https://ipinfo.io/ip'
  await cafesdk.log.info(`Requesting: ${targetUrl}`)

  const response = await axios.get(targetUrl, axiosConfig)

  await cafesdk.log.info(`Status code: ${response.status}`)
  await cafesdk.log.info(`Current exit IP: ${response.data.trim()}`)
} catch (err) {
  await cafesdk.log.error(`Request failed: ${err.message}`)
}
```

***

### **⚠️ Notes**

* ❗ **Never hard-code proxy usernames or passwords**
* ❗ **Always use the platform-injected** `PROXY_AUTH`
* ❗ In Node.js, `proxy = false`**must be set** , otherwise the SOCKS proxy will not take effect
