Advanced uses for the getVar function

You've seen how the getVar function can be used to access parameters in your query URI, but the getVar function can also be used to access a few internal RandomAPI features. If you'd like a refresher on the getVar function, take a look here.

The getVar function can access variables such as fmt, key, ref, etc. as well if you need to determine the format your API was requested in, etc.

You can also access some internal RandomAPI Generator variables such as numericSeed which is the internal seed that the generator is using for the current job it is generating. This could be especially useful if you are using a custom snippet or global snippet that has a seeding property you'd like to set (which we recommend so that the generator's seed and snippet's seed match each other and respect any custom seed values you might provide in your URI).

Or if you need a number on the [0,1) real interval, you can use the special prng() function that will return a number directly from the Mersenne Twister module that the generator is using.

api.seed    = getVar('seed');  
api.numSeed = getVar('numericSeed');  
api.format  = getVar('fmt');  
api.key     = getVar('key');  
api.ref     = getVar('ref');  
api.prng    = prng();  
{
  "seed": "7583c1fdce1943f4",
  "numericSeed": 4200665598,
  "format": "pretty",
  "key": "ABCD-1234-EFGH-5678",
  "ref": "1234abcd",
  "prng": 0.9772644529584795
}