Getting Started with the HTTPX Python Library

Feb 5, 2024 ยท 2 min read

The HTTPX library is a powerful and user-friendly HTTP client for Python. In this guide, we'll walk through installing HTTPX and making your first request.

Installing HTTPX

To install HTTPX, you'll need Python 3.6 or higher. The easiest way is via pip:

pip install httpx

This will download the latest version of HTTPX from PyPI and handle all the dependencies.

If you want to install a specific version, you can add ==version to the install command:

pip install httpx==0.23.0

You can also install HTTPX from source if you want the bleeding edge development version.

Making Your First Request

With HTTPX installed, we can start making requests:

import httpx

response = httpx.get('')

This sends a GET request to and prints the response body.

Some key things to note:

  • The httpx.get() method returns a Response object with the status code, headers, and other metadata.
  • We can access the response body text via response.text.
  • Going Further

    This just scratches the surface of what's possible with HTTPX. Some other ideas:

  • Custom headers, URL parameters, timeouts, retries and more
  • POST, PUT, DELETE and other HTTP verbs
  • Streaming responses
  • HTTP/2 support
  • Async requests
  • Authentication
  • The HTTPX documentation covers all this and more. The library prioritizes an easy-to-use API with powerful functionality underneath.

    So give HTTPX a try on your next Python project! Installing it is simple with pip, and you'll appreciate the elegant API when making HTTP requests.

    Browse by tags:

    Browse by language:

    The easiest way to do Web Scraping

    Get HTML from any page with a simple API call. We handle proxy rotation, browser identities, automatic retries, CAPTCHAs, JavaScript rendering, etc automatically for you

    Try ProxiesAPI for free

    curl ""

    <!doctype html>
        <title>Example Domain</title>
        <meta charset="utf-8" />
        <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />


    Don't leave just yet!

    Enter your email below to claim your free API key: