Data Asset API
Prerequisites
Token with datasets scope
The data asset's ID to pass to the API call
You can find the data asset's ID below the title
Create a New Data Asset
POST
https://{domain}codeocean.com/api/v1/data_assets
Path Parameters
Name | Type | Description |
---|---|---|
{domain}* | String | Your VPC domain |
Headers
Name | Type | Description |
---|---|---|
Content-Type* | String | application/json |
-u* | String | \ '${API Token from Code Ocean}:\' \ |
Request Body
Name | Type | Description |
---|---|---|
name* | String | The name of the data asset. |
description* | String | A description for the data asset. |
mount* | String | A folder under the capsule data folder, where the data asset files are found. |
tags* | array | Keywords to search the data asset by. |
source* | String | Where the data asset originated. Currently only AWS is supported. |
source.aws* | String | Describes the S3 bucket from which the data asset was created. |
source.aws.access_key_id | String | The AWS key ID used to access the S3 bucket. Not required if it is a public S3 bucket. |
source.aws.secret_access_key | String | The AWS secret access key ID used to access the S3 bucket. Not required if it is a public S3 bucket. |
source.aws.bucket* | String | The S3 bucket from which the data asset will be created. |
source.aws.prefix* | boolean | The folder in the S3 bucket from which the data asset is created. This is only relevant when copying the files over to Code Ocean (keep_on_external_storage=false). |
source.aws.keep_on_External_storage* | boolean | When set to true, the data asset files will not be copied over to Code Ocean. The prefix property will be ignored and the entire S3 bucket will be used. |
source.aws.index_data* | boolean | When this property is true Code Ocean will index the files in the remote bucket to display the file tree in the dataset and capsule pages. This is only relevant when keep_on_external_storage is set to true. When keep_on_external_storage is false Code Ocean will always index the files. |
Example of creating a new data asset:
The examples here are executed from a capsule that utilizes the secret management feature. The API token was added as "Custom Key" and the AWS credential was added as "AWS Cloud Credential"
Get Data Asset Metadata
GET
https://{domain}.codeocean.com/api/v1/data_assets/{data assets ID}'
Path Parameters
Name | Type | Description |
---|---|---|
{domain}* | String | Your VPC domain |
{data assets ID}* | String | The dataset ID that you want to get the metadata from |
Headers
Name | Type | Description |
---|---|---|
Authorization* | String | Basic ${API Token from Code Ocean} |
Search Data Assets
GET
https://{domain}.codeocean.com/api/v1/data_assets/{data assets ID}'
Path Parameters
Name | Type | Description |
---|---|---|
{domain}* | String | Your VPC domain |
Query Parameters
Name | Type | Description |
---|---|---|
start | int | describes the search from index |
limit | int | |
sort_field | String | option: created/type/name/size determines the field to sort by |
sort_order | String | option: asc/desc determines the result sort order. must be provided with sort_field, otherwise ignored |
query | String | determines the search query. can be a free text or in the form of “name:... tag:... run_script:... commit_id:...” |
type | String | option: dataset/result if omitted results may include both datasets and results |
ownership | String | option: owner/shared search data asset by ownership |
favorite | boolean | search only favorite data assets |
archived | boolean | search only archived data assets |
Headers
Name | Type | Description |
---|---|---|
-u* | String | \ '${API Token from Code Ocean}:\' \ |
The default number of items returned from Search Data Assets is 10.
Update Data Asset Metadata
PUT
https://{domain}.codeocean.com/api/v1/data_assets/{data_set_id}
Path Parameters
Name | Type | Description |
---|---|---|
{domain}* | String | Your VPC domain |
{data_set_id}* | String | Data Asset's id |
Headers
Name | Type | Description |
---|---|---|
-u* | String | \ '${API Token from Code Ocean}:\' \ |
Request Body
Name | Type | Description |
---|---|---|
name* | String | data asset name |
description* | String | data asset description |
tags | array | array of string tags |
mount | String | default mount folder |
Delete Data Asset
DELETE
https://{domain}.codeocean.com/api/v1/data_assets/{data_set_id}
Path Parameters
Name | Type | Description |
---|---|---|
{domain}* | String | Your VPC domain |
{data_set_id}* | String | Data Asset's id |
Headers
Name | Type | Description |
---|---|---|
-u* | String | \ '${API Token from Code Ocean}:\' \ |
Archive Data Asset
PATCH
https://{domain}.codeocean.com/api/v1/data_assets/{data_set_id}/archive?archive=true
Path Parameters
Name | Type | Description |
---|---|---|
{domain}* | String | Your VPC domain |
{data_set_id}* | String | Data Asset's id |
archive* | Boolean | If true will archive a data asset. Otherwise will unarchive it. |
Headers
Name | Type | Description |
---|---|---|
-u* | String | \ '${API Token from Code Ocean}:\' \ |
Last updated