Skip to content

API Reference ​

The FastBee backend provides RESTful APIs, and all requests must carry a JWT token.

Page Guide ​

Use CasesThird-party systems or custom frontends integrate with FastBee through RESTful APIs to manage resources such as products, devices, thing models, and scenes.
PrerequisitesThe backend service is running (API port 8080) and you have a system account that can log in.
Operation PathGet a captcha → Call /login to get a token → Carry Authorization: Bearer {token} in the request header → Call business endpoints.
Acceptance CriteriaAuthenticated calls return normal business data, and /swagger-ui.html opens the full Swagger API documentation.

Scope and Boundaries ​

  • The RESTful APIs target management-side integration and custom development, covering management operations on products, devices, thing models, scene linkage, and other resources.
  • Device data reporting and command delivery do not go through HTTP APIs; they use the MQTT protocol and are handled by the backend's built-in MQTT Broker.
  • The endpoint definitions in the backend source code fastbee-open-api module are authoritative; see Backend Development for the module structure.

Authentication ​

Get a Captcha ​

Login requires a graphical captcha by default (controlled by the system parameter sys.account.captchaEnabled, on by default). Call the captcha endpoint first:

GET /captchaImage

Response:

json
{
  "code": 200,
  "msg": "操作成功",
  "captchaEnabled": true,
  "uuid": "c9a1b2c3...",
  "img": "/9j/4AAQSkZJRg..."
}
  • img is the base64-encoded captcha image; the default captcha type is arithmetic, so code is the result of the expression shown in the image
  • uuid links the captcha to the login attempt and must be passed unchanged in the login request
  • If captchaEnabled is false (captcha disabled in the system parameters), the login request can omit code and uuid

Get a Token ​

POST /login
Content-Type: application/json

{
  "username": "admin",
  "password": "admin123",
  "code": "8",
  "uuid": "the uuid returned by captchaImage above"
}

Response:

json
{
  "code": 200,
  "msg": "操作成功",
  "token": "eyJhbGciOiJIUzI1NiJ9..."
}

Request Header ​

All subsequent requests must carry:

Authorization: Bearer {token}

Common Endpoints ​

Product Management ​

MethodPathDescription
GET/iot/product/listProduct list
POST/iot/productCreate a product
PUT/iot/productEdit a product
DELETE/iot/product/Delete a product

Device Management ​

MethodPathDescription
GET/iot/device/listDevice list
POST/iot/deviceCreate a device
PUT/iot/deviceEdit a device
DELETE/iot/device/Delete a device
GET/iot/device/runningStatus?deviceId=Device running status

Thing Model ​

MethodPathDescription
GET/iot/thingsModel/listThing model list
POST/iot/thingsModelCreate a thing model

Scene Linkage ​

MethodPathDescription
GET/iot/scene/listScene list
POST/iot/sceneCreate a scene
PUT/iot/sceneEdit a scene
DELETE/iot/scene/Delete scenes
PUT/iot/scene/updateStatusEnable/disable a scene

Online Documentation and Call Verification ​

The full API documentation is available via Swagger: after starting the backend, visit http://localhost:8080/swagger-ui.html.

Call verification example:

bash
# 1. Get a captcha, note the returned uuid, and solve the arithmetic expression in the image
curl http://localhost:8080/captchaImage

# 2. Log in to get a token (code is the captcha result, uuid comes from the previous step)
curl -X POST http://localhost:8080/login \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"admin123","code":"8","uuid":"uuid from the previous step"}'

# 3. Call a business endpoint with the token
curl http://localhost:8080/iot/product/list \
  -H "Authorization: Bearer {token}"

If step 3 returns the product list data, authentication and endpoint calls are working.

FAQ ​

The endpoint returns 401? ​

The token is missing or expired, or it is not placed in the Authorization header in the Bearer {token} format; call /login again to get a new token and retry.

Login returns a captcha error? ​

Login requires a captcha by default: call /captchaImage first to get the uuid and captcha image, fill code with the result of the arithmetic expression in the image (the default type), and pass the uuid unchanged in the login request. Make sure code and uuid come from the same captcha request and have not expired.

How do I see the complete endpoint list? ​

Visit the Swagger documentation at http://localhost:8080/swagger-ui.html after starting the backend; the corresponding controller list is also in the "API Controller Layer" section of Backend Development.

Which endpoint returns device real-time data? ​

Use GET /iot/device/runningStatus?deviceId={deviceId}; the device must be connected to the platform and have reported data, otherwise the result is empty.