Anyone Docs
  • 🔷The Documentation For Anyone
    • About
    • FAQ
  • 🔷Relay Setup
    • Get Started
    • Installation and Usage
      • Setting Your Environment
        • Virtualization on Windows
        • Virtualization on macOS
        • Install Ubuntu Server 22.04
        • Server management with SSH in Windows and macOS
      • Install Anon on Linux
      • Install Anon using the apt repository
      • Update Anon and accept terms and conditions
      • Install Anon in Docker
      • Configure SOCKS5 Proxy for Anyone
      • Install Anyone Exit Relay
    • Troubleshooting Common Issues
      • Diagnosing CGNAT and Public IPv4
      • Confirm ORPort Reachability
    • Firewall and Network Configurations
      • Router Port Forwarding
      • Install and Configure Firewall
    • Advanced Configuration and Troubleshooting
      • Configure IPv4 and IPv6
      • DoS mitigation parameters
    • Relay Operator Standards
    • Exit Relay Guidelines
  • 🔷Hardware Setup
    • Setup Guide
    • Description and Specifications
    • Relay Control Panel
      • Home
      • Network Settings
      • Relay Settings
      • Relay Family
      • Proxy Settings BETA
      • Change Password
      • Logs
      • Update
    • Update (Using USB)
    • Update to WEB 3.2.0 (Using UI)
    • Troubleshooting and additional configuration
      • Router Port Forwarding
      • Diagnosing CGNAT and Public IPv4
    • Router Setup
  • 🔷Security and Privacy
    • VPS Hardening
  • 🔷Rewards Dashboard
    • Registering to the Rewards Program
    • Accessing the Rewards Dashboard
    • Using the Rewards Dashboard
    • Rewards Status
  • 🔷Anyone SDK
    • NPM SDK
      • Install NPM Package
      • Run as Library
        • Anon
        • AnonSocksClient
        • AnonControlClient
      • Run from CLI
      • Tutorials
        • Hello Anon World I
        • Hello Anon World II
        • Circuit Control I
        • Circuit Control II
    • Native SDK
      • Anyone Client Releases
      • MAN - Anon Manual
      • Tutorials
        • Anyone Services I
        • Anyone Services II
    • iOS SDK [Beta]
      • Manual Install - CocoaPods
  • 🔷Connect to Anyone
    • Connecting to Linux
      • [Beta] One-Click Linux Setup
    • Connecting to macOS
      • macOS with NPM
      • [Beta] One-Click macOS Setup
    • Connecting to Windows
      • [Beta] One-Click Windows Setup
    • Individual Applications with Anyone
    • Connect Through Hardware
  • 🔷Tokenomics
    • Introduction
    • Token Distribution
      • Token Outflow
      • Other Tokens
    • Relay Rewards
      • Lock Requirement
      • Lock Adjustments
      • Reward Multipliers
    • Additional Roles
      • Authorities and Staking
      • Governance Voting
    • Premium Circuits
      • Premium Circuits
      • Premium Circuits: Metrics
    • Summary
      • Value Accrual Summary
      • Rewards Case Study
    • Appendix
      • M Derivation
      • Risk Equation Derivation
  • 🔷Resources
    • Community and Customer Support
    • Links
    • Token
    • Whitepaper
    • Roadmap
    • API
      • REST
      • [Future] GraphQL
Powered by GitBook
On this page
  • Constructor
  • Methods

Was this helpful?

  1. Anyone SDK
  2. NPM SDK
  3. Run as Library

AnonSocksClient

The AnonSocksClient class provides a way to send HTTP requests through the Anon network using a SOCKS proxy.

Constructor

constructor(anon: Anon, host?: string)

constructor(socksPort: number, host?: string)

Creates a new instance of the AnonSocksClient class.

  • anon: Anon - An instance of the Anon class, or

  • socksPort: number - The SOCKS port to use

  • host: string (optional) - The host to use for the SOCKS proxy. Default: '127.0.0.1'

Methods

get<T = any>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>

Sends a GET request to the specified URL through the Anon network.

  • url: string - The URL to send the GET request to

  • config: AxiosRequestConfig (optional) - Additional Axios request configuration Returns: A promise that resolves with the response data

post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>

Sends a POST request to the specified URL through the Anon network.

  • url: string - The URL to send the POST request to

  • data: any (optional) - The data to be sent as the request body

  • config: AxiosRequestConfig (optional) - Additional Axios request configuration Returns: A promise that resolves with the response data

put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>

Sends a PUT request to the specified URL through the Anon network.

  • url: string - The URL to send the PUT request to

  • data: any (optional) - The data to be sent as the request body

  • config: AxiosRequestConfig (optional) - Additional Axios request configuration Returns: A promise that resolves with the response data

delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>

Sends a DELETE request to the specified URL through the Anyone Network.

  • url: string - The URL to send the DELETE request to

  • config: AxiosRequestConfig (optional) - Additional Axios request configuration Returns: A promise that resolves with the response data

patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>

Sends a PATCH request to the specified URL through the Anyone Network.

  • url: string - The URL to send the PATCH request to

  • data: any (optional) - The data to be sent as the request body

  • config: AxiosRequestConfig (optional) - Additional Axios request configuration Returns: A promise that resolves with the response data

Usage Example

import { Anon, AnonSocksClient } from '@anyone-protocol/anyone-client';

const anon = new Anon();
await anon.start();

const client = new AnonSocksClient(anon);

try {
  const response = await client.get('https://api.example.com/data');
  console.log(response.data);

  const postResponse = await client.post('https://api.example.com/users', { name: 'John Doe' });
  console.log(postResponse.data);
} catch (error) {
  console.error('Error:', error.message);
} finally {
  await anon.stop();
}
PreviousAnonNextAnonControlClient

Last updated 5 months ago

Was this helpful?

🔷