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

# Exports

> GET /api/v1/exports — Télécharger vos données annotées dans 6 formats.

## Endpoint

```
GET https://dloopiq.onrender.com/api/v1/exports
Authorization: Bearer <jwt_acheteur>
```

***

## Paramètres

| Paramètre    | Obligatoire | Description                              |
| ------------ | ----------- | ---------------------------------------- |
| `format`     | ✅           | Format de sortie (voir ci-dessous)       |
| `status`     | ❌           | Filtrer par statut (défaut: `COMPLETED`) |
| `projectId`  | ❌           | Exporter uniquement un projet            |
| `type`       | ❌           | Filtrer par type de tâche                |
| `locale`     | ❌           | Filtrer par langue                       |
| `trainRatio` | ❌           | Ratio du split train (ex: `0.8`)         |
| `valRatio`   | ❌           | Ratio du split validation (ex: `0.1`)    |
| `testRatio`  | ❌           | Ratio du split test (ex: `0.1`)          |

***

## Formats disponibles

### `json` — JSON standard

```bash theme={null}
curl "https://dloopiq.onrender.com/api/v1/exports?format=json" \
  -H "Authorization: Bearer eyJhbGci..."
```

```json theme={null}
[
  {
    "id": "cmpkb4ghw00016qduu44p7n2q",
    "type": "SENTIMENT_ANALYSIS",
    "content": "Ce produit est fantastique !",
    "label": "Positif",
    "confidence": 0.87,
    "locale": "fr",
    "validatedAt": "2026-05-25T10:05:00Z"
  }
]
```

***

### `jsonl` — JSON Lines (une ligne par exemple)

Idéal pour le streaming et le fine-tuning GPT-style.

```bash theme={null}
curl "https://dloopiq.onrender.com/api/v1/exports?format=jsonl" \
  -H "Authorization: Bearer eyJhbGci..."
```

```
{"id":"cmpkb...","type":"SENTIMENT_ANALYSIS","content":"Ce produit est fantastique !","label":"Positif"}
{"id":"cmpkb...","type":"BINARY_CHOICE","content":"Cette image est-elle appropriée ?","label":"Oui"}
```

***

### `csv` — CSV classique

```bash theme={null}
curl "https://dloopiq.onrender.com/api/v1/exports?format=csv" \
  -H "Authorization: Bearer eyJhbGci..." \
  -o export.csv
```

```csv theme={null}
id,type,content,label,confidence,locale,validatedAt
cmpkb...,SENTIMENT_ANALYSIS,"Ce produit est fantastique !",Positif,0.87,fr,2026-05-25T10:05:00Z
```

***

### `openai` — Format OpenAI Chat fine-tuning

Prêt pour `openai api fine_tuning.jobs.create`.

```bash theme={null}
curl "https://dloopiq.onrender.com/api/v1/exports?format=openai" \
  -H "Authorization: Bearer eyJhbGci..."
```

```json theme={null}
{"messages":[{"role":"user","content":"Analyse le sentiment : Ce produit est fantastique !"},{"role":"assistant","content":"Positif"}]}
{"messages":[{"role":"user","content":"Analyse le sentiment : Service catastrophique"},{"role":"assistant","content":"Négatif"}]}
```

***

### `huggingface` — HuggingFace Datasets

Compatible avec `datasets.load_dataset('json', data_files=...)`.

```bash theme={null}
curl "https://dloopiq.onrender.com/api/v1/exports?format=huggingface" \
  -H "Authorization: Bearer eyJhbGci..."
```

```json theme={null}
{"text": "Ce produit est fantastique !", "label": "Positif", "label_id": 0}
{"text": "Service catastrophique",       "label": "Négatif", "label_id": 1}
```

***

### `alpaca` — Format Alpaca instruction-tuning

```bash theme={null}
curl "https://dloopiq.onrender.com/api/v1/exports?format=alpaca" \
  -H "Authorization: Bearer eyJhbGci..."
```

```json theme={null}
{"instruction": "Analyse le sentiment du texte suivant.", "input": "Ce produit est fantastique !", "output": "Positif"}
```

***

## Split train / val / test

```bash theme={null}
# 80% train, 10% validation, 10% test
curl "https://dloopiq.onrender.com/api/v1/exports?format=jsonl&trainRatio=0.8&valRatio=0.1&testRatio=0.1" \
  -H "Authorization: Bearer eyJhbGci..."
```

La réponse contient 3 fichiers dans une archive ZIP :

```
export.zip
├── train.jsonl    (80%)
├── val.jsonl      (10%)
└── test.jsonl     (10%)
```

<Note>
  Les ratios doivent additionner à 1.0 exactement. Si seulement `trainRatio` est fourni, l'export retourne un fichier unique sans split.
</Note>

***

## Usage Python complet

```python theme={null}
import requests
import json

headers = {'Authorization': f'Bearer {JWT}'}

# Export HuggingFace avec split
response = requests.get(
    'https://dloopiq.onrender.com/api/v1/exports',
    params={
        'format': 'huggingface',
        'trainRatio': 0.8,
        'valRatio': 0.1,
        'testRatio': 0.1
    },
    headers=headers
)

with open('export.zip', 'wb') as f:
    f.write(response.content)

# Charger avec HuggingFace datasets
from datasets import load_dataset
ds = load_dataset('json', data_files={'train': 'train.jsonl', 'test': 'test.jsonl'})
```
