API des votes

Intégrez le système de vote dans vos applications via notre API REST.

Endpoints

Voter
POST /api/polls/{poll_id}/vote
Headers
Content-Type: application/json
Accept: application/json
Authorization: Bearer {token}
X-CSRF-TOKEN: {csrf_token}
Corps de la requête
{
    "votes": {
        "section_id_1": "option_id_1",
        "section_id_2": "option_id_2"
    },
    "voter_name": "John Doe",
    "voter_fingerprint": "abc123...",
    "time_spent": 45
}
Réponse (succès)
{
    "data": {
        "vote": { ... },
        "requires_verification": false,
        "verification_code": null,
        "results": { ... },
        "total_votes": 120,
        "remaining_votes": 2
    },
    "message": "✅ Vote enregistré avec succès !"
}
Obtenir les résultats
GET /api/polls/{poll_id}/results
Réponse
{
    "data": {
        "poll": { ... },
        "sections": [ ... ],
        "results": {
            "option_id_1": 25,
            "option_id_2": 18
        },
        "total_votes": 43,
        "unique_voters": 12,
        "reactions_total": 8,
        "comments_total": 3,
        "reactions_summary": {
            "like": 5,
            "love": 3
        },
        "recent_comments": [ ... ],
        "show_stats_public": true,
        "analytics": { ... },
        "achievements": [ ... ]
    }
}
Réagir
POST /api/polls/{poll_id}/react
{
    "reaction_type": "like" // love, haha, wow, sad, angry, fire, clap
}
Commenter
POST /api/polls/{poll_id}/comment
{
    "content": "Très bon sondage !",
    "parent_id": null
}

Codes d'erreur

Code Description
401 Authentification requise
403 OTP requis / Non autorisé
422 Erreur de validation / Limite atteinte
500 Erreur interne du serveur