Random User Fetch with httpx

  • Share this:

Code introduction


This function uses the httpx library to send a GET request to 'https://randomuser.me/' and parse the returned JSON data.


Technology Stack : httpx

Code Type : HTTP request

Code Difficulty : Intermediate


                
                    
def fetch_random_user(httpx_client):
    """
    Fetches a random user from the 'https://randomuser.me/' API using the httpx library.
    """
    response = httpx_client.get('https://randomuser.me/')
    return response.json()

# JSON output                
              
Tags: