Prerequisites
The computation ID to pass to the API call
The computation ID can only be accessed from the response from the API calls. A typical use cases are to use List capsule computations API to locate the computation ID from a capsule or Run capsule API to start a new computation. Both of the methods will have the computations ID in the response body that can use in computations API for further tracking and getting the results.
Getting Computation
POST
https://{domain}.codeocean.com/api/v1/computations/{computations_id}
This API allows for the retrieval of information from a computational run.
Path Parameters
Request Body
200: OK 400: Bad Request invalid request body 401: Unauthorized 404: Not Found 500: Internal Server Error
Request Response Description
items - array, dictionary
Size
the item size in bytes - only available for files
Request Format
Copy curl --location --request POST 'https://{domain}/api/v1/computations/{computational_id}/results' \
--header 'Content-Type: application/json' \
-u \'${API_SECRET} : \' \
--data-raw '{
"path": ""
}'
Request Example Bash
Copy curl --location --request POST 'https://apps.codeocean.com/api/v1/computations/c229ed13-ec06-43d0-abd9-4d481af3f5e3/results' \
--header 'Content-Type: application/json' \
-u \'${API_SECRET} : \' \
--data-raw '{
"path": ""
}'
Request Example Python
Copy import os , requests
headers = {
"Content-Type" : "application/json"
}
json_data = {
"path" : ""
}
response = requests.post( 'https://apps.codeocean.com/api/v1/computations/c229ed13-ec06-43d0-abd9-4d481af3f5e3/results', headers=headers, json=json_data, auth=("'" + os.getenv('API_SECRET', ''), "'"), )
Request Example Response
Copy {
"items" : [
{
"name" : "1RH7.pdb" ,
"path" : "1RH7.pdb" ,
"size" : 346599 ,
"type" : "file"
} ,
{
"name" : "output" ,
"path" : "output" ,
"size" : 26 ,
"type" : "file"
}
]
}
List Files Computation URL
POST
https://{domain}.codeocean.com/api/v1/computations/{computations_id}
This API allows for the retrieval of information from a computational run.
Path Parameters
Request Body
200: OK 400: Bad Request invalid request body 401: Unauthorized 404: Not Found 500: Internal Server Error
Response CodeRequest Format
Copy curl --location --request POST 'https://{domain}/api/v1/computations/{computational_id}/results’ \
--header ' Content-Type: application/json ' \
-u \' ${API_SECRET} : \'
Request Example Bash
Copy curl --location --request POST
'https://apps.codeocean.com/api/v1/computations/c229ed13-ec06-43d0-abd9-4d481af3f5e3/results' \
--header 'Content-Type: application/json' \
-u \'${API_SECRET} : \'
Request Example Python
Copy import os , requests
headers = {
"Content-Type" : "application/json"
}
params = {
"path" : "fig1.png"
}
response = requests.post( 'https://apps.codeocean.com/api/v1/computations/c229ed13-ec06-43d0-abd9-4d481af3f5e3/results/download_url',
params = params , headers = headers , auth = ( "'" + os . getenv ( 'API_SECRET' , '' ), "'" ) , )
Request Example Response
Copy { "message" : "not found" }
Last updated 8 months ago