Random User Data Fetcher Function

  • Share this:

Code introduction


This function makes an HTTP GET request to the API at https://randomuser.me/ to fetch random user data. The API returns data in JSON format, which the function parses into a Python dictionary.


Technology Stack : requests

Code Type : HTTP request

Code Difficulty : Intermediate


                
                    
import requests
import random

def fetch_random_user_data():
    url = 'https://randomuser.me/api/'
    response = requests.get(url)
    data = response.json()
    return data                
              
Tags: