API Documentation

Using the API requires setting up an experiment to obtain an experiment ID. Code examples for using JavaScript and jsPsych are available in the experiment dashboard.

Save text-based data

POST /api/data

Save a text-based data file to the OSF. The data can be optionally validated by setting up validation rules in the experiment configuration.

ParameterDescription
experimentIDThe ID of the experiment to save data for. This ID is provided when an experiment is created on DataPipe.
dataThe text-based data to save, sent as a string.
filenameThe name of the file to create. This filename must be unique. If the file already exists the request will fail.

Save base64-encoded data

POST /api/base64

Save a base64-encoded file to the OSF. The file will be decoded before being posted to the OSF.

ParameterDescription
experimentIDThe ID of the experiment to save data for. This ID is provided when an experiment is created on DataPipe.
dataThe base64-encoded data to save, sent as a string.
filenameThe name of the file to create. This filename must be unique. If the file already exists the request will fail.

Get condition assignment

POST /api/condition

Get the next condition assignment in an experiment. The condition is a numerical value from 0 to n-1, where n is the number of conditions in the experiment. Condition assignment is sequential, so the first request will return 0, the second request will return 1, and so on.

ParameterDescription
experimentIDThe ID of the experiment. This ID is provided when an experiment is created on DataPipe.

On a successful request, the JSON response will contain a condition parameter with the condition assignment.

API Responses

Responses from the API are JSON. On a successful request the response will contain a message parameter will the value Success. When an error occurs, the responses will contain one of the error and message parameter sets shown below.

ErrorMessage
MISSING_PARAMETEROne or more required parameters are missing.
DATA_COLLECTION_NOT_ACTIVEData collection is not active for this experiment
BASE64DATA_COLLECTION_NOT_ACTIVEBase64 data collection is not active for this experiment
CONDITION_ASSIGNMENT_NOT_ACTIVECondition assignment is not active for this experiment
EXPERIMENT_NOT_FOUNDThe experiment ID does not match an experiment
INVALID_OWNERThe owner ID of this experiment does not match a valid user
INVALID_OSF_TOKENThe OSF token for this experiment is not valid
INVALID_BASE64_DATAThe data are not valid base64 data
INVALID_DATAThe data are not valid according to the validation parameters set for this experiment.
SESSION_LIMIT_REACHEDThe session limit for this experiment has been reached
UNKNOWN_ERROR_GETTING_CONDITIONAn unknown error occurred while getting the condition for this experiment
OSF_FILE_EXISTSThe OSF file already exists. File names must be unique.
OSF_UPLOAD_ERRORAn error occurred while uploading the data to OSF

Created by the developers of jsPsych

Report an Issue

GitHub

Contact Us