Skip to content

Repository files navigation

Randomorg

Golang Random.org API Client

GoDoc

A client for the Random.org JSON-RPC API, which serves true random numbers generated from atmospheric noise. An API key is required and can be acquired at https://api.random.org/dashboard.

Install

go get github.com/sgade/randomorg

Usage

package main

import (
	"context"
	"fmt"
	"log"
	"net/http"

	"github.com/sgade/randomorg"
)

func main() {
	random, err := randomorg.NewRandom("YOUR API KEY", &http.Client{})
	if err != nil {
		log.Fatal(err)
	}

	values, err := random.GenerateIntegers(context.Background(), 1, 0, 10)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(values)
}

See the GoDoc for the full API, or example_test.go for more runnable examples.

Basic vs. Signed API

This client implements both halves of the Random.org Core API:

  • The Basic API (GenerateIntegers, GenerateIntegerSequences, GenerateDecimalFractions, GenerateGaussians, GenerateStrings, GenerateUUIDs, GenerateBlobs) is the simplest way to fetch true random values.
  • The Signed API (GenerateSignedIntegers and friends, plus GetResult and VerifySignature) additionally returns a cryptographic signature proving the values came from RANDOM.ORG, along with support for tickets (CreateTickets, RevealTickets, ListTickets, GetTicket) that let a third party audit individual values without exposing your API key.

Optional parameters for every method (e.g. replacement, pregeneratedRandomization, and — for the Signed API — licenseData/userData/ticketId) are passed as a trailing, optional MethodOptions struct, so existing calls keep compiling unchanged when upgrading.

About

Golang Random.org API Client

Topics

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages