Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Rdo

Random.org API client library for JavaScript.

Hierarchy

  • Rdo

Index

Constructors

constructor

  • new Rdo(conf?: { apiKey?: string; credentials?: { login: string; password: string } | { sessionId: string }; signed?: boolean }): Rdo
  • Parameters

    • Default value conf: { apiKey?: string; credentials?: { login: string; password: string } | { sessionId: string }; signed?: boolean } = {}
      • Optional apiKey?: string

        A Random.org API key.

      • Optional credentials?: { login: string; password: string } | { sessionId: string }

        A Random.org credentials object.

      • Optional signed?: boolean

        Sign the reponses from the Random.org API when using an API key.

    Returns Rdo

Properties

Private conf

conf: { apiKey?: string; credentials?: { login: string; password: string } | { sessionId: string }; signed?: boolean }

Type declaration

  • Optional apiKey?: string

    A Random.org API key.

  • Optional credentials?: { login: string; password: string } | { sessionId: string }

    A Random.org credentials object.

  • Optional signed?: boolean

    Sign the reponses from the Random.org API when using an API key.

Private hasCreds

hasCreds: boolean = false

If authenticated via credentials.

Private isAuthed

isAuthed: boolean = false

If authenticated via an API key.

Methods

blob

  • blob(__namedParameters?: { amount: number; size: number }): Promise<Blob[]>
  • Generates Binary Large OBjects (BLOBs) containing true random data.

    Parameters

    • Default value __namedParameters: { amount: number; size: number } = {}
      • amount: number
      • size: number

    Returns Promise<Blob[]>

decimal

  • decimal(__namedParameters?: { amount: number; places: number; unique: boolean }): Promise<number[]>
  • Generate true random decimal fractions from a uniform distribution across the [0,1] interval with a user-defined number of decimal places.

    Parameters

    • Default value __namedParameters: { amount: number; places: number; unique: boolean } = {}
      • amount: number
      • places: number
      • unique: boolean

    Returns Promise<number[]>

gaussian

  • gaussian(__namedParameters: { amount: number; mean: number; significantDigits: number; standardDeviation: number }): Promise<any>
  • Generate true random numbers from a Gaussian distribution (also known as a normal distribution). The form uses a Box-Muller Transform to generate the Gaussian distribution from uniformly distributed numbers.

    Parameters

    • __namedParameters: { amount: number; mean: number; significantDigits: number; standardDeviation: number }
      • amount: number
      • mean: number
      • significantDigits: number
      • standardDeviation: number

    Returns Promise<any>

integer

  • integer(__namedParameters: { amount: number; base: 2 | 8 | 10 | 16; max: number; min: number; unique: boolean }): Promise<number[]>
  • Generate true random integers within a user-defined range.

    Parameters

    • __namedParameters: { amount: number; base: 2 | 8 | 10 | 16; max: number; min: number; unique: boolean }
      • amount: number
      • base: 2 | 8 | 10 | 16
      • max: number
      • min: number
      • unique: boolean

    Returns Promise<number[]>

Private mustBeAuthed

  • mustBeAuthed(): void
  • Throw an error if not authenticated via an API key.

    Returns void

Private mustHaveCreds

  • mustHaveCreds(): void
  • Throw an error if not authenticated via some credentials.

    Returns void

quota

  • quota(): Promise<number | { bitsLeft: number; creationTime: Date; requestsLeft: number; running: boolean; totalBits: number; totalRequests: number }>
  • Returns Promise<number | { bitsLeft: number; creationTime: Date; requestsLeft: number; running: boolean; totalBits: number; totalRequests: number }>

