npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

random-users-generator

v1.0.7

Published

This is a client to use fake user APIs at https://randomuser.me/

Downloads

38

Readme

Random Users Generator

This is a wrapper to use fake user APIs at https://randomuser.me/

Installation

npm i --save random-users-generator

Usage

Once the package is installed, you can import the library with the name you prefer using import and start using it, see example.

import generatorClient, { UsersResponse } from "random-users-generator";

Response data model is the same as the REST API.

Example

import generatorClient, { UsersResponse } from "random-users-generator";

// request single user
generatorClient.getUsers()
    .then((data: UsersResponse) => {
        // handle response data
        console.log(data);
    }).catch(err => {
        // handle errors
        console.error(err);
    });

The function getUsers() accepts an option object to specify data you want to retrieve, all parameters are optional. For example:

import generatorClient, { UsersResponse } from "random-users-generator";

// retrieve 10 users, only email address field
generatorClient.getUsers({
    results: 10,
    include: ['email'],
}).then((data: UsersResponse) => {
    // handle response data
    console.log(data);
}).catch(err => {
    // handle errors
    console.error(err);
});

Request Options

| Parameter | Type | Description | Required | Allowed Values | |-------------|-----------------|----------------------------------------------------------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------| | info | boolean | if you want info attribute in the response | no | true or false | | results | number | number of results | no | any integer | | seed | string | a seed used to generate always same sets of users (useful for pages) | no | any string | | page | number | number of the page you are requesting | no | any integer | | gender | string | gender of generated users | no | 'male' \| 'female' | | password | PasswordOptions | password generation policy | no | see PasswordOptions | | nationality | string[] | nationality of generated users | no | 'AU' \| 'BR' \| 'CA' \| 'CH' \| 'DE' \| 'DK' \| 'ES' \| 'FI' \| 'FR' \| 'GB' \| 'IE' \| 'IN' \| 'IR' \| 'MX' \| 'NL' \| 'NO' \| 'NZ' \| 'RS' \| 'TR' \| 'UA' \| 'US' | | include | string[] | include fields in response | no | 'gender' \| 'name' \| 'location' \| 'email' \| 'login' \| 'registered' \| 'dob' \| 'phone' \| 'cell' \| 'id' \| 'picture' \| 'nat' | | exclude | string[] | exclude fields in response | no | 'gender' \| 'name' \| 'location' \| 'email' \| 'login' \| 'registered' \| 'dob' \| 'phone' \| 'cell' \| 'id' \| 'picture' \| 'nat' |

PasswordOptions

| Parameter | Type | Description | Required | Allowed Values | |-----------|----------|------------------------------------------------------------|----------|---------------------------------------------| | charset | string[] | what type of characters include in the generated password | no | 'special' \| 'upper' \| 'lower' \| 'number' | | minLength | number | min length of generated password | no | any number | | maxLength | number | max length of generated password | no | any number |

Response Data

{
  "results": [
    {
      "gender": "female",
      "name": {
        "title": "Miss",
        "first": "Jennie",
        "last": "Nichols"
      },
      "location": {
        "street": {
          "number": 8929,
          "name": "Valwood Pkwy"
        },
        "city": "Billings",
        "state": "Michigan",
        "country": "United States",
        "postcode": "63104",
        "coordinates": {
          "latitude": "-69.8246",
          "longitude": "134.8719"
        },
        "timezone": {
          "offset": "+9:30",
          "description": "Adelaide, Darwin"
        }
      },
      "email": "[email protected]",
      "login": {
        "uuid": "7a0eed16-9430-4d68-901f-c0d4c1c3bf00",
        "username": "yellowpeacock117",
        "password": "addison",
        "salt": "sld1yGtd",
        "md5": "ab54ac4c0be9480ae8fa5e9e2a5196a3",
        "sha1": "edcf2ce613cbdea349133c52dc2f3b83168dc51b",
        "sha256": "48df5229235ada28389b91e60a935e4f9b73eb4bdb855ef9258a1751f10bdc5d"
      },
      "dob": {
        "date": "1992-03-08T15:13:16.688Z",
        "age": 30
      },
      "registered": {
        "date": "2007-07-09T05:51:59.390Z",
        "age": 14
      },
      "phone": "(272) 790-0888",
      "cell": "(489) 330-2385",
      "id": {
        "name": "SSN",
        "value": "405-88-3636"
      },
      "picture": {
        "large": "https://randomuser.me/api/portraits/men/75.jpg",
        "medium": "https://randomuser.me/api/portraits/med/men/75.jpg",
        "thumbnail": "https://randomuser.me/api/portraits/thumb/men/75.jpg"
      },
      "nat": "US"
    }
  ],
  "info": {
    "seed": "56d27f4a53bd5441",
    "results": 1,
    "page": 1,
    "version": "1.4"
  }
}

Please feel free to make suggestion or PR to improve the client. If you are using this library please star the repo for visibility.