You can download this code by clicking the button below.
This code is now available for download.
This function fetches user information from the randomuser.me API using the requests library for a specified user ID.
Technology Stack : requests, random, json
Code Type : Function
Code Difficulty : Intermediate
def fetch_random_user(user_id):
import requests
import random
import json
url = f"https://randomuser.me/api/?id={user_id}"
response = requests.get(url)
data = response.json()
user_info = data['results'][0]
return user_info