Skip to main content

location Domain

The location domain maps domain keywords to underlying faker implementations.

Faker Documentation

Methods

language.alpha2

Returns a random ISO 639-1 language code.

No parameters.

Examples:

Shows the default location.language.alpha2 call.

language.alpha2

Returns: pa

language.alpha3

Returns a random ISO 639-2 or ISO 639-3 language code.

No parameters.

Examples:

Shows the default location.language.alpha3 call.

language.alpha3

Returns: pan

language.name

Returns a random spoken language name.

No parameters.

Examples:

Shows the default location.language.name call.

language.name

Returns: Punjabi

location.buildingNumber

Generates a random building number.

No parameters.

Examples:

Shows the default location.buildingNumber call.

location.buildingNumber

Returns: 7031

location.cardinalDirection

Returns a random cardinal direction (north, east, south, west).

ArgTypeRequiredDescription
abbreviatedbooleannoIf true this will return abbreviated cardinal directions (N, E, S, W). Otherwise this will return the long name.

Examples:

Shows location.cardinalDirection when optional params are omitted.

location.cardinalDirection()

Returns: East

Shows location.cardinalDirection using abbreviated.

location.cardinalDirection(abbreviated=true)

Returns: E

location.city

Generates a random localized city name.

No parameters.

Examples:

Shows the default location.city call.

location.city

Returns: Edwinville

location.continent

Returns a random continent name.

No parameters.

Examples:

Shows the default location.continent call.

location.continent

Returns: Asia

location.country

Returns a random country name.

No parameters.

Examples:

Shows the default location.country call.

location.country

Returns: India

location.countryCode

Returns a random ISO_3166-1 country code.

ArgTypeRequiredDescription
variantalpha-2|alpha-3|numericnoThe code to return. Can be either 'alpha-2' (two-letter code), 'alpha-3' (three-letter code) or 'numeric' (numeric code).

Examples:

Shows location.countryCode when optional params are omitted.

location.countryCode()

Returns: IM

Shows location.countryCode using variant.

location.countryCode(variant="alpha-3")

Returns: IMN

location.county

Returns a random localized county, or other equivalent second-level administrative entity for the locale's country such as a district or department.

No parameters.

Examples:

Shows the default location.county call.

location.county

Returns: Cleveland

location.direction

Returns a random direction (cardinal and ordinal; northwest, east, etc).

ArgTypeRequiredDescription
abbreviatedbooleannoIf true this will return abbreviated directions (NW, E, etc). Otherwise this will return the long name.

Examples:

Shows location.direction when optional params are omitted.

location.direction()

Returns: West

Shows location.direction using abbreviated.

location.direction(abbreviated=true)

Returns: W

location.latitude

Generates a random latitude.

ArgTypeRequiredDescription
minnumbernoThe lower bound for the latitude to generate.
maxnumbernoThe upper bound for the latitude to generate.
precisionnumbernoThe number of decimal points of precision for the latitude.

Examples:

Shows location.latitude when optional params are omitted.

location.latitude()

Returns: -14.936

Shows location.latitude using min.

location.latitude(max=10, min=1)

Returns: 4.7532

Shows location.latitude using max.

location.latitude(max=5)

Returns: -50.3829

Shows location.latitude using precision.

location.latitude(precision=1)

Returns: -14.9

location.longitude

Generates a random longitude.

ArgTypeRequiredDescription
minnumbernoThe lower bound for the longitude to generate.
maxnumbernoThe upper bound for the longitude to generate.
precisionnumbernoThe number of decimal points of precision for the longitude.

Examples:

Shows location.longitude when optional params are omitted.

location.longitude()

Returns: -29.8721

Shows location.longitude using min.

location.longitude(max=10, min=1)

Returns: 4.7532

Shows location.longitude using max.

location.longitude(max=5)

Returns: -102.8509

Shows location.longitude using precision.

location.longitude(precision=1)

Returns: -29.9

location.ordinalDirection

Returns a random ordinal direction (northwest, southeast, etc).

ArgTypeRequiredDescription
abbreviatedbooleannoIf true this will return abbreviated ordinal directions (NW, SE, etc). Otherwise this will return the long name.

Examples:

Shows location.ordinalDirection when optional params are omitted.

location.ordinalDirection()

Returns: Northwest

Shows location.ordinalDirection using abbreviated.

location.ordinalDirection(abbreviated=true)

Returns: NW

location.secondaryAddress

Generates a random localized secondary address. This refers to a specific location at a given address

No parameters.

Examples:

Shows the default location.secondaryAddress call.

location.secondaryAddress

Returns: Apt. 703

location.state

Returns a random localized state, or other equivalent first-level administrative entity for the locale's country such as a province or region.

ArgTypeRequiredDescription
abbreviatedbooleannoIf true this will return abbreviated first-level administrative entity names. Otherwise this will return the long name.

Examples:

Shows location.state when optional params are omitted.

location.state()

Returns: Massachusetts

Shows location.state using abbreviated.

location.state(abbreviated=true)

Returns: MA

location.street

Generates a random localized street name.

No parameters.

Examples:

Shows the default location.street call.

location.street

Returns: Gutmann Creek

location.streetAddress

Generates a random localized street address.

ArgTypeRequiredDescription
useFullAddressbooleannoWhether to expand to a full address including secondary address information.

Examples:

Shows location.streetAddress when optional params are omitted.

location.streetAddress()

Returns: 7031 Iris Mill

Shows location.streetAddress using useFullAddress.

location.streetAddress(useFullAddress=true)

Returns: 7031 Iris Mill Apt. 728

location.timeZone

Returns a random IANA time zone name.

No parameters.

Examples:

Shows the default location.timeZone call.

location.timeZone

Returns: America/Santiago

location.zipCode

Generates data using faker location zip code.

ArgTypeRequiredDescription
statestringnoState abbreviation used to constrain the generated zip code where supported by the locale.
formatstringnoFormat pattern used for the generated zip code.

Examples:

Shows the default location.zipCode call.

location.zipCode()

Returns: 70310

Shows location.zipCode using a format option.

location.zipCode(format="#####")

Returns: 47031