Skip to content

API Documentation

Aditya Shibu edited this page Feb 15, 2025 · 4 revisions

API Routes

Root route ("/")

  • Navigate to the root route to check if FastAPI has been setup correctly
  • Response:
{
  "message": "Welcome to the Smart Home API!"
}

Device info route ("/device_info")

  • Navigate to /device_info to retrieve the JSON of all simulated smart home devices.
  • The response includes details like device ID, name, status, connection status, IP address, and other relevant properties.

Change device Status ("/device/{id}/status")

  • Sending a POST request to this API randomly changes the specified status of a device.
  • The function changeDeviceStatus in devices_json.py handles this behavior.
  • Request:
POST /device/{id}/status
  • Response Example:
{
  "success": "Changed Status to on."
}

Change device name ("/device/{id}/name/{new_name}")

  • Sending a POST request to this API changes the name of a device.
  • The function changeDeviceName in devices_json.py handles this behavior.
  • Request:
POST /device/{id}/name/{new_name}
  • Response Example:
{
  "success": "Changed device name to new_name."
}

Get updates ("/updates")

  • Navigate to /updates to retrieve the list of updates.
  • The function getUpdates in devices_json.py handles this behavior.
  • Response Example:
{
  "updates": ["Update 1", "Update 2"]
}

Change connection status ("/device/{id}/connect")

  • Sending a POST request to this API toggles the connection status of a device.
  • The function changeConnection in devices_json.py handles this behavior.
  • Request:
POST /device/{id}/connect
  • Response Example:
{
  "success": "Connected device_name."
}