{"library":"socks-proxy-agent","title":"SOCKS Proxy HTTP/HTTPS Agent","type":"library","description":"socks-proxy-agent is a Node.js module that provides an `http.Agent` implementation, enabling HTTP and HTTPS requests, and WebSocket connections, to be routed through a SOCKS proxy server. It supports SOCKS4, SOCKS4a, SOCKS5, and SOCKS5h protocols, offering flexibility in how connections are established and resolved. The current stable version is 10.0.0. The package is part of the broader `proxy-agents` monorepo by TooTallNate, which implies a release cadence often synchronized with its core dependency `agent-base` and Node.js LTS updates, as evidenced by the recent major version bump due to an increased minimum Node.js requirement. Its key differentiator is its focused and robust implementation for SOCKS proxies, making it suitable for scenarios requiring specific proxy tunneling capabilities for anonymity, bypassing geo-restrictions, or internal network access.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install socks-proxy-agent"],"cli":null},"imports":["import { SocksProxyAgent } from 'socks-proxy-agent';","import type { SocksProxyAgentOptions } from 'socks-proxy-agent';","import https from 'https'; // or http\nconst agent = new SocksProxyAgent(proxyUri);"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/TooTallNate/proxy-agents","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/socks-proxy-agent","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import https from 'https';\nimport { SocksProxyAgent } from 'socks-proxy-agent';\n\n// Replace with your SOCKS proxy URI, including optional authentication\n// Example with username/password: 'socks://user%40example.com:password@proxy.example.com:1080'\nconst SOCKS_PROXY_URI = process.env.SOCKS_PROXY_URI ?? 'socks://127.0.0.1:1080';\n\n// Create a new SocksProxyAgent instance\nconst agent = new SocksProxyAgent(SOCKS_PROXY_URI);\n\nconsole.log(`Making HTTPS request through SOCKS proxy: ${SOCKS_PROXY_URI}`);\n\nhttps.get('https://ipinfo.io/json', { agent }, (res) => {\n  console.log(`Response Status: ${res.statusCode}`);\n  console.log('Response Headers:', res.headers);\n\n  let data = '';\n  res.on('data', (chunk) => {\n    data += chunk;\n  });\n  res.on('end', () => {\n    console.log('Response Body:');\n    try {\n      const json = JSON.parse(data);\n      console.log(json);\n    } catch (e) {\n      console.error('Failed to parse JSON response:', e);\n      console.log(data);\n    }\n  });\n}).on('error', (err) => {\n  console.error('Error making HTTPS request:', err.message);\n});","lang":"typescript","description":"Demonstrates how to create a `SocksProxyAgent` instance and use it with Node.js's built-in `https` module to route an HTTPS request through a SOCKS proxy, including basic error handling.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}