Skip to content

harrylewis/python-uinames

Repository files navigation

UINames API Python Wrapper

Travis CI Build Status

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.

Installation

This library can be installed with pip:

pip install uinames

Usage

function uinames.generate_random_identity()

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.

Parameters

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 and 500 (inclusive). The default value for this parameter is 1.
  • gender - The desired gender of all the returned identities. This should be either "male", "female", or None. The default value for this parameter is None.
  • 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", or None. The default value for this parameter is None.
  • minlen - The desired minimum combined name and surname length. This should be an integer or None. The default value for this parameter is None.
  • maxlen - The desired maximum combined name and surname length. This should be an integer or None. The default value for this parameter is None.
  • 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, and photo. The default value for this parameter is False.

class uinames.models.People

A container for a collection of Person class instances.

Attributes
  • data - A list containing all of the Person instances. This should be used to access the returned identities.

class uinames.models.Person

A container for a single identity and its properties.

Basic Attributes
  • 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.
Advanced Attributes

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 as 475431301).
  • 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 form XXXX (such as 2085), and the security number in the form XXX (such as 143).
  • 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).

About

A light Python wrapper for the UINames API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages