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

# HTTP and Python

> Call Deepline plays from Python or any runtime that can make HTTP requests. Use it to pilot on a few rows, verify the output, and scale the workflow safely.

Job: run a Deepline workflow from a non-TypeScript system.

Python does not author `.play.ts` files. Python calls a saved or prebuilt play over HTTP.

## Environment

Put the Deepline host and workspace key in `.env.deepline`. The example Python
script reads that file directly.

```bash theme={null}
python3 -m pip install requests
cat >.env.deepline <<'ENV'
DEEPLINE_HOST_URL=https://code.deepline.com
DEEPLINE_API_KEY=dl_workspace_key
ENV
```

## Start a run

This is the shape of a small Python caller.

```python theme={null}
start = requests.post(
    f"{BASE_URL}/api/v2/plays/run",
    headers=headers,
    json={
        "name": "prebuilt/person-linkedin-to-email",
        "input": {
            "linkedin_url": "https://www.linkedin.com/in/example-person/",
        },
    },
)
workflow_id = start.json()["workflowId"]
```

## Poll until done

```python theme={null}
status = requests.get(
    f"{BASE_URL}/api/v2/runs/{workflow_id}",
    headers=headers,
)
```

Stop polling when status is `completed`, `failed`, or `cancelled`.

## Write the result

For a first script, write the final response to JSON. Convert to CSV only after you know the result shape.

```python theme={null}
with open("person-email-result.json", "w") as f:
    json.dump(body, f, indent=2)
```

If the response is failed, keep the JSON. It has the run id and error context your teammate or support will ask for.

## When to use Python

Use Python when the job already starts in:

* Airflow
* a CRM export script
* a data warehouse task
* a notebook
* a backend service that should not shell out

Use TypeScript when you are authoring the play itself.
