:)
-k

API

https://the-sauna.icu/prandom/?api=
________________________


Valid endpoints:

  • nochars - returns a random digits only RUD *
  • coin - returns a coinflip result *
  • info - returns info about a request *
  • poem - returns a random ""poem"" (64 words) '
  • color - returns a random color (hex(default), &rgba, &hsla) *
  • wallpaper - returns a random wallpaper

  • * Means that endpoint has &json as an option


Ratelimiting

If you get ratelimited you'll get a response akin to this;

                    
                            {
                            "ratelimited": true,
                            "left": 12,
                            "ip": "1.2.3.4"
                            }
                    
                

Examples;


PHP
    
         = curl_init();
        curl_setopt(, CURLOPT_URL, "https://the-sauna.icu/prandom/?api=nochars");
        curl_setopt(, CURLOPT_RETURNTRANSFER, 1);
         = curl_exec();
        curl_close();
        echo ;
    
Python

        import requests
        r = requests.get("https://the-sauna.icu/prandom/?api=coin")
        print(r.text)
    
Powershell
    
        Invoke-WebRequest -Uri "https://the-sauna.icu/prandom/?api"
    
Bash (CURL, JQ)
        
        curl -s "https://the-sauna.icu/prandom/?api=info&json" | jq
    
C++
    
        /* bad c++ below */
        #include <iostream>
        #include <curl/curl.h>
        int main() {
            CURL *curl;
            CURLcode res;
            curl = curl_easy_init();
            if(curl) {
                curl_easy_setopt(curl, CURLOPT_URL, "https://the-sauna.icu/prandom/?api=nochars");
                res = curl_easy_perform(curl);
                curl_easy_cleanup(curl);
            }
            std::cout << res << std::endl;
            return 0;
        }
    
C#
    
        using System;
        using System.Net;
        using System.IO;
        namespace RudApp0
        {
            class Program
            {
                static void Main(string[] args)
                {
                    string url = "https://the-sauna.icu/prandom/?api=nochars";
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                    Stream resStream = response.GetResponseStream();
                    StreamReader reader = new StreamReader(resStream);
                    string responseFromServer = reader.ReadToEnd();
                    Console.WriteLine(responseFromServer);
                }
            }
        }
    
Go
    
        // there is also a GO version of the "algorithm" availbe at https://the-sauna.icu/prandom/rud.go 
        package main
        import (
            "fmt"
            "io/ioutil"
            "net/http"
        )
        func main() {
            resp, err := http.Get("https://the-sauna.icu/prandom/?api=nochars")
            if err != nil {
                panic(err)
            }
            defer resp.Body.Close()
            body, err := ioutil.ReadAll(resp.Body)
            if err != nil {
                panic(err)
            }
            fmt.Println(string(body))
        }
    
Ruby
    
        require 'net/http'
        require 'uri'
        url = URI.parse("https://the-sauna.icu/prandom/?api=nochars")
        req = Net::HTTP::Get.new(url.to_s)
        res = Net::HTTP.start(url.host, url.port, :use_ssl => url.scheme == 'https') {|http|
            http.request(req)
        }
        puts res.body
    
Java
    
        import java.io.BufferedReader;
        import java.io.InputStreamReader;
        import java.net.HttpURLConnection;
        import java.net.URL;
        public class Main {
            public static void main(String[] args) throws Exception {
                URL url = new URL("https://the-sauna.icu/prandom/?api=nochars");
                HttpURLConnection con = (HttpURLConnection) url.openConnection();
                con.setRequestMethod("GET");
                BufferedReader in = new BufferedReader(
                        new InputStreamReader(con.getInputStream()));
                String inputLine;
                StringBuffer content = new StringBuffer();
                while ((inputLine = in.readLine()) != null) {
                    content.append(inputLine);
                }
                in.close();
                con.disconnect();
                System.out.println(content.toString());
            }
        }
    
Node.js
    
        const https = require('https');
        https.get('https://the-sauna.icu/prandom/?api=nochars', (resp) => {
            let data = '';
            resp.on('data', (chunk) => {
                data += chunk;
            });
            resp.on('end', () => {
                console.log(JSON.parse(data));
            });
        }).on("error", (err) => {
            console.log("Error: " + err.message);
        });
    
GraphQL
    
        query {
            coinflip
        }
    

"Security"

Obviously this is a bad source of randomness, and you should not use this for anything that requires anything cryptographically secure (passwords, etc).

Why?

Wanted to get something that'd be standardized (cough) and CURL-able.

There is no reason to use this over your own implementation of course, but it's a nice larp :)


timestamp: Sun, 11 Jun 2023 00:27:12 +0000 [59899707256709]
page generated in 15.541076660156 ms
total api requests: 33894