In what follows I will present two methods for obtaining random numbers inside a Yahoo Pipes setup. The first method is based on obtaining the current timestamp and using it your random number. The advantage of this method is that it is quick (you don’t need to access third-party websites). This disadvantage is that it’s not that random – somebody reading your feed can figure out the algorithm and possibly predict future values. If this a problem for you, take a look at the second method.
The flow is as follows:
- from the first element you get the date/time at the time of the feed “evaluation” (this might differ from the time the feed is fetched)
- the second step is to format it as a timestamp (number of seconds since 00:00:00 UTC on January 1, 1970), which also has the side-effect of creating a single number
- the third step is to normalize it. Taking modulo 100 means that the number will always be between 0 and 99. If you need an interval not starting at 0, just add an other steps which “shifts” the lower end of it (for example: if you need numbers between –150 and –100, you would implement the following expression: –150 + (timestamp % 50))
Now for the second version: this is based on the random.org REST API. Simply fetch the URL which outputs the random numbers as a CSV file:
The advantage of this method is that it is fairly easy to obtain high-quality random numbers in large quantities. The disadvantage is that they might ban Yahoo pipes at one moment if too many people start using the service (since they state on their site that: “If you access RANDOM.ORG via an automated client, please make sure you observe the Guidelines for Automated Clients or your computer may be banned.” – and you have little control over the method the Pipes backend uses to fetch the data)