sequence

  • sequence(__namedParameters: { amount: number; base: 2 | 8 | 10 | 16 | (2 | 8 | 10 | 16)[]; length: number | number[]; max: number | number[]; min: number | number[]; unique: false | true | boolean[] }): Promise<number[][]>
  • Generate uniform or multiform sequences of true random integers within user-defined ranges. Uniform sequences all have the same general form (length, range, replacement and base) whereas these characteristics can vary for multiform sequences.

    Parameters

    • __namedParameters: { amount: number; base: 2 | 8 | 10 | 16 | (2 | 8 | 10 | 16)[]; length: number | number[]; max: number | number[]; min: number | number[]; unique: false | true | boolean[] }
      • amount: number
      • base: 2 | 8 | 10 | 16 | (2 | 8 | 10 | 16)[]
      • length: number | number[]
      • max: number | number[]
      • min: number | number[]
      • unique: false | true | boolean[]

    Returns Promise<number[][]>

string

  • string(__namedParameters?: { amount: number; characters: string | string[]; length: number; unique: boolean }): Promise<string[]>
  • This method generates true random strings.

    Parameters

    • Default value __namedParameters: { amount: number; characters: string | string[]; length: number; unique: boolean } = {}
      • amount: number
      • characters: string | string[]
      • length: number
      • unique: boolean

    Returns Promise<string[]>

uuid

  • uuid(__namedParameters?: { amount: number }): Promise<string[]>

Object literals

delegation

delegation: object

The methods described here allows RANDOM.ORG account holders to delegate use of services to other RANDOM.ORG account holders. A ‘delegation’ is a relationship between two RANDOM.ORG accounts in which one (the delegator) gives another (the delegate) access to use a particular service (e.g., the Third-Party Draw Service) on behalf of the delegator. The delegator can later remove the delegation if it wishes.

add

  • add(__namedParameters: { delegateID: number; notifyDelegate: boolean; serviceID: number }): Promise<{ delegationKey: string }>
  • Create a delegation of a particular service between two RANDOM.ORG account holders.

    Parameters

    • __namedParameters: { delegateID: number; notifyDelegate: boolean; serviceID: number }
      • delegateID: number
      • notifyDelegate: boolean
      • serviceID: number

    Returns Promise<{ delegationKey: string }>

list

  • list(): Promise<Array<{ delegateID: number; delegationKey: string; delegatorID: number; serviceID: number }>>
  • List all delegations in which the user acts as delegator or delegate.

    Returns Promise<Array<{ delegateID: number; delegationKey: string; delegatorID: number; serviceID: number }>>

remove

  • remove(__namedParameters: { delegationKey: string; notifyDelegate: boolean }): Promise<boolean>
  • Allow a delegator to remove a delegation, effectively revoking rights previously granted with the add method.

    Parameters

    • __namedParameters: { delegationKey: string; notifyDelegate: boolean }
      • delegationKey: string
      • notifyDelegate: boolean

    Returns Promise<boolean>

handler

handler: object

Register a handler that will be used to deliver notifications about the creation and deletion of delegations in which the account holder is delegate.

remove

  • remove(): Promise<boolean>
  • Remove the handler that is being used to deliver notifications about the creation and deletion of delegations in which the account holder is delegate.

    Returns Promise<boolean>

set

  • set(__namedParameters: { handlerSecret: string; handlerURL: string }): Promise<boolean>
  • Register a handler that will be used to deliver notifications about the creation and deletion of delegations in which the account holder is delegate.

    Parameters

    • __namedParameters: { handlerSecret: string; handlerURL: string }
      • handlerSecret: string
      • handlerURL: string

    Returns Promise<boolean>

draw

draw: object

The Third-Party Draw Service allows clients to hold ‘drawings’ (US English) or ‘draws’ (UK, Irish and Australian English) in which a number of winners are selected from a pool of entries.

get

  • get(__namedParameters: { delegationKey: string; drawID: number; maxEntries: number }): Promise<DrawData>
  • Obtain information about a completed drawing, subject to access control of the drawing's privacy settings.

    Parameters

    • __namedParameters: { delegationKey: string; drawID: number; maxEntries: number }
      • delegationKey: string
      • drawID: number
      • maxEntries: number

    Returns Promise<DrawData>

