Skip to main content
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.
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.
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

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.
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.