Skip to main content

location Domain

The location domain maps domain keywords to underlying faker implementations.

Faker Documentation

Methods

location.buildingNumber

Generates a random building number.

No parameters.

Examples:

location.buildingNumber()

Example return values:

  • 5075

location.cardinalDirection

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

No parameters.

Examples:

location.cardinalDirection()

Example return values:

  • East

location.city

Generates a random localized city name.

No parameters.

Examples:

location.city()

Example return values:

  • Stellachester

location.continent

Returns a random continent name.

No parameters.

Examples:

location.continent()

Example return values:

  • Asia

location.country

Returns a random country name.

No parameters.

Examples:

location.country()

Example return values:

  • Svalbard & Jan Mayen Islands

location.countryCode

Returns a random ISO_3166-1 country code.

No parameters.

Examples:

location.countryCode()

Example return values:

  • MG

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:

location.county()

Example return values:

  • Northamptonshire

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:

location.direction()
location.direction(abbreviated=false)

Example return values:

  • North

location.language

Returns a random spoken language.

No parameters.

Examples:

location.language()

Example return values:

  • {"name":"Icelandic","alpha2":"is","alpha3":"isl"}

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:

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

Example return values:

  • 51.5448

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:

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

Example return values:

  • 92.3892

location.nearbyGPSCoordinate

Generates a random GPS coordinate within the specified radius from the given coordinate.

No parameters.

Examples:

location.nearbyGPSCoordinate()

Example return values:

  • [58.313,9.9746]

location.ordinalDirection

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

No parameters.

Examples:

location.ordinalDirection()

Example return values:

  • Northeast

location.secondaryAddress

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

No parameters.

Examples:

location.secondaryAddress()

Example return values:

  • Suite 634

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:

location.state()
location.state(abbreviated=false)

Example return values:

  • Hawaii

location.street

Generates a random localized street name.

No parameters.

Examples:

location.street()

Example return values:

  • Viva Harbor

location.streetAddress

Generates a random localized street address.

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

Examples:

location.streetAddress()
location.streetAddress(useFullAddress=true)

Example return values:

  • 12056 Vandervort Common

location.timeZone

Returns a random IANA time zone name.

No parameters.

Examples:

location.timeZone()

Example return values:

  • Australia/Perth

location.zipCode

Generates data using faker location zip code.

No parameters.

Examples:

location.zipCode()

Example return values:

  • 36791