This is a light python wrapper for the UINames API developed by Thom. It allows you to generate random identities (based on a few parameters) for use as mock user data.
This version has only been tested with the latest version of python 2.7.
This library can be installed with pip:
pip install uinames
This uses the UINames API to generate a single, random identity, and returns it in the form of a Person class instance (explained below).
function uinames.generate_random_identities(amount=1, gender=None, region=None, minlen=None, maxlen=None, ext=False)
This uses the UINames API to generate 1 or more random identities, and returns it in the form of a People class instance (explained below). Within the People instance, the individual Person instances can be accessed.
All of the following parameters are optional, but have default values.
- amount - The number of identities to return. This should be an integer between
1
and500
(inclusive). The default value for this parameter is1
. - gender - The desired gender of all the returned identities. This should be either
"male"
,"female"
, orNone
. The default value for this parameter isNone
. - region - The desired region of origin for all the returned identities. This can be one of the following:
"Albania"
,"Argentina"
,"Armenia"
,"Australia"
,"Austria"
,"Azerbaijan"
,"Bangladesh"
,"Belgium"
,"Bosnia and Herzegovina"
,"Brazil"
,"Canada"
,"China"
,"Colombia"
,"Denmark"
,"Egypt"
,"England"
,"Estonia"
,"Finland"
,"France"
,"Georgia"
,"Germany"
,"Greece"
,"Hungary"
,"India"
,"Iran"
,"Israel"
,"Italy"
,"Japan"
,"Korea"
,"Mexico"
,"Morocco"
,"Netherlands"
,"New Zealand"
,"Nigeria"
,"Norway"
,"Pakistan"
,"Poland"
,"Portugal"
,"Romania"
,"Russia"
,"Slovakia"
,"Slovenia"
,"Spain"
,"Sweden"
,"Switzerland"
,"Turkey"
,"Ukraine"
,"United States"
,"Vietnam"
, orNone
. The default value for this parameter isNone
. - minlen - The desired minimum combined name and surname length. This should be an integer or
None
. The default value for this parameter isNone
. - maxlen - The desired maximum combined name and surname length. This should be an integer or
None
. The default value for this parameter isNone
. - ext - This should be a Boolean value. When set to
True
, this parameter causes all the returned entities to contain additional properties, such as:age
,title
,phone
,birthday
,email
,password
,credit_card
, andphoto
. The default value for this parameter isFalse
.
A container for a collection of Person class instances.
- data - A list containing all of the Person instances. This should be used to access the returned identities.
A container for a single identity and its properties.
- name - The first name of the returned identity.
- surname - The last name of the returned identity.
- gender - The gender of the returned identity. This will be either
"male"
or"female"
. - region - The region of origin of the identity. This will be one from the list above, in capitalized form.
The following attributes will be present when the ext
parameter is set to True
.
- age - The age of the identity. This will an integer.
- title - The title of the identity. This will be either
"mr"
or"mrs"
. - phone - The phone number of the identity. This will be of the format
"(444) 444 4444"
. - birthday - The birthday of the identity. This will be a dictionary containing the birthday in the following formats:
"DD/MM/YYYY"
(such as"24/01/1985"
),"MM/DD/YYYY"
(such as"01/24/1985"
), and a raw integer value representing the time since Epoch (such as475431301
). - email - The email of the identity. This will be a string.
- password - The password of the identity. This will be a string.
- credit_card - The credit card information of the identity. This will contain the following data: An expiration field in the form
"MM/YY"
(such as"3/19"
), the credit card number in the form"XXXX-XXXX-XXXX-XXXX"
(such as"2115-8343-4559-1249"
), the PIN number in the formXXXX
(such as2085
), and the security number in the formXXX
(such as143
). - photo - An avatar of the identity. This will be a URL.
Note that accessing a non-existing property will raise a PropertyUnavailable exception (uinames.utils.PropertyUnavailable).