Sulu logo
Sulu
Docs

Technical Overview

The Random Number API hosted at https://rnd.ln.sulu.sh provides a simple and efficient way to retrieve random numbers. By making a GET request to the /randomnumber endpoint, users receive a JSON response containing a randomly generated number. This API is particularly useful for applications requiring random number generation, such as in gaming, simulations, or any scenario where unpredictability is key.

Host

https://rnd.ln.sulu.sh

Endpoints
  • GET /randomnumber
Price

During the development stage of the API, we are implementing a fixed price of 10 sats for unlimited access to the API designed for early testers. This will be updated once the API is completed.

Response Format

Returns a JSON object containing a random number.

Response Object
FieldData TypeDescription
numberdecimalRandom number
Sample JavaScript Code using Alby's fetchWithL402 Tool

To consume the Random Number API in a JavaScript application, you can use the fetchWithL402 function provided by Alby tools. This function simplifies the process of making authenticated requests to APIs that use the L402 authentication scheme. Below is a sample code snippet demonstrating how to make a request to the Random Number API:

Example
1// JavaScript code to fetch a random number using the Random Number API
2async function getRandomNumber() {
3    try {
4        const response = await fetchWithL402(
5          "https://rnd.ln.sulu.sh/randomnumber",
6          {},
7          { headerKey: "L402" });
8
9        if (response.ok) {
10            const data = await response.json();
11            console.log("Random Number:", data.number);
12            return data.number;
13        } else {
14            console.error("Failed to fetch random number:", response.status);
15        }
16    } catch (error) {
17        console.error("Error fetching random number:", error);
18    }
19}
20
21// Example usage
22getRandomNumber();

Copyright © 2024 Sulu