> For the complete documentation index, see [llms.txt](https://docs.anyone.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.anyone.io/sdk/npm/tutorials/ii.md).

# Hello Anon World II

In part II, we will introduce the AnonSocksClient and make our first request over the internet - fetching your (new) IP address! We will continue from the node module and codebase from [Hello Anon World I](/sdk/npm/tutorials/i.md).

### Anon Socks Client

The AnonSocksClient is used to tunnel http(s) requests through the network. It provides implementations for `get, post, delete`  and more that automatically use a running instance of the Anyone client. It can be imported much like the Anon library:

<pre class="language-javascript"><code class="lang-javascript"><strong>import { AnonSocksClient } from "@anyone-protocol/anyone-client";
</strong></code></pre>

and instantiated immediately after the instantiation of the main **anon** client, taking it as reference:

```javascript
// ..imports and function statements..
const anon = new Anon({ displayLog: false, socksPort: 9050, controlPort: 9051 });
const anonSocksClient = new AnonSocksClient(anon);
```

For those coming in from part I, you'll notice some new arguments in the **anon** instantiation - these are optional arguments that become relevant when dealing with SOCKS routing, circuit control and debugging. Seen in this code snippet are the default values for each one.

<details>

<summary>What <em>are</em> SOCKS? <span data-gb-custom-inline data-tag="emoji" data-code="1f9e6">🧦</span></summary>

These SOCKS aren't for your feet! SOCKS is an acronym for Socket Secure - an internet protocol that allows you to route your traffic to a 'proxy server' (i.e., a server that sits in between you and your eventual, varied list of destinations).&#x20;

Importantly, a SOCKS proxy server can run locally, listening to any requests made on a specific port (known as 'binding' to that port). In this case, the anon SOCKS process listens to any request made to the specified socksPort, forwards this through a circuit in the Anon network, and returns the result to whichever process makes the request.&#x20;

</details>

### Fetching our IP

Here, we will be calling `anonSocksClient.get` to fetch our IP through the network. We'll be using the public, free service at [https://api.ipify.org](<https://api.ipify.org >), but you can choose any that works as an API! We will simply call 'get' on the API, await its result and print the result:

```javascript
const response = await anonSocksClient.get('https://api.ipify.org?format=json');
console.log('Response:', response.data);
```

Let's see the AnonSocksClient setup and this logic in the full function (note that, for now, a short wait time is required after `anon.start()` and before making requests through the network).&#x20;

```javascript
import { Anon } from "@anyone-protocol/anyone-client";
import { AnonSocksClient } from "@anyone-protocol/anyone-client";

async function main() {
    const anon = new Anon();
    const anonSocksClient = new AnonSocksClient(anon);

    try {
        await anon.start();
        await new Promise(resolve => setTimeout(resolve, 15000));
        
        const response = await anonSocksClient.get('https://api.ipify.org?format=json');
        console.log('Response:', response.data);
        
    } catch(error) {
        console.log(error)
    } finally {
        await anon.stop()
    }
}

main()
```

Running `node <programName>.js` from the command line will show the same setup logs as before and then the result of the IP lookup! We're now, as far as external sites are concerned, coming out of Bayern, Germany. Cool!&#x20;

<figure><img src="/files/xUaagFEkB2CTSWJSjnsd" alt=""><figcaption></figcaption></figure>

See the full code on [GitHub](https://github.com/anyone-protocol).&#x20;

Now, lets look into more fine-tuned circuit control.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.anyone.io/sdk/npm/tutorials/ii.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
