Computation API

Prerequisites

  • Token with capsule scope

  • 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

NameTypeDescription

POST*

/computations/:computation_id/results

Headers

NameTypeDescription

-u*

Authorize with Code Ocean API Secret: -u $API_SECRET :

This is setting the "Authorization Basic" base64string header

-H*

Set this to: Content - Type: application/json

--data-raw*

JSON data with capsule/pipeline information

Request Body

NameTypeDescription

computational_id

string

Identification of computational run

Request Response Description
  • items - array, dictionary

    • Name

      • the name of the entry

    • Path

      • full path to the item

    • Size

      • the item size in bytes - only available for files

    • Type - file, folder

      • the type of the item

Request Format
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
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
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
{
  "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

NameTypeDescription

POST*

/computations/:computation_id/results

Headers

NameTypeDescription

-u*

authorize with Code Ocean API Secret:

-u $API_SECRET:

This is setting the "Authorization

Basic" base64string header

-H*

Set this to: Content - Type: application/json

Request Body

NameTypeDescription

computational_id*

string

identification of the computational run

Response Code

AWS URL - http

Request Format
curl --location --request POST 'https://{domain}/api/v1/computations/{computational_id}/results’ \
--header 'Content-Type: application/json' \
-u \'${API_SECRET}:\'
Request Example Bash
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
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
{"message":"not found"}