Introduction
Modern applications often require test user data during development. Instead of creating fake users manually, developers can use the free API provided by Random User Generator API. This service generates realistic user profiles including names, emails, phone numbers, addresses, and profile images.
This article explains the API concept, request structure, response format, backend implementation, and frontend integration using a practical example.
Overview of the Random User API
The Random User API is a free REST service used to generate fake user data for testing applications, prototypes, and UI development. It returns structured data in formats like JSON, XML, CSV, or YAML.
Basic API Endpoint
https://randomuser.me/api/
When this endpoint is called, it returns a randomly generated user profile.
Example API Response
{
"results":[
{
"gender":"female",
"name":{
"title":"Miss",
"first":"Jennie",
"last":"Nichols"
},
"email":"[email protected]",
"phone":"(272) 790-0888",
"location":{
"city":"Billings",
"state":"Michigan",
"country":"United States"
},
"picture":{
"large":"https://randomuser.me/api/portraits/women/75.jpg"
}
}
]
}
The API returns a JSON object containing a results array where each element represents a user profile.
API Request Parameters
Developers can customize the generated data using query parameters.
Generate Multiple Users
https://randomuser.me/api/?results=10
Filter by Gender
https://randomuser.me/api/?gender=female
Filter by Nationality
https://randomuser.me/api/?nat=us
Example
https://randomuser.me/api/?results=5&gender=male&nat=us
This returns 5 male users from the United States.
System Architecture
A simple application using this API typically follows this workflow.
User opens webpage
↓
Frontend sends request to backend API
↓
Backend calls Random User API
↓
API returns generated user profiles
↓
Backend forwards response to frontend
↓
Frontend displays user data
Backend Implementation (ASP.NET Web API)
Create a controller to call the Random User API and return the data.
UserController.cs
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
namespace RandomUserAPI.Controllers
{
public class UserController : ApiController
{
[HttpGet]
[Route("api/users")]
public async Task<IHttpActionResult> GetUsers()
{
string url = "https://randomuser.me/api/?results=5";
using (HttpClient client = new HttpClient())
{
var response = await client.GetAsync(url);
if (!response.IsSuccessStatusCode)
return BadRequest("API request failed");
var result = await response.Content.ReadAsStringAsync();
return Ok(result);
}
}
}
}

Join the conversation! Your thoughts help the community grow.