Skip to content

API Endpoints Reference 🚀

All requests should be sent to the base URL: https://yourdomain.com/api/


🤖 Kiosk Endpoints

Used primarily by the ESP32 hardware.

1. Update Kiosk Status

POST /kiosk/{kioskId}/status - Auth: X-API-Key header required. - Body: { "status": "available" | "maintenance" | "offline" } - Description: Updates the real-time health status of the machine shown on the map.

2. Submit Transaction

POST /kiosk/transaction - Auth: X-API-Key header required. - Body: json { "kioskId": "kiosk123", "userId": "user_abc", "plasticCount": 5, "metalCount": 2 } - Description: The core recycling logic. It updates user points, increments kiosk totals, logs the transaction, and sends a push notification.


📱 User & Info Endpoints

General data retrieval.

3. Get User Info

GET /user/{userId} - Description: Fetches the current points and profile data for a specific user directly from Firestore.

4. Get Kiosk Info

GET /kiosk/{kioskId} - Description: Retrieves details for a specific machine, including its coordinates and opening hours.


📢 Notification Endpoints

Administrative and system alerts.

5. Send Notification to Topic

POST /notify/topic - Body: { "topic": "all_users", "title": "New Reward!", "body": "Starbucks coupons are back." } - Description: Triggers a global push notification to all users subscribed to a specific FCM topic.

6. Send OTP (Email)

POST /send-otp-email - Body: { "email": "user@example.com", "otp": "123456" } - Description: Sends a password reset or verification OTP using the server's mail system.


📦 Postman Collection

A pre-configured Postman collection is available in the api/ directory: REward_API.postman_collection.json. You can import this to test all endpoints during development.