Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

HTTPX · Function

get

AsyncClient.get asynchronously performs an HTTP GET request and returns an HTTPX response. Await the call, and manage the client with an async context manager or explicit closure.

How it works

AsyncClient.get performs an asynchronous HTTP GET and returns a response after the request completes. Call it with await, typically inside an async with block so the client’s resources are closed automatically.

Syntax

await client.get(url, *, params=None, headers=None, cookies=None, auth=None, proxy=None, follow_redirects=False, verify=True, timeout=Timeout(timeout=5.0), trust_env=True)

Parameters

NameTypeDescription
urlstr or URLTarget URL for the GET request.
paramsQueryParamTypes | NoneOptional query parameters appended to the URL.
headersHeaderTypes | NoneOptional request headers.
cookiesCookieTypes | NoneOptional cookies sent with the request.
authAuthTypes | NoneOptional authentication configuration.
proxyProxyTypes | NoneOptional proxy configuration.
follow_redirectsboolWhether redirects are followed.
verifyssl.SSLContext | str | boolTLS certificate verification setting.
timeoutTimeoutTypes | NoneRequest timeout configuration.
trust_envboolWhether environment configuration is trusted.

Returns

Response

Key points

  • The client supports connection pooling, HTTP/2, redirects, and cookie persistence.
  • A single asynchronous client can be reused by multiple concurrent tasks.
  • The documented call pattern awaits client.get and stores the resulting response.

Common mistakes

  • Because this is an asynchronous method, omitting await leaves you with a coroutine rather than the completed response.
  • Use a context-managed client for automatic cleanup; otherwise close an explicitly created client with await client.aclose().

Example: Asynchronous GET request

import asyncio
import httpx

async def main():
    async with httpx.AsyncClient() as client:
        response = await client.get(
            "https://httpbin.org/get",
            params={"q": "httpx"},
        )
        response.raise_for_status()
        print(response.json()["args"])

asyncio.run(main())

Creates a scoped asynchronous client, awaits a GET request with query parameters, validates success, and reads the decoded JSON response.

When to use it

Asynchronous retrieval

Retrieve a web resource from an async application.

Query-driven requests

Send filters or search terms without manually constructing a URL.

Shared connection-pool access

Reuse one client for related concurrent operations.

Interview questions

QWhat does AsyncClient.get do?

AsyncClient.get sends an HTTP GET request and must be awaited. It returns an HTTPX response object, which exposes status, headers, body, and related response information.

Follow-up: How should a client be managed across multiple requests? Use one shared AsyncClient when appropriate, and close it with the async context manager or await client.aclose().

QHow is an asynchronous GET request called?

The method is invoked on httpx.AsyncClient, and its URL may include request-specific options such as query parameters. The documented async usage is response = await client.get(...).

Follow-up: How would you ensure a failed HTTP status is handled? Inspect the returned response status or call the response’s status-checking method before consuming the result.

QWhy use AsyncClient instead of the synchronous top-level helper?

An AsyncClient provides asynchronous HTTP access together with connection pooling and can be shared between tasks. A context-managed instance ensures its resources are released after use.

Follow-up: What client feature can be enabled for HTTP/2? Construct AsyncClient with http2=True, then inspect the response protocol version through its HTTP-version property.

  • AsyncClient
  • AsyncClient.request
  • AsyncClient.stream
  • Response
  • httpx.get

Source: Developer Interface - HTTPX. Checked 2026-10-15.