> ## Documentation Index
> Fetch the complete documentation index at: https://learn.alphacast.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect Alphacast to Python

> Load Alphacast datasets into pandas with the Python SDK, starting from code you copy in the app.

The Alphacast Python SDK loads datasets into pandas. The app can write the code for the dataset you are viewing.

## Copy code from a dataset

**1. Open the dataset**

Apply any filters for columns, entities or dates. The code includes them.

**2. Copy the code**

Click **Download**. Under **Connect data**, open **Python** and copy the code.

**3. Run it**

Paste it in a notebook. The first line, `!pip install alphacast`, uses notebook syntax. In a script, remove that line and run `pip install alphacast` in your terminal.

![Use this data panel with the Python code](https://mintcdn.com/alphacastio/S4wtX2Iw06s3xHSn/images/app/connect-python.jpg?fit=max\&auto=format\&n=S4wtX2Iw06s3xHSn\&q=85\&s=b13c3766caac755f393a6bc1c6c6f1ff)

## Write it yourself

Keep your API key out of your code. This example reads it from an environment variable.

```bash theme={null}
pip install alphacast
```

```python theme={null}
import os
from alphacast import Alphacast

alphacast = Alphacast(os.environ["ALPHACAST_API_KEY"])

dataset_id = 12345  # replace with your dataset ID
df = alphacast.datasets.dataset(dataset_id).download_data(format="pandas")
print(df.head())
```

To get your key, see [account settings](https://learn.alphacast.io/settings.md#get-or-reset-your-api-key).

> [!WARNING]
>
> The code that you copy from the app contains your API key. Remove it before you share a notebook or commit code.

## Access and limits

Your [plan](https://www.alphacast.io/pricing) and repository permissions determine which data you get and how much you can download.

## Next steps

> [card] [Python quickstart](https://learn.alphacast.io/python-sdk/quickstart.md)
>
> Create, upload and download a dataset.

> [card] [Download data](https://learn.alphacast.io/python-sdk/downloading.md)
>
> Filter by date, entity and column.

> [card] [Search](https://learn.alphacast.io/python-sdk/search.md)
>
> Find datasets from code.

> [card] [Upload data](https://learn.alphacast.io/python-sdk/uploading.md)
>
> Send DataFrames to Alphacast.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.