Base URL

https://rbainfotech.com/api/api.php

Authentication

1. User Login (JWT Authentication)

Method: POST

URL: /api.php?login=true

Request Body:

{

“email”: “user@example.com”,

“password”: “securepassword”

}

Response Example:

{

“success”: true,

“token”: “your_jwt_token”

}

2. Protected Routes

All user-editing and product-related operations require the JWT token in the Authorization header:

Authorization: Bearer your_jwt_token

User Management (Protected Routes)

3. Get Logged-in User Details

Method: GET

URL: /api.php/users/{id}

Only the authenticated user can fetch their own details using the token.

If the ID in the request does not match the token’s user ID, access will be denied.

4. Create a User

Method: POST

URL: /api.php/users

Request Body:

{

“name”: “John Doe”,

“email”: “john@example.com”,

“password”: “securepassword”

}

5. Update Own User Profile (Requires JWT Token)

Method: PUT

URL: /api.php/users/{id}

Request Body:

{

“name”: “Updated Name”,

“email”: “updated@example.com”

}

Response Example:

{

“success”: true,

“message”: “User updated successfully”

}

Only the authenticated user can update their own profile.

If the ID in the request does not match the token’s user ID, access will be denied. Method: PUT

URL: /api.php/users/{id}

Only the authenticated user can update their own profile.

If the ID in the request does not match the token’s user ID, access will be denied.

6. Delete Own User Account (Requires JWT Token)

Method: DELETE

URL: /api.php/users/{id}

Response Example:

{

“success”: true,

“message”: “User deleted successfully”

}

Only the authenticated user can delete their own account.

If the ID in the request does not match the token’s user ID, access will be denied. Method: DELETE

URL: /api.php/users/{id}

Only the authenticated user can delete their own account.

If the ID in the request does not match the token’s user ID, access will be denied.

Product Management (Protected Routes)

7. Get All Products

Method: GET

URL: /api.php/products

8. Get a Specific Product

Method: GET

URL: /api.php/products/{id}

9. Create a Product (Requires JWT Token)

Method: POST

URL: /api.php/products

Request Body:

{

“name”: “New Product”,

“description”: “Product description”,

“price”: 99.99

}

10. Update a Product (Requires JWT Token)

Method: PUT

URL: /api.php/products/{id}

Request Body:

{

“name”: “Updated Product”,

“description”: “Updated description”,

“price”: 149.99

}

Response Example:

{

“success”: true,

“message”: “Product updated successfully”

}

Method: PUT

URL: /api.php/products/{id}

11. Delete a Product (Requires JWT Token)

Method: DELETE

URL: /api.php/products/{id}

Response Example:

{

“success”: true,

“message”: “Product deleted successfully”

}

Method: DELETE

URL: /api.php/products/{id}

Automatic Cleanup of Old Data

To prevent database overload, the API will automatically remove outdated records:

User Cleanup: Users inactive for more than 6 months will be deleted.

Product Cleanup: Products not updated in 1 year will be removed.

12. Trigger Data Cleanup (Requires Admin JWT Token)

Method: POST

URL: /api.php/cleanup

Response Example:

{

“success”: true,

“message”: “Old data cleaned up successfully”

}

Testing Instructions

JWT authentication is required for user editing and product management endpoints.

Use Postman or CURL to send requests.

Ensure that the server is running and accessible.

Modify the Base URL as per your setup.

For POST and PUT requests, use JSON format for data submission.