hold

  • hold(__namedParameters: { delegationKey: string; entries: string[]; entryType: "opaque" | "email"; identicalEntriesPermitted: boolean; recordType: "public" | "private" | "entrantAccessible" | "test"; showEntries: boolean; showWinners: boolean; title: string; winnerCount: number; winnerHandling: "remove" | "replace" | "exclude"; winnerStart: number }): Promise<{ completionTime: Date; drawID: number; entryCount: number; recordURL: string | null; status: "completed" | "withheld" | "test"; winners: string[] | null }>
  • Hold a drawing in one single operation. All information required for the drawing is passed as parameters. For this reason, the client must have collected all the entries from which the winner(s) will be selected before the method is invoked. Once the invocation is made, it is not possible to add entries or to delete or modify the drawing.

    Parameters

    • __namedParameters: { delegationKey: string; entries: string[]; entryType: "opaque" | "email"; identicalEntriesPermitted: boolean; recordType: "public" | "private" | "entrantAccessible" | "test"; showEntries: boolean; showWinners: boolean; title: string; winnerCount: number; winnerHandling: "remove" | "replace" | "exclude"; winnerStart: number }
      • delegationKey: string
      • entries: string[]
      • entryType: "opaque" | "email"
      • identicalEntriesPermitted: boolean
      • recordType: "public" | "private" | "entrantAccessible" | "test"
      • showEntries: boolean
      • showWinners: boolean
      • title: string
      • winnerCount: number
      • winnerHandling: "remove" | "replace" | "exclude"
      • winnerStart: number

    Returns Promise<{ completionTime: Date; drawID: number; entryCount: number; recordURL: string | null; status: "completed" | "withheld" | "test"; winners: string[] | null }>

list

  • list(__namedParameters?: { delegationKey: string }): Promise<DrawData[]>
  • This method lets a RANDOM.ORG account holder list all the drawings in their account. Your client must set the method property of its JSON-RPC request object to listDraws.

    Parameters

    • Default value __namedParameters: { delegationKey: string } = {}
      • delegationKey: string

    Returns Promise<DrawData[]>

giveaway

giveaway: object

This API gives clients access to RANDOM.ORG's Multi-Round Giveaway Service. Ideally suited to video streaming in real-time, the service randomizes your list of up to 3,000 participants in up to 30 rounds. The client first creates the giveaway and then runs the rounds one at a time. In the final round, the service generates a verification code, valid for one month, which proves your giveaway wasn't rigged.

begin

  • begin(__namedParameters: { delegationKey: string; description: string; entries: string[]; rounds: number }): Promise<GiveawayDataCurr>
  • This method creates a new giveaway but does not yet run the rounds.

    Parameters

    • __namedParameters: { delegationKey: string; description: string; entries: string[]; rounds: number }
      • delegationKey: string
      • description: string
      • entries: string[]
      • rounds: number

    Returns Promise<GiveawayDataCurr>

cont

  • cont(__namedParameters: { delegationKey: string; giveawayKey: string }): Promise<GiveawayDataCurr>
  • This method runs a single round of a giveaway previously created with the begin method.

    Parameters

    • __namedParameters: { delegationKey: string; giveawayKey: string }
      • delegationKey: string
      • giveawayKey: string

    Returns Promise<GiveawayDataCurr>

get

  • get(__namedParameters: { giveawayKey: string }): Promise<GiveawayData>
  • This method obtains the details of a giveaway. The giveaway must have been created with the being method and can be either in completed or not completed state. The records of giveaways are public, so no authentication is required to use this method.

    Parameters

    • __namedParameters: { giveawayKey: string }
      • giveawayKey: string

    Returns Promise<GiveawayData>

list

  • list(__namedParameters?: { delegationKey: string }): Promise<GiveawayData[]>
  • This method lists all non-expired giveaways for a given RANDOM.ORG account.

    Parameters

    • Default value __namedParameters: { delegationKey: string } = {}
      • delegationKey: string

    Returns Promise<GiveawayData[]>

Generated using TypeDoc