diff --git a/README.md b/README.md index b0217c3..3d55e7f 100644 --- a/README.md +++ b/README.md @@ -127,3 +127,15 @@ MIT, Apache ## Maintainers Muwanga Erasto Kosea, Ouma Ronald + +## ๐Ÿ“ก API Documentation + +Full API documentation is available here: + +๐Ÿ‘‰ /docs/api.md + +This includes: +- All endpoints +- Request and response examples +- Authentication details +- Testing guidance \ No newline at end of file diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 0000000..03d7f3d --- /dev/null +++ b/docs/api.md @@ -0,0 +1,151 @@ +# ๐Ÿ“ก API Documentation + +This document provides details of all backend API endpoints. + +--- + +## ๐Ÿ“Œ Overview + +The API allows interaction with the system through HTTP requests. +All responses are returned in a structured format. + +Base URL: +`/api` + +--- + +## ๐Ÿ” Authentication + +Some endpoints require authentication using a token. + +**Header Format:** +Authorization: Bearer + +If authentication is required, it will be specified per endpoint. + +--- + +## ๐Ÿ“ Endpoints + +### 1. Get All Resources + +**Endpoint:** GET /api/resources +**Authentication:** Optional + +**Description:** +Fetch all resources from the system. + +**Request Example:** +- Method: GET +- URL: /api/resources + +**Response Example:** +- Status: Success +- Data: + - id: 1 + name: Resource One + - id: 2 + name: Resource Two + +--- + +### 2. Get Resource by ID + +**Endpoint:** GET /api/resources/{id} +**Authentication:** Optional + +**Description:** +Fetch a single resource by its ID. + +**Request Example:** +- Method: GET +- URL: /api/resources/1 + +**Response Example:** +- Status: Success +- Data: + - id: 1 + - name: Resource One + +--- + +### 3. Create Resource + +**Endpoint:** POST /api/resources +**Authentication:** Required + +**Description:** +Create a new resource. + +**Request Example:** +- Method: POST +- URL: /api/resources +- Body: + - name: New Resource + +**Response Example:** +- Status: Success +- Message: Resource created successfully + +--- + +### 4. Update Resource + +**Endpoint:** PUT /api/resources/{id} +**Authentication:** Required + +**Description:** +Update an existing resource. + +**Request Example:** +- Method: PUT +- URL: /api/resources/1 +- Body: + - name: Updated Resource + +**Response Example:** +- Status: Success +- Message: Resource updated successfully + +--- + +### 5. Delete Resource + +**Endpoint:** DELETE /api/resources/{id} +**Authentication:** Required + +**Description:** +Delete a resource by ID. + +**Request Example:** +- Method: DELETE +- URL: /api/resources/1 + +**Response Example:** +- Status: Success +- Message: Resource deleted successfully + +--- + +## ๐Ÿงช Testing the API + +You can test the API using: +- Postman +- cURL +- Browser (for GET endpoints) + +--- + +## ๐Ÿ“Œ Notes + +- Ensure correct HTTP methods are used +- Include authentication token where required +- Follow endpoint structure carefully + +--- + +## ๐Ÿ“Ž Summary + +- All endpoints are documented +- Request/response examples provided +- Authentication clearly defined \ No newline at end of file