> For the complete documentation index, see [llms.txt](https://docs.growthepie.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.growthepie.com/recipes-tutorials/recipes/export-to-csv.md).

# Export To CSV

This recipe downloads one metric export and writes it to CSV. Use this recipe when you want a local file for spreadsheet workflows, versioned data snapshots, or notebook inputs.

## Example

```python
import csv
import requests

url = "https://api.growthepie.com/v1/export/txcount.json"
rows = requests.get(url, timeout=30).json()

with open("txcount.csv", "w", newline="", encoding="utf-8") as f:
    writer = csv.DictWriter(f, fieldnames=["metric_key", "origin_key", "date", "value"])
    writer.writeheader()
    writer.writerows(rows)

print("Wrote txcount.csv")
```

## Related Pages

* [Fetch growthepie Data In Python](/recipes-tutorials/recipes/fetch-growthepie-data-in-python.md)
* [Endpoint: export/{metric}.json](/api-reference/api/export-metric-json.md)
