Registry / security / tor-axios

tor-axios

JSON →
library2.1.1jsnpmunverified

A TypeScript library that wraps axios to route HTTP requests through the Tor network. Current stable version is 2.1.1. It provides a TorAxios class that automatically uses a SOCKS proxy (via Tor) for all requests, with optional control port integration to programmatically refresh the Tor session (get a new IP). Key differentiators: simple API, full TypeScript support, ability to extract httpAgent/httpsAgent for custom axios instances. Requires a running Tor daemon and axios >=1.0.0. Maintained actively.

npm install tor-axios
INSTALL
IMPORT
SIG · TOR-AXIOS
T
tor-axios
securityjavascriptv2.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TorAxios
✓ import { TorAxios } from 'tor-axios'
✗ const TorAxios = require('tor-axios').TorAxios
Default export is not available; always use named import. ESM-only since v2.
TorAxios
✓ const { TorAxios } = require('tor-axios')
✗ const TorAxios = require('tor-axios')
CommonJS 'require' must destructure named export; default import not available.
TorAxios
✓ import type { TorAxios } from 'tor-axios'
TypeScript type import works for type-only usage.

Basic usage: create TorAxios instance with default Tor SOCKS proxy and make a GET request.

import { TorAxios } from 'tor-axios'; const tor = new TorAxios({ ip: 'localhost', port: 9050, }); const response = await tor.get('http://icanhazip.com'); console.log(response.data);
Debug
Known issues
breakingVersion 2.0.0 dropped CommonJS support and removed default export.
fix
Use named import: import { TorAxios } from 'tor-axios' instead of import TorAxios from 'tor-axios'.
affects: >=2.0.0
gotchaAxios is a peer dependency; must be installed separately.
fix
Run npm install axios alongside tor-axios.
affects: >=1.0.0
gotchaTor daemon must be running and SOCKS proxy port must be open.
fix
Ensure Tor is installed and running (e.g., brew services start tor or sudo systemctl start tor).
affects: >=1.0.0
gotchaControl port and password are required for refreshSession() to work.
fix
Set controlPort and controlPassword in TorSetupOptions, and enable ControlPort in torrc.
affects: >=1.0.0
gotcharefreshSession() sends a NEWNYM signal to Tor; may affect other Tor users if using shared instance.
fix
Use with caution in shared environments; consider running dedicated Tor instance.
affects: >=1.0.0
Errors
Common errors & fixes
Error: connect ECONNREFUSED 127.0.0.1:9050
Tor daemon is not running or SOCKS proxy port is incorrect.
fix
Start Tor (tor &) or check port configuration.
Error: ControlPort authentication failed: password did not match HashedControlPassword
ControlPassword provided does not match the hashed password in torrc.
fix
Generate hash with tor --hash-password <your_password> and update torrc.
TypeError: tor_axios_1.TorAxios is not a constructor
Using default import instead of named import (CommonJS).
fix
Use const { TorAxios } = require('tor-axios');
Cannot find module 'tor-axios'
Package not installed or import path incorrect.
fix
Run npm install tor-axios axios and ensure import path is correct.
Upgrade
Version history
2.1.1latest on npm
Audit
Dependencies
axiosrequiredPeer dependency; used to make HTTP requests through Tor
Agent activity
25 hits · last 30 days
node
24
Resources
tor-axios — npm install tor-axios · libregistry