Fake.REST logo
Fake.REST
Topics
Getting started
Dynamic templating
Scripting

Random

Random namespace contains methods that generate random numbers, ids, etc.

Template definitions

{{random.uuid()}} - It generates a random UUID, e.g. "7d8jh38b-fde7-56ed-9f55-1866dbc6815f".


{{random.alphaNumeric(count)}} - It generates a random alphanumeric sequence.

params:

count - the length of the sequence that needs to generate.


{{random.boolean()}} - It generates a random boolean, true or false.


{{random.imageUrl()}} - It generates a random umage Url from lorem pixel.


{{random.locale()}} - It generates a random locale, e.g. "en".


{{random.words(count)}} - It generates a string with random words separated by space.

params:

count - the number of words that needs to generate. The number is limited to 1,000.


{{random.number(max | min, max)}} - It generates a random integer number.

params:

min - minimum value,
max - maximum value.


{{random.float(max | min, max, dec = 2)}} - It generates a random integer number.

params:

min - minimum value,
max - maximum value,
dec - decimal count, default set to 2.


The example of template usage:

{
  "theRandomExample": {
    "uuid": "{{random.uuid()}}",
    "alphaNumeric": "{{random.alphaNumeric(10)}}",
    "boolean": "{{random.boolean()}}",
    "imageUrl": "{{random.imageUrl()}}",
    "locale": "{{random.locale()}}",
    "number": "{{random.number(100, 100000)}}",
    "float": "{{random.float(100, 1000, 4)}}",
    "words": "{{random.words(10)}}"
  }
}