Aller au contenu

rclone Agent — Référence API

Toutes les requêtes nécessitent un header Authorization :

Authorization: Bearer <RCLONE_AGENT_TOKEN>

Le token est stocké dans context.md sur le serveur.

http://localhost:<PORT> (depuis le VPS)
http://host.docker.internal:<PORT> (depuis un container Docker, ex: n8n)

Le port exact est dans context.md.


Vérifie que l’agent tourne et retourne des statistiques générales.

Requête :

Fenêtre de terminal
curl http://localhost:3001/health \
-H "Authorization: Bearer <TOKEN>"

Réponse :

{
"status": "ok",
"total_jobs": 8420,
"running": 2
}

Retourne le statut d’un job et les 30 dernières lignes de son log.

Requête :

Fenêtre de terminal
curl http://localhost:3001/status/j3a4f9c1 \
-H "Authorization: Bearer <TOKEN>"

Réponse (job en cours) :

{
"job_id": "j3a4f9c1",
"status": "RUNNING",
"src_drive_id": "0AL20FP2ksGoAUk9PVA",
"dst_drive_id": "0AJ3-jwswIxZSUk9PVA",
"path": "Dossier/Sous-dossier",
"item_type": "dossier",
"started_at": "2026-04-17T14:30:00",
"finished_at": null,
"exit_code": null,
"log_tail": "2026-04-17 14:30:00 Démarrage...\n..."
}

Statuts possibles :

StatutSignification
RUNNINGrclone est en cours d’exécution
SUCCESSTransfert terminé avec succès (exit code 0)
ERRORTransfert échoué (exit code ≠ 0)

Liste tous les jobs connus (en mémoire + disque).

Requête :

Fenêtre de terminal
curl http://localhost:3001/jobs \
-H "Authorization: Bearer <TOKEN>"

Réponse :

{
"jobs": [
{
"job_id": "j3a4f9c1",
"status": "SUCCESS",
"path": "Dossier/Fichier.pdf",
"started_at": "2026-04-17T14:30:00",
"finished_at": "2026-04-17T14:32:15"
}
]
}

Lance un transfert rclone en arrière-plan. Retourne immédiatement un job_id pour suivre la progression.

Requête :

Fenêtre de terminal
curl -X POST http://localhost:3001/transfer \
-H "Authorization: Bearer <TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"src_drive_id": "0AL20FP2ksGoAUk9PVA",
"dst_drive_id": "0AJ3-jwswIxZSUk9PVA",
"path": "Dossier/Fichier.pdf",
"type": "fichier"
}'

Corps de la requête :

ChampRequisDescription
src_drive_idID du Shared Drive source
dst_drive_idID du Shared Drive destination
pathChemin relatif dans le drive (sans / au début)
typefichierrclone copyto / dossierrclone copy

Réponse (202 Accepted) :

{
"job_id": "j3a4f9c1",
"log_file": "/home/sidy/scripts/logs/transfer_j3a4f9c1.log"
}

Liste le contenu d’un Shared Drive (jusqu’à une profondeur donnée).

Requête :

Fenêtre de terminal
curl -X POST http://localhost:3001/scan \
-H "Authorization: Bearer <TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"drive_id": "0AL20FP2ksGoAUk9PVA",
"max_depth": 2
}'

Réponse :

{
"items": [
{
"Path": "Dossier A",
"Name": "Dossier A",
"IsDir": true
},
{
"Path": "Dossier A/Fichier.pdf",
"Name": "Fichier.pdf",
"IsDir": false,
"Size": 204800
}
],
"count": 42
}

Vérifie si un fichier ou dossier existe déjà dans le drive destination.

Requête :

Fenêtre de terminal
curl -X POST http://localhost:3001/check \
-H "Authorization: Bearer <TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"dst_drive_id": "0AJ3-jwswIxZSUk9PVA",
"path": "Dossier/Fichier.pdf",
"type": "fichier"
}'

Réponse :

{
"exists": true,
"path": "Dossier/Fichier.pdf",
"type": "fichier"
}

Crée un nouveau Shared Drive sur le Compte B.

Requête :

Fenêtre de terminal
curl -X POST http://localhost:3001/create-drive \
-H "Authorization: Bearer <TOKEN>" \
-H "Content-Type: application/json" \
-d '{"name": "Nom du nouveau drive"}'

Réponse :

{
"id": "0AJ3-jwswIxZSUk9PVA",
"name": "Nom du nouveau drive"
}

CodeSignification
200Succès
202Job créé, traitement en cours
400Paramètre manquant ou JSON invalide
401Token Bearer incorrect
404Job ou endpoint introuvable
500Erreur interne (rclone a échoué)