Skip to content

Home > @world-wide-lab/client > Client

Client class

You will need to create an instance of this class to communicate with the World-Wide-Lab server. You can then use the methods of this class to create participants, sessions and responses.

Signature:

typescript
export declare class Client

Constructors

Constructor

Modifiers

Description

(constructor)(options)

Create a new Client instance

Properties

Property

Modifiers

Type

Description

options

ClientOptions

Options the Client was created with

Methods

Method

Modifiers

Description

call(method, endpoint, data, options)

Call an endpoint at the API server

createParticipant(participantParams)

Create a new participant from sractch. Use getParticipant() if you want to get an existing participant or store their id. This function will not keep track of a participant's id.

createResponse(opts)

Create a new Response. See also Session.response()

createSession(sessionOptions)

Start a new Session. If a participant's id is stored, it will be used. see getParticipant().

deleteStoredParticipantId()

Delete the stored participantId.

getLeaderboardScores(leaderboardId, level, options)

Get the scores of a leaderboard.

getParticipant()

Get a Participant. If someone has already participanted on this machine and their IDs is saved, will return this existing participant. Otherwise, will create a new participant and store the corresponding id.

getStoredParticipantId()

Get the participantId of the last person that participated using your website (if their id was stored).

storeParticipantId(participantId)

Store the participantId of the last person that participated using your website.