# 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)`&#x20;

`constructor(socksPort: number, host?: string)`&#x20;

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>>`&#x20;

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>>`&#x20;

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>>`&#x20;

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>>`&#x20;

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>>`&#x20;

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

```javascript
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();
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.anyone.io/sdk/npm/library/anonsocksclient.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
