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

# How to Set Up Toolip With HTTPX

> HTTPX is a powerful and modern HTTP client for Python that supports asynchronous requests, proxy integration, streaming, and authentication. It serves as an excellent alternative to the requests library, particularly for applications that require asynchronous capabilities.

## What is HTTPX?

**HTTPX** provides both synchronous and asynchronous APIs, making it a versatile choice for handling HTTP requests, managing sessions, and working with proxies, authentication, and streaming data. When combined with **Toolip**, it enables efficient and reliable request execution.

Prefer an enterprise-grade guide? Learn more about Oculus Proxies <a href="https://docs.oculusproxies.com/integration-guides/httpx" target="_blank" rel="noopener">Httpx Integration Guide</a>.

<Tip>
  Targeting search engines like Google, Bing, or Yandex requires a specialized proxy to ensure stable access and avoid blocks. **Toolip’s Search Engine ISP Proxies** are designed specifically for this, providing reliable performance where standard proxies may fail. If your proxy test isn't working on search engines, switching to **Search Engine ISP Proxies** can resolve the issue.
</Tip>

<Steps>
  <Step title="Install Python">
    Make sure that [Python](https://www.python.org/downloads/) is installed on your machine.
  </Step>

  <Step title="Install HTTPX">
    * Execute the following to install HTTPX:

    ```bash theme={null}
    pip install httpx
    ```

    * To add support for SOCKS proxies, install it using the command below:

    ```bash theme={null}
    pip install httpx[socks]
    ```
  </Step>

  <Step title="Basic Request">
    Copy the code below to set up **HTTPX with Toolip**, ensuring you include the authentication credentials:

    * `username` - Your proxy's username.

    * `password` - Your proxy's password.

    * Basic request shouldn't require Host and Port.

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

    # Define the destination website
    url = "https://httpbin.org/basic-auth/user/pass"

    # Define authentication credentials
    auth = ("username", "password")

    # Make the request with authentication
    response = httpx.get(url, auth=auth)

    # Print the response
    print(response.status_code)
    print(response.text)
    ```
  </Step>

  <Step title="Sending SOCKS5 Request">
    Use the example below to send a **SOCKS5 request** with HTTPX:

    * `username` - Your proxy's username.

    * `password` - Your proxy's password.

    * `host` - Your proxy's host.

    * `port` - Your proxy's port.

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

    # SOCKS5 proxy with authentication
    proxies = {
    "http://": "socks5://username:password@host:port",
    "https://": "socks5://username:password@host:port",
    }

    # Make a request through the SOCKS5 proxy
    response = httpx.get("https://httpbin.org/ip", proxies=proxies)

    # Print the response
    print(response.text)
    ```
  </Step>

  <Step title="Sending Asynchronous Request">
    Check the following example to perform an **asynchronous request** using HTTPX:

    ```python Python theme={null}
    import httpx
    import asyncio

    async def fetch():
    async with httpx.AsyncClient() as client:
        response = await client.get("https://httpbin.org/basic-auth/user/pass", auth=("username", "password"))
        print(response.text)

    # Run the async function
    asyncio.run(fetch())
    ```
  </Step>
</Steps>
