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:

  • "5098"
  • "8232"

location.cardinalDirection

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

No parameters.

Examples:

location.cardinalDirection()

Example return values:

  • "West"

location.city

Generates a random localized city name.

No parameters.

Examples:

location.city()

Example return values:

  • "Neldachester"
  • "East Libbychester"

location.continent

Returns a random continent name.

No parameters.

Examples:

location.continent()

Example return values:

  • "Antarctica"
  • "Asia"

location.country

Returns a random country name.

No parameters.

Examples:

location.country()

Example return values:

  • "Indonesia"
  • "Iraq"

location.countryCode

Returns a random ISO_3166-1 country code.

No parameters.

Examples:

location.countryCode()

Example return values:

  • "PE"
  • "KI"

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:

  • "Rutland"
  • "Washington County"

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:

  • "East"
  • "North"

location.language

Returns a random spoken language.

No parameters.

Examples:

location.language()

Example return values:

  • {"name":"Tagalog","alpha2":"tl","alpha3":"tgl"}
  • {"name":"Azerbaijani","alpha2":"az","alpha3":"aze"}

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:

  • 38.5893
  • 57.5593

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:

  • -174.1417
  • 100.7973

location.nearbyGPSCoordinate

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

No parameters.

Examples:

location.nearbyGPSCoordinate()

Example return values:

  • [-5.738,-37.5877]
  • [30.3643,59.1147]

location.ordinalDirection

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

No parameters.

Examples:

location.ordinalDirection()

Example return values:

  • "Southwest"
  • "Southeast"

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 588"
  • "Apt. 105"

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:

  • "New Hampshire"
  • "Louisiana"

location.street

Generates a random localized street name.

No parameters.

Examples:

location.street()

Example return values:

  • "Kemmer Forges"
  • "Labadie Extension"

location.streetAddress

Generates a random localized street address.

ArgTypeRequiredDescription
useFullAddressbooleannoWhen true, generates a fuller address variant (for example including additional address detail). When false or omitted, generates a standard street address.

Examples:

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

Example return values:

  • "24973 Steuber Skyway"
  • "555 Kali Summit"

location.timeZone

Returns a random IANA time zone name.

No parameters.

Examples:

location.timeZone()

Example return values:

  • "America/Anchorage"
  • "Asia/Pyongyang"

location.zipCode

Generates data using faker location zip code.

No parameters.

Examples:

location.zipCode()

Example return values:

  • "24867"
  • "55040-0535"