# Retrieve data from your endpoint with Python - Docs

Call PostHog endpoints from Python using the `requests` library.

## Basic request

Python

PostHog AI

```python
import requests
url = "<ph_app_host>/api/environments/{project_id}/endpoints/{endpoint_name}/run"
headers = {"Authorization": "Bearer {POSTHOG_PERSONAL_API_KEY}"}
response = requests.get(url, headers=headers)
data = response.json()
print(data)
```

## With variables

Python

PostHog AI

```python
import requests
url = "<ph_app_host>/api/environments/{project_id}/endpoints/{endpoint_name}/run"
headers = {"Authorization": "Bearer {POSTHOG_PERSONAL_API_KEY}"}
body = {"variables": {"customer_id": "cust_123"}}
response = requests.post(url, headers=headers, json=body)
data = response.json()
```

### Community questions

Ask a question

### Was this page useful?

HelpfulCould be better