Skip to content

REward API Endpoints Details

This document provides a comprehensive list and detailed description of all API endpoints used in the REward project.

Base URL: https://reward.ibrahim-azab.com/api

Authentication

Some endpoints require the X-API-Key header for security:

X-API-Key: 53cdf4760cdd5bd629a0b214d80e15ec

1. System & Diagnostics

1.1 Health Check

  • Endpoint: GET /
  • Description: Verifies API availability.
  • Response: json { "status": "ok", "message": "REward API v1.0" }

1.2 Test Connection

  • Endpoint: GET /test-connection
  • Description: Performs diagnostic tests to check DNS resolution, Google connectivity, and Firebase Firestore API connectivity.
  • Response: json { "timestamp": "2024-12-20 10:00:00", "server_ip": "...", "tests": { "dns_resolution": { "host": "firestore.googleapis.com", "success": true }, "google_connectivity": { "url": "https://www.google.com", "success": true }, "firestore_connectivity": { "url": "https://firestore.googleapis.com", "success": true } } }

2. Notifications & Communications

2.1 Send to Topic

  • Endpoint: POST /notify/topic
  • Description: Sends a push notification to all users subscribed to an FCM topic.
  • Payload: json { "topic": "all_users", "title": "Announcement", "body": "Message content" }

2.2 Send to User

  • Endpoint: POST /notify/user
  • Description: Sends a push notification to a specific user.
  • Payload: json { "userId": "user123", "title": "Hello", "body": "Personal message" }

2.3 Send OTP Email

  • Endpoint: POST /send-otp-email
  • Description: Sends an HTML email with a 6-digit OTP for verification.
  • Headers: X-API-Key required.
  • Payload: json { "email": "user@example.com", "otp": "123456" }

3. Kiosk (ESP32) Operations

3.1 Get Kiosk Info

  • Endpoint: GET /kiosk/{kioskId}
  • Description: Retrieves kiosk status and counts.

3.2 Update Kiosk Status

  • Endpoint: POST /kiosk/{kioskId}/status
  • Description: Updates operational status (available/maintenance).

3.3 Submit Transaction

  • Endpoint: POST /kiosk/transaction
  • Description: Submits recycled item counts and awards points.
  • Payload: json { "kioskId": "kiosk_01", "userId": "user123", "plasticCount": 5, "metalCount": 2 }

4. User Operations

4.1 Get User Info

  • Endpoint: GET /user/{userId}
  • Description: Retrieves profile and points.

4.2 Get User by Kiosk Code

  • Endpoint: GET /user/by-code/{kioskCode}
  • Description: Lookup user ID by temporary 8-digit kiosk code.

4.3 Reset Password

  • Endpoint: POST /reset-password
  • Description: Updates the user's password in Firebase Auth.
  • Headers: X-API-Key required.
  • Payload: json { "email": "user@example.com", "password": "new_secure_password" }