iot REST API Documentation

iot REST API Documentation

IoT 허브 REST API 문서

2021년 07월 06일

서비스 소개

#Auth API



[POST] /api/login

Make login with ID and password. Returns JWT.

Parameters

NameTypeInDescription
idstringbodyRequired. Login ID for control hub.
pwstringbodyRequired. Login password for control hub.


Response

  • Success:
    • Code: 201
    • Content: <JWT|string>
  • Error:
CodeContent
401authentication failed




[POST] /api/autologin

Make login JWT. Returns id

Parameters

NameTypeInDescription
jwtstringheaderRequired. Previously signed JWT for control hub.


Response

  • Success:
    • Code: 201
    • Content:
      {
        id: [string],
        exp: [integer],
        iat: [integer]
      }
      
  • Error:
CodeContent
401authentication failed


#Device API



[GET] /device/all

Get registered devices list

Parameters

NameTypeInDescription
jwtstringheaderRequired. Previously signed JWT for control hub.


Response

  • Success:
    • Code: 200
    • Content:
      [
        {
          id: <device id|string>,
          status: <device status|json>,
          online: <divice online status|bool>
        }
        ...
      ]
      
  • Error:
CodeContent
401authentication failed




[GET] /device/:deviceId

Get device status.

Parameters: None

Response

  • Success:
    • Code: 200
    • Content:
      {
        id: <device id|string>,
        status: <device status|json>,
        online: <divice online status|bool>
      }
      
  • Error:
CodeContent
400Invalid request parameters
404device <deviceId> not found


Response’s < device status > contents

Device TypeContent
passiveSwitch{ power: [bool] }
passiveTactSwitch{ }
ledDisplaynot supported




[POST] /device/:deviceId

Write device status.

Parameters:

  • Common
    All requests requires jwt token.
NameTypeInDescription
jwtstringheaderRequired. Previously signed JWT for control hub.


  • passiveSwitch
NameTypeInDescription
toggleboolbodyIf true, toggles device’s power status.
powerboolbodySet device’s power status.


  • passiveTactSwitch
NameTypeInDescription
pushboolbodyIf true, pushes switch of device


Response

  • Success:
    • Code: 201
    • Content: { status: <device status|json> }
  • Error:
CodeContent
400Invalid request parameters
401device <deviceId> not found
404device <deviceId> not found
503device <deviceId> is offline