Generating Random User Profiles for a Web Application

Sergey Sokurenko
2 min readMar 15, 2018

--

Often happens, when you develop, or test your web app, you need some dummy users profiles to show on UI or save into the database. To solve it you can create your service, or use one of already available services.

Of course, with your custom solution, you have more flexibility and control over the model of the user profile data, but for demo or test purposes, a third-party service will work just fine.

One of such services is https://randomuser.me. To get a random user profile just use the default end point: https://randomuser.me/api/ it will return JSON data in the following format:

{“results”: [{“gender”: “female”,”name”: {“title”: “miss”,”first”: “ramona”,”last”: “carter”},”location”: {“street”: “2286 frances ct”,”city”: “townsville”,”state”: “queensland”,”postcode”: 6699},”email”: “ramona.carter@example.com”,”login”: {“username”: “bigrabbit281”,”password”: “salvador”,”salt”: “NgEKDglD”,”md5": “8946b15e0a5411bfdb52df5ac1b90520”,”sha1": “f460f12a714919499d413a69a76ca2f262e9c198”,”sha256": “fbb37b276b0900fcfdcfc47f0584f9859726c3791b9b0e453dbac8178be26412”},”dob”: “1977–05–01 13:29:43”,”registered”: “2009–05–12 00:46:03”,”phone”: “08–4889–2804”,”cell”: “0479–076–830”,”id”: {“name”: “TFN”,”value”: “212902602”},”picture”: {“large”: “https://randomuser.me/api/portraits/women/90.jpg","medium": “https://randomuser.me/api/portraits/med/women/90.jpg","thumbnail": “https://randomuser.me/api/portraits/thumb/women/90.jpg"},"nat": “AU”}],”info”: {“seed”: “7d4db9727474515a”,”results”: 1,”page”: 1,”version”: “1.1”}}

As you can see, it includes all basic data like name, email, address, profile picture, etc…

If you need to get all the time the same result, just add the seed query param to the request, for example https://randomuser.me/api/?seed=somestring will always return you a profile for Elouan Lecomte.

If you need a bunch of random user profiles, add the results param. The following example will return an array of 10 random user profiles: https://randomuser.me/api/?results=10

Sometimes you just a user profile picture, in this case check the following service http://avatars.adorable.io. Its simple API provides you with a user profile image with requested size. What is also nice, it returns persistent image according to the request. For example the following request https://api.adorable.io/avatars/400/daniel will always return you this 400x400 image file:

Randomly generated user profile picture.

______________________

Pluralsight is my favourite technology learning platform.

You can get 50% discount for the first month with this referral link: http://referral.pluralsight.com/mQdfX3Y

--

--