interface-forge - v2.5.0
    Preparing search index...

    Class InternetModule

    Module to generate internet related entries.

    For user accounts, you may need an email() and a password(), as well as a ASCII username() or Unicode displayName(). Since the emails generated could coincidentally be real email addresses, you should not use these for sending real email addresses. If this is a concern, use exampleEmail() instead.

    For websites, you can generate a domainName() or a full url().

    To make your data more 🔥, you can use emoji().

    You also have access to a number of the more technical elements of web requests, such as httpMethod, httpStatusCode, ip, mac, userAgent, and port.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    faker: Faker

    Methods

    • Generates a random css hex color code in aesthetically pleasing color palette.

      Based on http://stackoverflow.com/questions/43044/algorithm-to-randomly-generate-an-aesthetically-pleasing-color-palette

      Parameters

      • Optionaloptions: { blueBase?: number; greenBase?: number; redBase?: number }

        An options object.

        • OptionalblueBase?: number

          The optional base blue in range between 0 and 255.

          0
          
        • OptionalgreenBase?: number

          The optional base green in range between 0 and 255.

          0
          
        • OptionalredBase?: number

          The optional base red in range between 0 and 255.

          0
          

      Returns string

      faker.color.rgb(): For generating a random RGB color.

      faker.internet.color() // '#30686e'
      faker.internet.color({ redBase: 100, greenBase: 100, blueBase: 100 }) // '#4e5f8b'

      2.0.1

      Please use faker.color.rgb() or any of the other color methods instead.

    • Generates a display name using the given person's name as base. The resulting display name may use one or both of the provided names. If the input names include Unicode characters, the resulting display name will contain Unicode characters. It will not contain spaces.

      Parameters

      • Optionaloptions: { firstName?: string; lastName?: string }

        An options object.

        • OptionalfirstName?: string

          The optional first name to use.

          faker.person.firstName()
          
        • OptionallastName?: string

          The optional last name to use.

          faker.person.lastName()
          

      Returns string

      faker.internet.username(): For generating a plain ASCII username.

      faker.internet.displayName() // 'Nettie_Zboncak40'
      faker.internet.displayName({ firstName: 'Jeanne', lastName: 'Doe' }) // 'Jeanne98' - note surname not used.
      faker.internet.displayName({ firstName: 'John', lastName: 'Doe' }) // 'John.Doe'
      faker.internet.displayName({ firstName: 'Hélene', lastName: 'Müller' }) // 'Hélene_Müller11'
      faker.internet.displayName({ firstName: 'Фёдор', lastName: 'Достоевский' }) // 'Фёдор.Достоевский50'
      faker.internet.displayName({ firstName: '大羽', lastName: '陳' }) // '大羽.陳'

      8.0.0

    • Generates a random domain name.

      Returns string

      faker.internet.domainName() // 'slow-timer.info'
      

      2.0.1

    • Returns a random domain suffix.

      Returns string

      faker.internet.domainSuffix() // 'com'
      faker.internet.domainSuffix() // 'name'

      2.0.1

    • Generates a random domain word.

      Returns string

      faker.internet.domainWord() // 'close-reality'
      faker.internet.domainWord() // 'weird-cytoplasm'

      2.0.1

    • Generates an email address using the given person's name as base.

      Parameters

      • Optionaloptions: {
            allowSpecialCharacters?: boolean;
            firstName?: string;
            lastName?: string;
            provider?: string;
        }

        The options to use.

        • OptionalallowSpecialCharacters?: boolean

          Whether special characters such as .!#$%&'*+-/=?^_`{|}~ should be included in the email address.

          false
          
        • OptionalfirstName?: string

          The optional first name to use.

          faker.person.firstName()
          
        • OptionallastName?: string

          The optional last name to use.

          faker.person.lastName()
          
        • Optionalprovider?: string

          The mail provider domain to use. If not specified, a random free mail provider will be chosen.

      Returns string

      faker.internet.email() // 'Kassandra4@hotmail.com'
      faker.internet.email({ firstName: 'Jeanne'}) // 'Jeanne63@yahoo.com'
      faker.internet.email({ firstName: 'Jeanne'}) // 'Jeanne_Smith63@yahoo.com'
      faker.internet.email({ firstName: 'Jeanne', lastName: 'Doe' }) // 'Jeanne.Doe63@yahoo.com'
      faker.internet.email({ firstName: 'Jeanne', lastName: 'Doe', provider: 'example.fakerjs.dev' }) // 'Jeanne_Doe88@example.fakerjs.dev'
      faker.internet.email({ firstName: 'Jeanne', lastName: 'Doe', provider: 'example.fakerjs.dev', allowSpecialCharacters: true }) // 'Jeanne%Doe88@example.fakerjs.dev'

      2.0.1

    • Generates a random emoji.

      Parameters

      • Optionaloptions: { types?: readonly EmojiType[] }

        Options object.

        • Optionaltypes?: readonly EmojiType[]

          A list of the emoji types that should be used.

          Object.keys(faker.definitions.internet.emoji)
          

      Returns string

      faker.internet.emoji() // '🥰'
      faker.internet.emoji({ types: ['food', 'nature'] }) // '🥐'

      6.2.0

    • Generates an email address using an example mail provider using the given person's name as base.

      Parameters

      • Optionaloptions: { allowSpecialCharacters?: boolean; firstName?: string; lastName?: string }

        An options object.

        • OptionalallowSpecialCharacters?: boolean

          Whether special characters such as .!#$%&'*+-/=?^_`{|}~ should be included in the email address.

          false
          
        • OptionalfirstName?: string

          The optional first name to use.

          faker.person.firstName()
          
        • OptionallastName?: string

          The optional last name to use.

          faker.person.lastName()
          

      Returns string

      faker.internet.exampleEmail() // 'Helmer.Graham23@example.com'
      faker.internet.exampleEmail({ firstName: 'Jeanne' }) // 'Jeanne96@example.net'
      faker.internet.exampleEmail({ firstName: 'Jeanne' }) // 'Jeanne.Smith96@example.net'
      faker.internet.exampleEmail({ firstName: 'Jeanne', lastName: 'Doe' }) // 'Jeanne_Doe96@example.net'
      faker.internet.exampleEmail({ firstName: 'Jeanne', lastName: 'Doe', allowSpecialCharacters: true }) // 'Jeanne%Doe88@example.com'

      3.1.0

    • Returns a random http method.

      Can be either of the following:

      • GET
      • POST
      • PUT
      • DELETE
      • PATCH

      Returns "GET" | "POST" | "PUT" | "DELETE" | "PATCH"

      faker.internet.httpMethod() // 'PATCH'
      

      5.4.0

    • Generates a random HTTP status code.

      Parameters

      • Optionaloptions: { types?: readonly HTTPStatusCodeType[] }

        Options object.

        • Optionaltypes?: readonly HTTPStatusCodeType[]

          A list of the HTTP status code types that should be used.

          Object.keys(faker.definitions.internet.http_status_code)
          

      Returns number

      faker.internet.httpStatusCode() // 200
      faker.internet.httpStatusCode({ types: ['success', 'serverError'] }) // 500

      7.0.0

    • Generates a random IPv4 or IPv6 address.

      Returns string

      faker.internet.ip() // '245.108.222.0'
      faker.internet.ip() // '4e5:f9c5:4337:abfd:9caf:1135:41ad:d8d3'

      2.0.1

    • Generates a random IPv4 address.

      Parameters

      • Optionaloptions: { cidrBlock?: string }

        The optional options object.

        • OptionalcidrBlock?: string

          The optional CIDR block to use. Must be in the format x.x.x.x/y.

          '0.0.0.0/0'
          

      Returns string

      faker.internet.ipv4() // '245.108.222.0'
      faker.internet.ipv4({ cidrBlock: '192.168.0.0/16' }) // '192.168.215.224'

      6.1.1

    • Generates a random IPv4 address.

      Parameters

      • Optionaloptions: {
            network?:
                | "any"
                | "loopback"
                | "private-a"
                | "private-b"
                | "private-c"
                | "test-net-1"
                | "test-net-2"
                | "test-net-3"
                | "link-local"
                | "multicast";
        }

        The optional options object.

        • Optionalnetwork?:
              | "any"
              | "loopback"
              | "private-a"
              | "private-b"
              | "private-c"
              | "test-net-1"
              | "test-net-2"
              | "test-net-3"
              | "link-local"
              | "multicast"

          The optional network to use. This is intended as an alias for well-known cidrBlocks.

          'any'
          

      Returns string

      faker.internet.ipv4() // '245.108.222.0'
      faker.internet.ipv4({ network: 'private-a' }) // '10.199.154.205'

      6.1.1

    • Generates a random IPv4 address.

      Parameters

      • Optionaloptions:
            | { cidrBlock?: string }
            | {
                network?:
                    | "any"
                    | "loopback"
                    | "private-a"
                    | "private-b"
                    | "private-c"
                    | "test-net-1"
                    | "test-net-2"
                    | "test-net-3"
                    | "link-local"
                    | "multicast";
            }

        The optional options object.

        • { cidrBlock?: string }
          • OptionalcidrBlock?: string

            The optional CIDR block to use. Must be in the format x.x.x.x/y.

            '0.0.0.0/0'
            
        • {
              network?:
                  | "any"
                  | "loopback"
                  | "private-a"
                  | "private-b"
                  | "private-c"
                  | "test-net-1"
                  | "test-net-2"
                  | "test-net-3"
                  | "link-local"
                  | "multicast";
          }
          • Optionalnetwork?:
                | "any"
                | "loopback"
                | "private-a"
                | "private-b"
                | "private-c"
                | "test-net-1"
                | "test-net-2"
                | "test-net-3"
                | "link-local"
                | "multicast"

            The optional network to use. This is intended as an alias for well-known cidrBlocks.

            'any'
            

      Returns string

      faker.internet.ipv4() // '245.108.222.0'
      faker.internet.ipv4({ cidrBlock: '192.168.0.0/16' }) // '192.168.215.224'
      faker.internet.ipv4({ network: 'private-a' }) // '10.199.154.205'

      6.1.1

    • Generates a random IPv6 address.

      Returns string

      faker.internet.ipv6() // '269f:1230:73e3:318d:842b:daab:326d:897b'
      

      4.0.0

    • Generates a random JWT (JSON Web Token).

      Please note that this method generates a random signature instead of a valid one.

      Parameters

      • Optionaloptions: {
            header?: Record<string, unknown>;
            payload?: Record<string, unknown>;
            refDate?: string | number | Date;
        }

        The optional options object.

        • Optionalheader?: Record<string, unknown>

          The header to use for the token. If present, it will replace any default values.

          {
          * alg: faker.internet.jwtAlgorithm(),
          * typ: 'JWT'
          * }
        • Optionalpayload?: Record<string, unknown>

          The payload to use for the token. If present, it will replace any default values.

          {
          * iat: faker.date.recent(),
          * exp: faker.date.soon(),
          * nbf: faker.date.anytime(),
          * iss: faker.company.name(),
          * sub: faker.string.uuid(),
          * aud: faker.string.uuid(),
          * jti: faker.string.uuid()
          * }
        • OptionalrefDate?: string | number | Date

          The date to use as reference point for the newly generated date.

          faker.defaultRefDate()
          

      Returns string

      faker.internet.jwt() // 'eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MzI2MzgxMDYsImV4cCI6MTczMjY5MjUwOSwibmJmIjoxNzA1MDgxNjQ4LCJpc3MiOiJHdXRrb3dza2kgYW5kIFNvbnMiLCJzdWIiOiJlMzQxZjMwNS0yM2I2LTRkYmQtOTY2ZC1iNDRiZmM0ZGIzMGUiLCJhdWQiOiI0YzMwZGE3Yi0zZDUzLTQ4OGUtYTAyZC0zOWI2MDZiZmYxMTciLCJqdGkiOiJiMGZmOTMzOC04ODMwLTRmNDgtYjA3Ny1kNDNmMjU2OGZlYzAifQ.oDLVR73M0u5SjMPlc1aruxbdK7l2titXSeo9J5M1JUd65a1X9MhCz7FOobtX8eaj'
      faker.internet.jwt({ header: { alg: 'HS256' }}) // 'eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3MTg2MTM3MTIsImV4cCI6MTcxODYzMzY3OSwibmJmIjoxNjk3MjYzNjMwLCJpc3MiOiJEb3lsZSBhbmQgU29ucyIsInN1YiI6IjYxYWRkYWFmLWY4MjktNDkzZS1iNTI1LTJjMGJkNjkzOTdjNyIsImF1ZCI6IjczNjcyMjVjLWIwMWMtNGE1My1hYzQyLTYwOWJkZmI1MzBiOCIsImp0aSI6IjU2Y2ZkZjAxLWRhMzMtNGUxNi04MzJiLTFlYTk3ZGY1MTQ2YSJ9.5iUgaCaFVPZ8d1QD0xMjoeJbmPVyUfKfoRQ6Njzm5MLp5F4UMh5REbPCrW70fAkr'
      faker.internet.jwt({ payload: { iss: 'Acme' }}) // 'eyJhbGciOiJFUzM4NCIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJBY21lIn0.syUt0GBukNac8Cn1AGKFq2SWAXWy1YIfl0uOYiwg6TZ3omAW0c7FGWY6bC7ZOFSt'
      faker.internet.jwt({ refDate: '2020-01-01T00:00:00.000Z' }) // 'eyJhbGciOiJFUzM4NCIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1Nzc4MDY4NDUsImV4cCI6MTU3Nzg0NjI4MCwibmJmIjoxNTgxNTQyMDYwLCJpc3MiOiJLcmVpZ2VyLCBBbHRlbndlcnRoIGFuZCBQYXVjZWsiLCJzdWIiOiI5NzVjMjMyOS02MDlhLTRjYTYtYjBkZi05ZmY4MGZiNDUwN2QiLCJhdWQiOiI0ODQxZWYwNi01OWYwLTQzMWEtYmFmZi0xMjkxZmRhZDdhNjgiLCJqdGkiOiJmNDBjZTJiYi00ZWYyLTQ1MjMtOGIxMy1kN2Q4NTA5N2M2ZTUifQ.cuClEZQ0CyPIMVS5uxrMwWXz0wcqFFdt0oNne3PMryyly0jghkxVurss2TapMC3C'

      9.1.0

    • Generates a random JWT (JSON Web Token) Algorithm.

      Returns string

      faker.internet.jwt(): For generating random JWT (JSON Web Token).

      faker.internet.jwtAlgorithm() // 'HS256'
      faker.internet.jwtAlgorithm() // 'RS512'

      9.1.0

    • Generates a random mac address.

      Parameters

      • Optionaloptions: { separator?: string }

        An options object.

        • Optionalseparator?: string

          The optional separator to use. Can be either ':', '-' or ''.

          ':'
          

      Returns string

      faker.internet.mac() // '32:8e:2e:09:c6:05'
      

      3.0.0

    • Generates a random mac address.

      Parameters

      • Optionalseparator: string

        The optional separator to use. Can be either ':', '-' or ''. Defaults to ':'.

      Returns string

      faker.internet.mac() // '32:8e:2e:09:c6:05'
      

      3.0.0

    • Generates a random mac address.

      Parameters

      • Optionaloptions: string | { separator?: string }

        The optional separator or an options object.

        • string
        • { separator?: string }
          • Optionalseparator?: string

            The optional separator to use. Can be either ':', '-' or ''.

            ':'
            

      Returns string

      faker.internet.mac() // '32:8e:2e:09:c6:05'
      

      3.0.0

    • Generates a random password-like string. Do not use this method for generating actual passwords for users. Since the source of the randomness is not cryptographically secure, neither is this generator.

      Parameters

      • Optionaloptions: { length?: number; memorable?: boolean; pattern?: RegExp; prefix?: string }

        An options object.

        • Optionallength?: number

          The length of the password to generate.

          15
          
        • Optionalmemorable?: boolean

          Whether the generated password should be memorable.

          false
          
        • Optionalpattern?: RegExp

          The pattern that all chars should match. This option will be ignored, if memorable is true.

          /\w/
          
        • Optionalprefix?: string

          The prefix to use.

          ''
          

      Returns string

      faker.internet.password() // '89G1wJuBLbGziIs'
      faker.internet.password({ length: 20 }) // 'aF55c_8O9kZaPOrysFB_'
      faker.internet.password({ length: 20, memorable: true }) // 'lawetimufozujosodedi'
      faker.internet.password({ length: 20, memorable: true, pattern: /[A-Z]/ }) // 'HMAQDFFYLDDUTBKVNFVS'
      faker.internet.password({ length: 20, memorable: true, pattern: /[A-Z]/, prefix: 'Hello ' }) // 'Hello IREOXTDWPERQSB'

      2.0.1

    • Generates a random port number.

      Returns number

      faker.internet.port() // 9414
      

      5.4.0

    • Returns a random web protocol. Either http or https.

      Returns "http" | "https"

      faker.internet.protocol() // 'http'
      

      2.1.5

    • Generates a random http(s) url.

      Parameters

      • Optionaloptions: { appendSlash?: boolean; protocol?: HTTPProtocolType }

        Optional options object.

        • OptionalappendSlash?: boolean

          Whether to append a slash to the end of the url (path).

          faker.datatype.boolean()
          
        • Optionalprotocol?: HTTPProtocolType

          The protocol to use.

          'https'
          

      Returns string

      faker.internet.url() // 'https://remarkable-hackwork.info'
      faker.internet.url({ appendSlash: true }) // 'https://slow-timer.info/'
      faker.internet.url({ protocol: 'http', appendSlash: false }) // 'http://www.terrible-idea.com'

      2.1.5

    • Generates a random user agent string.

      Returns string

      faker.internet.userAgent()
      // 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_1 like Mac OS X) AppleWebKit/537.19.86 (KHTML, like Gecko) Version/18_3 Mobile/15E148 Safari/598.43'

      2.0.1

    • Generates a username using the given person's name as base. The resulting username may use neither, one or both of the names provided. This will always return a plain ASCII string. Some basic stripping of accents and transliteration of characters will be done.

      Parameters

      • Optionaloptions: { firstName?: string; lastName?: string }

        An options object.

        • OptionalfirstName?: string

          The optional first name to use.

          faker.person.firstName()
          
        • OptionallastName?: string

          The optional last name to use.

          faker.person.lastName()
          

      Returns string

      faker.internet.displayName(): For generating an Unicode display name.

      faker.internet.username() // 'Nettie_Zboncak40'
      faker.internet.username({ firstName: 'Jeanne' }) // 'Jeanne98'
      faker.internet.username({ firstName: 'Jeanne' }) // 'Jeanne.Smith98'
      faker.internet.username({ firstName: 'Jeanne', lastName: 'Doe'}) // 'Jeanne_Doe98'
      faker.internet.username({ firstName: 'John', lastName: 'Doe' }) // 'John.Doe'
      faker.internet.username({ firstName: 'Hélene', lastName: 'Müller' }) // 'Helene_Muller11'
      faker.internet.username({ firstName: 'Фёдор', lastName: 'Достоевский' }) // 'Fedor.Dostoevskii50'
      faker.internet.username({ firstName: '大羽', lastName: '陳' }) // 'hlzp8d.tpv45' - note neither name is used

      9.1.0

    • Generates a username using the given person's name as base. The resulting username may use neither, one or both of the names provided. This will always return a plain ASCII string. Some basic stripping of accents and transliteration of characters will be done.

      Parameters

      • Optionaloptions: { firstName?: string; lastName?: string }

        An options object.

        • OptionalfirstName?: string

          The optional first name to use.

          faker.person.firstName()
          
        • OptionallastName?: string

          The optional last name to use.

          faker.person.lastName()
          

      Returns string

      faker.internet.displayName(): For generating an Unicode display name.

      faker.internet.userName() // 'Nettie_Zboncak40'
      faker.internet.userName({ firstName: 'Jeanne' }) // 'Jeanne98'
      faker.internet.userName({ firstName: 'Jeanne' }) // 'Jeanne.Smith98'
      faker.internet.userName({ firstName: 'Jeanne', lastName: 'Doe'}) // 'Jeanne_Doe98'
      faker.internet.userName({ firstName: 'John', lastName: 'Doe' }) // 'John.Doe'
      faker.internet.userName({ firstName: 'Hélene', lastName: 'Müller' }) // 'Helene_Muller11'
      faker.internet.userName({ firstName: 'Фёдор', lastName: 'Достоевский' }) // 'Fedor.Dostoevskii50'
      faker.internet.userName({ firstName: '大羽', lastName: '陳' }) // 'hlzp8d.tpv45' - note neither name is used

      2.0.1

      Use faker.internet.username() instead.