You can use the API to generate a random number at any time by simply making a request.

There are some additional arguments you can send including specifying a minimum and maximum number range and what type of algorithm to use.

How to Generate a Random Number

Simply GET this URL

https://gamipixel.com/api/v1/gami-random-number

You should send your api_key and authentication_key as POST$.

If you just get the URL, then a random number between 0 and 9223372036854775807 will be delivered to you.

Specify a Random Number Range

You can send additional arguments to the API to specify a range. For example, you could specify a minimum range, like this

min=-50
max=55

This would give a random result between -50 and 55.

The minimum value you can send is -9223372036854775807 and the maximum value you can send is 9223372036854775807. If your values exceed these, it will result in an error.

Random Number Response

Depending on what response method you use, it will either return JSON like this:

{
    "random_number": 123456789
}

or delimited like this:

random_number:123456789

Code Examples

Here are some code examples for you.

Javascript (Fetch)

fetch('https://gamipixel.com/api/v1/gami-random-number', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
    },
    body: new URLSearchParams({
        'api_key': 'your_api_key_here',
        'authentication_key': 'your_authentication_key_here',
        'min': '-1000',
        'max': '1000'
    })
})
.then(response => response.json())
.then(data => console.log(data));

Python (requests)

import requests

url = "https://gamipixel.com/api/v1/gami-random-number"
payload = {
    'api_key': 'your_api_key_here',
    'authentication_key': 'your_authentication_key_here',
    'min': '-1000',
    'max': '1000'
}
response = requests.post(url, data=payload)
print(response.json())

C# (Unity)

using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        using (var client = new HttpClient())
        {
            var values = new Dictionary<string, string>
            {
                { "api_key", "your_api_key" },
                { "authentication_key", "your_authentication_key" },
                { "min", "-1000" },
                { "max", "1000" },
                { "delimited", "no" }
            };

            var content = new FormUrlEncodedContent(values);

            var response = await client.PostAsync("https://gamipixel.com/api/v1/gami-random-number", content);

            var responseString = await response.Content.ReadAsStringAsync();

            Console.WriteLine(responseString);
        }
    }
}

C++ (Unreal Engine)

#include <iostream>
#include <curl/curl.h>

static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp)
{
    ((std::string*)userp)->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main()
{
    CURL* curl;
    CURLcode res;
    std::string readBuffer;

    curl = curl_easy_init();
    if(curl) {
        curl_easy_setopt(curl, CURLOPT_URL, "https://gamipixel.com/api/v1/gami-random-number");

        // Post fields
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "api_key=your_api_key&authentication_key=your_authentication_key&min=-1000&max=1000&delimited=no");

        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);

        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);

        std::cout << readBuffer << std::endl;
    }
    return 0;
}

Visual Basic

Imports System
Imports System.Net.Http
Imports System.Collections.Generic

Module Program
    Sub Main(args As String())
        RunAsync().GetAwaiter().GetResult()
    End Sub

    Async Function RunAsync() As Task
        Using client As New HttpClient()
            Dim values As New Dictionary(Of String, String) From {
                {"api_key", "your_api_key"},
                {"authentication_key", "your_authentication_key"},
                {"min", "-1000"},
                {"max", "1000"},
                {"delimited", "no"}
            }

            Dim content As New FormUrlEncodedContent(values)

            Dim response As HttpResponseMessage = Await client.PostAsync("https://gamipixel.com/api/v1/gami-random-number", content)

            Dim responseString As String = Await response.Content.ReadAsStringAsync()

            Console.WriteLine(responseString)
        End Using
    End Function
End Module