Home FAQ Community Chat 💬 API Docs 🔗

RESTful API Documentation: Client FAQ

This document describes the use of the API to manipulate the `FAQ/Question` resource (`faq_client`).

Base Endpoint: https://khelaf-hanifi.com/api-faq.php

Security & Authentication

Sensitive methods (**PUT** and **DELETE**) are protected by an **API Key** which must be transmitted as a URL parameter.

Admin Key (to use for PUT/DELETE):

key=Lab2025_Secret_Api_Key_2024

Unauthorized access to these methods will return a **403 Forbidden** code.


GET Read Questions

Allows retrieving the list of questions or a specific question (only questions with 'answered' status).

Action URL/Parameters Description HTTP Status
Read Collection (with pagination) /api-faq.php?limit=5&offset=0 Returns a paginated list of public (answered) questions. 200 OK
Read Specific Resource /api-faq.php?id={ID} Returns a question by its ID. 200 OK or 404 Not Found

Example Response 200 (Collection)

{
    "status": "success",
    "message": "Questions list retrieved successfully with pagination.",
    "data": {
        "metadata": {
            "total": 42,
            "limit": 5,
            "offset": 0,
            "returned": 5
        },
        "questions": [
            { "id": 10, "question": "How can I reset my password?", "reponse": "Please click on 'Forgot Password'...", "auteur": "Client" },
            // ... other questions ...
        ]
    }
}

POST Create a Question

Allows a client to post a new question. The default status is `'en_attente'` (pending).

URL Request Body (JSON) HTTP Status
/api-faq.php {"question": "Your question here", "auteur": "Your name"} 201 Created or 400 Bad Request

Example Request Body

{
    "question": "What is the average response time for a new question?",
    "auteur": "Curious"
}

PUT Update (Admin Answer)

Allows the administrator to provide an answer to a pending question, changing its status to `'répondu'` (answered).

URL/Parameters Request Body (JSON) HTTP Status
/api-faq.php?id={ID}&key={KEY} {"reponse": "The official company answer."} 200 OK, 403 Forbidden, or 404 Not Found

DELETE Delete a Question (Admin)

Allows the administrator to permanently delete a question.

URL/Parameters Request Body HTTP Status
/api-faq.php?id={ID}&key={KEY} (None) 200 OK, 403 Forbidden, or 404 Not Found