Internet
Module to generate internet related entries.
- Avatar
- Color
- Domain Name
- Domain Suffix
- Domain Word
- Emoji
- Example Email
- Http Method
- Ip
- Ipv4
- Ipv6
- Mac
- Password
- Port
- Protocol
- Url
- User Agent
- User Name
Avatar
Returns a random avatar url.
Returns: string
faker.internet.avatar(): string
faker.internet.avatar() // => "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHir...
faker.internet.avatar()
// 'https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/315.jpg'
Color
Generates a random css hex color code in aesthetically pleasing color palette.
Parameters
Name | Type | Default | Description |
---|---|---|---|
redBase | number | 0 | The optional base red in range between |
greenBase | number | 0 | The optional base green in range between |
blueBase | number | 0 | The optional base blue in range between |
Returns: string
faker.internet.color(redBase: number = 0, greenBase: number = 0, blueBase: number = 0): string
faker.internet.color() // => "#464c5b"
faker.internet.color() // '#30686e'
faker.internet.color(100, 100, 100) // '#4e5f8b'
Domain Name
Generates a random domain name.
Returns: string
faker.internet.domainName(): string
faker.internet.domainName() // => "muddy-neuropathologist.net"
faker.internet.domainName() // 'slow-timer.info'
Domain Suffix
Returns a random domain suffix.
Returns: string
faker.internet.domainSuffix(): string
faker.internet.domainSuffix() // => "name"
faker.internet.domainSuffix() // 'com'
faker.internet.domainSuffix() // 'name'
Domain Word
Generates a random domain word.
Returns: string
faker.internet.domainWord(): string
faker.internet.domainWord() // => "muddy-neuropathologist"
faker.internet.domainWord() // 'close-reality'
faker.internet.domainWord() // 'weird-cytoplasm'
Generates an email address using the given person's name as base.
Parameters
Name | Type | Default | Description |
---|---|---|---|
firstName? | string | The optional first name to use. If not specified, a random one will be chosen. | |
lastName? | string | The optional last name to use. If not specified, a random one will be chosen. | |
provider? | string | The mail provider domain to use. If not specified, a random free mail provider will be chosen. | |
options? | { ... } | { allowSpecialCharacters: false } | The options to use. |
options.allowSpecialCharacters? | boolean | false | Whether special characters such as |
Returns: string
faker.internet.email(firstName?: string, lastName?: string, provider?: string, options?: {
allowSpecialCharacters: boolean
} = { allowSpecialCharacters: false }): string
faker.internet.email() // => "Larry_Ratke85@yahoo.com"
faker.internet.email() // 'Kassandra4@hotmail.com'
faker.internet.email('Jeanne', 'Doe') // 'Jeanne63@yahoo.com'
faker.internet.email('Jeanne', 'Doe', 'example.fakerjs.dev') // 'Jeanne_Doe88@example.fakerjs.dev'
faker.internet.email('Jeanne', 'Doe', 'example.fakerjs.dev', { allowSpecialCharacters: true }) // 'Jeanne%Doe88@example.fakerjs.dev'
Emoji
Generates a random emoji.
Parameters
Name | Type | Default | Description |
---|---|---|---|
options | { ... } | {} | Options object. |
options.types? | readonly EmojiType[] | A list of the emoji types that should be used. |
Returns: string
faker.internet.emoji(options: {
types: readonly EmojiType[]
} = {}): string
faker.internet.emoji() // => "💺"
faker.internet.emoji() // '🥰'
faker.internet.emoji({ types: ['food', 'nature'] }) // '🥐'
Example Email
Generates an email address using an example mail provider using the given person's name as base.
Parameters
Name | Type | Default | Description |
---|---|---|---|
firstName? | string | The optional first name to use. If not specified, a random one will be chosen. | |
lastName? | string | The optional last name to use. If not specified, a random one will be chosen. | |
options? | { ... } | { allowSpecialCharacters: false } | The options to use. |
options.allowSpecialCharacters? | boolean | false | Whether special characters such as |
Returns: string
faker.internet.exampleEmail(firstName?: string, lastName?: string, options?: {
allowSpecialCharacters: boolean
} = { allowSpecialCharacters: false }): string
faker.internet.exampleEmail() // => "Larry_Ratke85@example.com"
faker.internet.exampleEmail() // 'Helmer.Graham23@example.com'
faker.internet.exampleEmail('Jeanne', 'Doe') // 'Jeanne96@example.net'
faker.internet.exampleEmail('Jeanne', 'Doe', { allowSpecialCharacters: true }) // 'Jeanne%Doe88@example.com'
Http Method
Returns a random http method.
Can be either of the following:
GET
POST
PUT
DELETE
PATCH
Returns: 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT'
faker.internet.httpMethod(): "GET" | "POST" | "PUT" | "DELETE" | "PATCH"
faker.internet.httpMethod() // => "PUT"
faker.internet.httpMethod() // 'PATCH'
Ip
Generates a random IPv4 address.
Returns: string
faker.internet.ip(): string
faker.internet.ip() // => "140.151.183.216"
faker.internet.ip() // '245.108.222.0'
Ipv4
Generates a random IPv4 address.
Returns: string
faker.internet.ipv4(): string
faker.internet.ipv4() // => "140.151.183.216"
faker.internet.ipv4() // '245.108.222.0'
Ipv6
Generates a random IPv6 address.
Returns: string
faker.internet.ipv6(): string
faker.internet.ipv6() // => "89bd:9d8d:69a6:74e0:f467:cc87:96ed:151a"
faker.internet.ipv6() // '269f:1230:73e3:318d:842b:daab:326d:897b'
Mac
Generates a random mac address.
Parameters
Name | Type | Default | Description |
---|---|---|---|
sep? | string | ':' | The optional separator to use. Can be either |
Returns: string
faker.internet.mac(sep?: string = ':'): string
faker.internet.mac() // => "89:bd:9d:8d:69:a6"
faker.internet.mac() // '32:8e:2e:09:c6:05'
Password
Generates a random password.
Parameters
Name | Type | Default | Description |
---|---|---|---|
len | number | 15 | The length of the password to generate. |
memorable | boolean | false | Whether the generated password should be memorable. |
pattern | RegExp | /\w/ | The pattern that all chars should match should match.
This option will be ignored, if |
prefix | string | '' | The prefix to use. |
Returns: string
faker.internet.password(len: number = 15, memorable: boolean = false, pattern: RegExp = /\w/, prefix: string = ''): string
faker.internet.password() // => "UYdqZrTqIEJuENl"
faker.internet.password() // '89G1wJuBLbGziIs'
faker.internet.password(20) // 'aF55c_8O9kZaPOrysFB_'
faker.internet.password(20, true) // 'lawetimufozujosodedi'
faker.internet.password(20, true, /[A-Z]/) // 'HMAQDFFYLDDUTBKVNFVS'
faker.internet.password(20, true, /[A-Z]/, 'Hello ') // 'Hello IREOXTDWPERQSB'
Port
Generates a random port number.
Returns: number
faker.internet.port(): number
faker.internet.port() // => 35967
faker.internet.port() // '9414'
Protocol
Returns a random web protocol. Either http
or https
.
Returns: 'http' | 'https'
faker.internet.protocol(): "http" | "https"
faker.internet.protocol() // => "https"
faker.internet.protocol() // 'http'
faker.internet.protocol() // 'https'
Url
Generates a random url.
Returns: string
faker.internet.url(): string
faker.internet.url() // => "https://optimistic-rabbi.org"
faker.internet.url() // 'https://remarkable-hackwork.info'
User Agent
Generates a random user agent string.
Returns: string
faker.internet.userAgent(): string
faker.internet.userAgent() // => "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT ...
faker.internet.userAgent()
// 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_8_8) AppleWebKit/536.0.2 (KHTML, like Gecko) Chrome/27.0.849.0 Safari/536.0.2'
User Name
Generates a username using the given person's name as base.
Parameters
Name | Type | Default | Description |
---|---|---|---|
firstName? | string | The optional first name to use. If not specified, a random one will be chosen. | |
lastName? | string | The optional last name to use. If not specified, a random one will be chosen. |
Returns: string
faker.internet.userName(firstName?: string, lastName?: string): string
faker.internet.userName() // => "Katelynn_Medhurst60"
faker.internet.userName() // 'Nettie_Zboncak40'
faker.internet.userName('Jeanne', 'Doe') // 'Jeanne98'