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.
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.
Parameter | Description |
---|---|
experimentID | The ID of the experiment to save data for. This ID is provided when an experiment is created on DataPipe. |
data | The text-based data to save, sent as a string. |
filename | The name of the file to create. This filename must be unique. If the file already exists the request will fail. |
POST /api/base64
Save a base64-encoded file to the OSF. The file will be decoded before being posted to the OSF.
Parameter | Description |
---|---|
experimentID | The ID of the experiment to save data for. This ID is provided when an experiment is created on DataPipe. |
data | The base64-encoded data to save, sent as a string. |
filename | The name of the file to create. This filename must be unique. If the file already exists the request will fail. |
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.
Parameter | Description |
---|---|
experimentID | The 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.
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.
Error | Message |
---|---|
MISSING_PARAMETER | One or more required parameters are missing. |
DATA_COLLECTION_NOT_ACTIVE | Data collection is not active for this experiment |
BASE64DATA_COLLECTION_NOT_ACTIVE | Base64 data collection is not active for this experiment |
CONDITION_ASSIGNMENT_NOT_ACTIVE | Condition assignment is not active for this experiment |
EXPERIMENT_NOT_FOUND | The experiment ID does not match an experiment |
INVALID_OWNER | The owner ID of this experiment does not match a valid user |
INVALID_OSF_TOKEN | The OSF token for this experiment is not valid |
INVALID_BASE64_DATA | The data are not valid base64 data |
INVALID_DATA | The data are not valid according to the validation parameters set for this experiment. |
SESSION_LIMIT_REACHED | The session limit for this experiment has been reached |
UNKNOWN_ERROR_GETTING_CONDITION | An unknown error occurred while getting the condition for this experiment |
OSF_FILE_EXISTS | The OSF file already exists. File names must be unique. |
OSF_UPLOAD_ERROR | An error occurred while uploading the data to OSF |