RandomOrg.CoreApi 1.0.1

.NET 5.0 .NET Standard 2.0
Install-Package RandomOrg.CoreApi -Version 1.0.1
dotnet add package RandomOrg.CoreApi --version 1.0.1
<PackageReference Include="RandomOrg.CoreApi" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RandomOrg.CoreApi --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RandomOrg.CoreApi, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install RandomOrg.CoreApi as a Cake Addin
#addin nuget:?package=RandomOrg.CoreApi&version=1.0.1

// Install RandomOrg.CoreApi as a Cake Tool
#tool nuget:?package=RandomOrg.CoreApi&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

This is the official .NET implementation of the RANDOM.ORG JSON-RPC API (Release 4), which supports .NET Standard 2.0+, .NET Core 2.0+, .NET 5 and .NET Framework 4.6.1+.

It provides either serialized or unserialized access to both the signed and unsigned methods of the API through the RandomOrgClient class. It also provides a convenience class through the RandomOrgClient class, the RandomOrgCache, for precaching requests. In the context of this module, a serialized client is one for which the sequence of requests matches the sequence of responses.


The library requires the Newtonsoft.Json package for normal operation.


This library is comprised of the RandomOrg.CoreApi and RandomOrg.CoreApi.Errors namespaces.

using RandomOrg.CoreApi;
using RandomOrg.CoreApi.Errors;
  • RandomOrg.CoreApi contains the RandomOrgClient and RandomOrgCache classes
  • RandomOrg.CoreApi.Errors contains the following custom error classes:
    • RandomOrgBadHTTPResponseException
    • RandomOrgInsufficientBitsException
    • RandomOrgInsufficientRequestsException
    • RandomOrgJSONRPCException
    • RandomOrgKeyNotRunningException
    • RandomOrgRANDOMORGException
    • RandomOrgSendTimeoutException
    • RandomOrgCacheEmptyException

The default setup is best for non-time-critical serialized requests, e.g., batch clients:

RandomOrgClient roc = RandomOrgClient.GetRandomOrgClient(YOUR_API_KEY_HERE);
try {
	int[] response = roc.GenerateIntegers(5, 0, 10);
	Console.WriteLine(string.Join(",", response));
} catch (...) { ... }

Example output: 9, 5, 4, 1, 10

...or for more time sensitive serialized applications, e.g., real-time draws, use:

RandomOrgClient roc = RandomOrgClient.GetRandomOrgClient(YOUR_API_KEY_HERE, 2000, 10000, true);
try {
	Dictionary<string, object> response = roc.GenerateSignedIntegers(5, 0, 10);
	Console.WriteLine(string.Join(Environment.NewLine, response));
} catch (...) { ... }

[data, System.Int32[]]
[random, {
    "method": "generateSignedIntegers",
    "hashedApiKey": "HASHED_KEY_HERE",
    "n": 5,
    "min": 0,
    "max": 10,
    "replacement": true,
    "base": 10,
    "data": [
    "license": {
      "type": "developer",
      "text": "Random values licensed strictly for development and testing only",
      "infoUrl": null
    "userData": null,
    "ticketData": null,
    "completionTime": "2021-02-16 19:01:38Z",
    "serialNumber": 5623
[signature, SIGNATURE_HERE]

If obtaining some kind of response instantly is important, a cache should be used. A cache will populate itself as quickly and efficiently as possible allowing pre-obtained randomness to be supplied instantly. If randomness is not available - e.g., the cache is empty - the cache will throw a RandomOrgCacheEmptyException allowing the lack of randomness to be handled without delay:

RandomOrgClient roc = RandomOrgClient.GetRandomOrgClient(YOUR_API_KEY_HERE);
RandomOrgCache<int[]> c = roc.CreateIntegerCache(5, 0, 10);
while (true) {
	try {
		int[] randoms = c.Get();
		Console.WriteLine(string.Join(",", randoms));
	} catch (RandomOrgCacheEmptyException) {
		// handle lack of true random number here
		// possibly use a pseudo random number generator

10, 3, 1, 9, 0
8, 9, 8, 3, 5
3, 5, 2, 8, 2

Note that caches don't support signed responses as it is assumed that clients using the signing features want full control over the serial numbering of responses.

Finally, it is possible to request live results as-soon-as-possible and without serialization, however this may be more prone to timeout failures as the client must obey the server's advisory delay times if the server is overloaded:

RandomOrgClient roc = RandomOrgClient.GetRandomOrgClient(YOUR_API_KEY_HERE, 0, 10000, false);
try {
	int[] randoms = roc.GenerateIntegers(5, 0, 10);
	Console.WriteLine(string.Join(",", randoms));
} catch (...) { ... }

[8, 10, 10, 4, 0]

Signature Verification

There are two additional methods to generate signature verification URLs and HTML forms (CreateUrl and CreateHtml) using the random object and signature returned from any of the signed (value generating) methods. The generated URLs and HTML forms link to the same web page that is also shown when a result is verified using the online Signature Verification Form.


For a full list of available randomness generation functions and other features see the library documentation and https://api.random.org/json-rpc/4

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 161 12/17/2021
1.0.0 166 8/10/2021

This is a minor update to the documentation of this library. For more information please check the corresponding Github repository (https://github.com/RandomOrg/JSON-RPC-.NET) or the RANDOM.ORG JSON-RPC Core API documentation (https://api.random.org/json-rpc/4).