> For the complete documentation index, see [llms.txt](https://docs.codeocean.com/user-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.codeocean.com/user-guide/code-ocean-api/python-sdk.md).

# 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 <a href="#installation" id="installation"></a>

{% hint style="info" %}
The Python SDK requires Python >=3.11 and Code Ocean >=2.19
{% endhint %}

The SDK can be installed via pip as shown below:

```bash
pip install -U codeocean
```

For development, install from source with:

```bash
pip install -e .[dev] -
```

## Authentication <a href="#authentication" id="authentication"></a>

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](/user-guide/code-ocean-api/authentication.md).

```python
from codeocean import CodeOcean​

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

## Examples <a href="#examples" id="examples"></a>

The [Capsule](/user-guide/code-ocean-api/capsule.md), [Computation](/user-guide/code-ocean-api/computation.md), and [Data Asset](/user-guide/code-ocean-api/data-asset.md) sections of the Code Ocean API Guide all contain examples using the Python SDK.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.codeocean.com/user-guide/code-ocean-api/python-sdk.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
