Python SDK

The Code Ocean Python SDK makes it even easier to leverage the full functionality of the extensive Code Ocean Public API in your Python scripts and applications.

Installation

The Python SDK requires Python >=3.11 and Code Ocean >=2.19

The SDK can be installed via pip as shown below:

pip install -U codeocean

For development, install from source with:

pip install -e .[dev] -

Authentication

When creating a CodeOcean client as shown below, you will use your Code Ocean API token. The Python library will then automatically send this key in each request. You can learn more about creating a Code Ocean API Token in our guide here.

from codeocean import CodeOcean​

client = CodeOcean(domain="https://{domain}", token="cop_d23dasd312")

Examples

The Capsule, Computation, and Data Asset sections of the Code Ocean API Guide all contain examples using the Python SDK.