> ## Documentation Index
> Fetch the complete documentation index at: https://www.illusory.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Code Examples

> Use Illusory Residential Proxies with curl, browsers, Python, and Node.

Every example uses the same connection details. Replace `USERNAME` and `SECRET` with your credentials, and adjust the targeting tokens (`-country-us`, `-session-…`) to taste.

| Field              | Value                                                      |
| ------------------ | ---------------------------------------------------------- |
| Proxy URL          | `http://USERNAME-country-us:SECRET@proxy.illusory.io:1080` |
| Host (recommended) | `proxy.illusory.io`                                        |
| IP (alternative)   | `160.202.129.71`                                           |
| Port               | `1080`                                                     |
| Protocols          | HTTP/HTTPS and SOCKS5                                      |

The domain and IP are interchangeable. Examples below use the domain; swap in `160.202.129.71` if you prefer to connect by IP.

## Code samples

<CodeGroup>
  ```bash cURL theme={null}
  curl -x "http://USERNAME-country-us:SECRET@proxy.illusory.io:1080" https://api.ipify.org
  ```

  ```python Python theme={null}
  import requests

  proxy = "http://USERNAME-country-us:SECRET@proxy.illusory.io:1080"
  proxies = {"http": proxy, "https": proxy}

  r = requests.get("https://api.ipify.org?format=json", proxies=proxies, timeout=30)
  print(r.json())  # the residential exit IP

  # For a sticky session, add a session token to the username:
  # proxy = "http://USERNAME-country-us-session-checkout1-sesstime-30:SECRET@proxy.illusory.io:1080"
  ```

  ```typescript TypeScript theme={null}
  import axios from "axios";
  import { HttpsProxyAgent } from "https-proxy-agent";

  const proxy: string =
    "http://USERNAME-country-us:SECRET@proxy.illusory.io:1080";
  const agent = new HttpsProxyAgent(proxy);

  const { data } = await axios.get<{ ip: string }>(
    "https://api.ipify.org?format=json",
    { httpAgent: agent, httpsAgent: agent },
  );
  console.log(data); // the residential exit IP

  // For a sticky session, add a session token to the username:
  // const proxy = "http://USERNAME-country-us-session-checkout1-sesstime-30:SECRET@proxy.illusory.io:1080";
  ```

  ```rust Rust theme={null}
  use std::error::Error;

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn Error>> {
      let proxy_url = "http://USERNAME-country-us:SECRET@proxy.illusory.io:1080";
      // For a sticky session, add a session token to the username:
      // let proxy_url = "http://USERNAME-country-us-session-checkout1-sesstime-30:SECRET@proxy.illusory.io:1080";
      // For SOCKS5, enable the `socks` cargo feature (reqwest = { version = "0.12", features = ["socks"] }) and use a socks5h:// URL.

      let client = reqwest::Client::builder()
          .proxy(reqwest::Proxy::all(proxy_url)?)
          .build()?;

      let ip: String = client
          .get("https://api.ipify.org")
          .send()
          .await?
          .text()
          .await?;

      println!("{ip}"); // the residential exit IP
      Ok(())
  }
  ```
</CodeGroup>

<Note>
  Sticky sessions: add a session token to the username (for example `-session-checkout1-sesstime-30`) to keep the same residential exit IP for up to 30 minutes. Drop the token for rotating mode.
</Note>

## Browser (FoxyProxy)

1. Install the **FoxyProxy** extension (Chrome or Firefox).
2. Add a new proxy:
   * **Type:** HTTP
   * **Host:** `proxy.illusory.io`
   * **Port:** `1080`
   * **Username:** `USERNAME-country-us` (add any targeting tokens here)
   * **Password:** `SECRET`
3. Enable the proxy and browse. Your traffic now exits through a residential IP.

<Note>
  Because targeting lives in the username, you can save multiple FoxyProxy entries (one per country or session) and switch between them instantly.
</Note>

## Tips

* For best throughput, run **multiple parallel requests** with rotating mode. Residential bandwidth aggregates across peers.
* Use `socks5h://` (not `socks5://`) with curl so DNS is resolved through the proxy.
* Keep sticky sessions short-lived and scoped to a single flow.
