Apidog Docs
🇺🇸 English
  • 🇺🇸 English
  • 🇯🇵 日本語
HomeLearning CenterSupport CenterAPI References
HomeLearning CenterSupport CenterAPI References
Discord Community
Slack Community
X / Twitter
🇺🇸 English
  • 🇺🇸 English
  • 🇯🇵 日本語
  1. Learning Center
  • Back to home
  • Dynamic values Modules
  • Airline
  • Animal
  • Color
  • Commerce
  • Company
  • Database
  • Datatype
  • Date
  • Finance
  • Food
  • Git
  • Hacker
  • Helpers
  • Image
  • Internet
  • Location
  • Lorem
  • Music
  • Number
  • Person
  • Phone
  • Science
  • String
  • System
  • Vehicle
  • Word
  1. Learning Center

Location

Module to generate addresses and locations.
Overview
For a typical street address for a locale, use {{$location.streetAddress}}, {{$location.city}}, {{$location.state}}, and {{$location.zipCode}}. Most locales provide localized versions for a specific country.
If you need latitude and longitude coordinates, use {{$location.latitude}} and {{$location.longitude}}, or {{$location.nearbyGPSCoordinateLatitude}} for a latitude/longitude near a given location.
For a random country, you can use {{$location.country}} or {{$location.countryCode}}.

buildingNumber#

Generates a random building number.
Returns: string
Examples

cardinalDirection#

Returns a random cardinal direction.
Parameters
NameTypeDefaultDescription
abbreviatedbooleanfalseIf true this will return abbreviated directions (N, E, etc). Otherwise this will return the long name.
Returns: string
Examples

city#

Generates a random localized city name.
Returns: string
Examples

country#

Returns a random country name.
Returns: string
Examples

countryCode#

Returns a random country name.
Parameters
NameTypeDefaultDescription
variant'alpha-2' |'alpha-3' | 'numeric''alpha-2'The code to return. Can be either 'alpha-2' (two-letter code), 'alpha-3' (three-letter code) or 'numeric' (numeric code).
Returns: string
Examples

direction#

Returns a random direction .
Parameters
NameTypeDefaultDescription
abbreviatedbooleanfalseIf true this will return abbreviated directions (NW, E, etc). Otherwise this will return the long name.
Returns: string
Examples

latitude#

Generates a random latitude.
Parameters
NameTypeDefaultDescription
maxnumber90The upper bound for the latitude to generate.
minnumber-90The lower bound for the latitude to generate.
precisionnumber4The number of decimal points of precision for the latitude.
Returns: number
Examples

longitude#

Generates a random longitude.
Parameters
NameTypeDefaultDescription
maxnumber90The upper bound for the longitude to generate.
minnumber-90The lower bound for the longitude to generate.
precisionnumber4The number of decimal points of precision for the longitude.
Returns: number
Examples

nearbyGPSCoordinate#

Generates a random GPS coordinate within the specified radius from the given coordinate.
The original faker.location.nearbyGPSCoordinate() method has been refined into two more precise variables:
{{$location.nearbyGPSCoordinateLatitude}}: Generates an Latitude within the specified radius from the given coordinate.
{{$location.nearbyGPSCoordinateLongitude}}: Generates an Longitude within the specified radius from the given coordinate.
Parameters
NameTypeDefaultDescription
isMetricbooleanfalseIf true assume the radius to be in kilometers. If false for miles.
latitudenumberThe original latitude to get a new coordinate close to.
longitudenumberThe original longitude to get a new coordinate close to.
radiusnumber10The maximum distance from the given coordinate to the new coordinate.
Returns: [latitude: number, longitude: number]
Examples

ordinalDirection#

Returns a random ordinal direction (northwest, southeast, etc).
Parameters
NameTypeDefaultDescription
abbreviatedbooleanfalseIf true this will return abbreviated directions (NW, SE, etc). Otherwise this will return the long name.
Returns: string
Examples

secondaryAddress#

Generates a random localized secondary address. This refers to a specific location at a given address such as an apartment or room number.
Returns: string
Examples

state#

Returns a random localized state, or other equivalent first-level administrative entity for the locale's country such as a province or region. Generally, these are the ISO 3166-2 subdivisions for a country. If a locale doesn't correspond to one specific country, the method may return ISO 3166-2 subdivisions from one or more countries that uses that language. For example, the ar locale includes subdivisions from Arabic-speaking countries, such as Tunisia, Algeria, Syria, Lebanon, etc. For historical compatibility reasons, the default en locale only includes states in the United States (identical to en_US). However, you can use other English locales, such as en_IN, en_GB, and en_AU, if needed.
Parameters
NameTypeDefaultDescription
abbreviatedbooleanfalseIf true this will return abbreviated first-level administrative entity names. Otherwise this will return the long name.
Returns: string
Examples

street#

Generates a random localized street name.
Returns: string
Examples

streetAddress#

Generates a random localized street address.
Parameters
NameTypeDefaultDescription
useFullAddressbooleanWhen true this will generate a full address. Otherwise it will just generate a street address.
Returns: string
Examples

timeZone#

Returns a random IANA time zone relevant to this locale.
The returned time zone is tied to the current locale.
Returns: string
Examples

zipCode#

Generates random zip code from specified format. If format is not specified, the locale's zip format is used.
Parameters
NameTypeDefaultDescription
formatstringWThe optional format used to generate the zip code. This won't be used if the state option is specified.
Returns: string
Examples

Previous
Internet
Next
Lorem
Built with